Skip to content

Commit

Permalink
[BUGFIX] Mission: alt des illustrations (PIX-15601)
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Dec 5, 2024
2 parents 8c2f901 + a73dc02 commit 68e40ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 6 additions & 4 deletions api/src/school/infrastructure/repositories/mission-repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { Mission, MissionContent, MissionStep } from '../../domain/models/Missio
import { MissionNotFoundError } from '../../domain/school-errors.js';
import { missionDatasource } from '../datasources/learning-content/mission-datasource.js';

const { FRENCH_FRANCE } = LOCALE;
const { FRENCH_SPOKEN } = LOCALE;

function _toDomain(data, locale) {
const translatedName = getTranslatedKey(data.name_i18n, locale);
const translatedLearningObjectives = getTranslatedKey(data.learningObjectives_i18n, locale);
const translatedValidatedObjectives = getTranslatedKey(data.validatedObjectives_i18n, locale);
const translatedIntroductionMediaAlt = getTranslatedKey(data.introductionMediaAlt_i18n, locale);
const translatedContent = getTranslatedContent(data.content, locale);

return new Mission({
id: data.id,
name: translatedName,
Expand All @@ -22,13 +24,13 @@ function _toDomain(data, locale) {
validatedObjectives: translatedValidatedObjectives,
introductionMediaUrl: data.introductionMediaUrl,
introductionMediaType: data.introductionMediaType,
introductionMediaAlt: data.introductionMediaAlt,
introductionMediaAlt: translatedIntroductionMediaAlt,
documentationUrl: data.documentationUrl,
content: translatedContent,
});
}

async function get(id, locale = { locale: FRENCH_FRANCE }) {
async function get(id, locale = FRENCH_SPOKEN) {
try {
const missionData = await missionDatasource.get(parseInt(id, 10));
return _toDomain(missionData, locale);
Expand All @@ -37,7 +39,7 @@ async function get(id, locale = { locale: FRENCH_FRANCE }) {
}
}

async function findAllActiveMissions(locale = { locale: FRENCH_FRANCE }) {
async function findAllActiveMissions(locale = FRENCH_SPOKEN) {
const allMissions = await missionDatasource.list();
const allActiveMissions = allMissions.filter((mission) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Integration | Repository | mission-repository', function () {
validatedObjectives_i18n: { fr: 'validatedObjectivesi18n' },
introductionMediaUrl: 'http://monimage.pix.fr',
introductionMediaType: 'image',
introductionMediaAlt: "Alt à l'image",
introductionMediaAlt_i18n: { fr: "Alt à l'image" },
documentationUrl: 'http://madoc.pix.fr',
content: {
steps: [
Expand All @@ -56,9 +56,10 @@ describe('Integration | Repository | mission-repository', function () {
const mission = await missionRepository.get('1');

// then
expect({ ...mission }).to.deep.equal(expectedMission);
expect(mission).to.deep.equal(expectedMission);
});
});

context('when there is no mission for the given id', function () {
it('should return the not found error', async function () {
// given
Expand Down Expand Up @@ -114,7 +115,7 @@ describe('Integration | Repository | mission-repository', function () {
validatedObjectives_i18n: { fr: 'validatedObjectivesi18n' },
introductionMediaUrl: 'http://monimage.pix.fr',
introductionMediaType: 'image',
introductionMediaAlt: "Alt à l'image",
introductionMediaAlt_i18n: { fr: "Alt à l'image" },
documentationUrl: 'http://madoc.pix.fr',
content: {
steps: [
Expand All @@ -135,7 +136,7 @@ describe('Integration | Repository | mission-repository', function () {
validatedObjectives_i18n: { fr: 'validatedObjectivesi18n' },
introductionMediaUrl: 'http://monimage.pix.fr',
introductionMediaType: 'image',
introductionMediaAlt: "Alt à l'image",
introductionMediaAlt_i18n: { fr: "Alt à l'image" },
documentationUrl: 'http://madoc.pix.fr',
content: {
steps: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="mission-introduction__media">
<Challenge::ChallengeMedia
@src={{@model.mission.introductionMediaUrl}}
@alt={{@challenge.introductionMediaAlt}}
@alt={{@model.mission.introductionMediaAlt}}
@type={{@model.mission.introductionMediaType}}
/>
</div>
Expand Down

0 comments on commit 68e40ce

Please sign in to comment.