Skip to content

Commit

Permalink
Make tests work for challenges preview
Browse files Browse the repository at this point in the history
Co-authored-by: Laura Bergoens <[email protected]>
  • Loading branch information
Eithliu and laura-bergoens committed Oct 10, 2024
1 parent ac464d1 commit 1f74aba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
17 changes: 16 additions & 1 deletion api/tests/acceptance/application/challenges/challenges_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,19 +845,29 @@ describe('Acceptance | Controller | challenges-controller', () => {
challengeId,
locale: 'fr',
geography: 'BR',
requireGafamWebsiteAccess: true,
isIncompatibleIpadCertif: true,
deafAndHardOfHearing: LocalizedChallenge.DEAF_AND_HARD_OF_HEARING_VALUES.OK,
isAwarenessChallenge: false,
toRephrase: true,
});
databaseBuilder.factory.buildLocalizedChallenge({
id: localizedChallengeId,
challengeId,
locale,
status: LocalizedChallenge.STATUSES.PAUSE,
geography: null,
requireGafamWebsiteAccess: false,
isIncompatibleIpadCertif: true,
deafAndHardOfHearing: LocalizedChallenge.DEAF_AND_HARD_OF_HEARING_VALUES.KO,
isAwarenessChallenge: false,
toRephrase: false,
});

await databaseBuilder.commit();
});

it.fails('should redirect to a staging Pix App preview URL', async () => {
it('should redirect to a staging Pix App preview URL', async () => {
// given
const apiToken = 'secret';
const apiTokenScope = nock('https://api.test.pix.fr')
Expand Down Expand Up @@ -888,6 +898,11 @@ describe('Acceptance | Controller | challenges-controller', () => {
t2Status: false,
t3Status: false,
status: Challenge.STATUSES.PROPOSE,
requireGafamWebsiteAccess: true,
isIncompatibleIpadCertif: true,
deafAndHardOfHearing: LocalizedChallenge.DEAF_AND_HARD_OF_HEARING_VALUES.OK,
isAwarenessChallenge: false,
toRephrase: true,
})
.matchHeader('Authorization', `Bearer ${apiToken}`)
.reply(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ describe('Integration | Repository | localized-challenge-repository', function()
challengeId: challengeId1,
locale: 'fr-fr',
embedUrl,
requireGafamWebsiteAccess: true,
isIncompatibleIpadCertif: true,
deafAndHardOfHearing: LocalizedChallenge.DEAF_AND_HARD_OF_HEARING_VALUES.OK,
isAwarenessChallenge: true,
toRephrase: true,
});
databaseBuilder.factory.buildLocalizedChallenge({
id: `${challengeId1}En`,
Expand Down Expand Up @@ -524,6 +529,11 @@ describe('Integration | Repository | localized-challenge-repository', function()
locale: 'fr-fr',
embedUrl,
urlsToConsult: null,
requireGafamWebsiteAccess: true,
isIncompatibleIpadCertif: true,
deafAndHardOfHearing: LocalizedChallenge.DEAF_AND_HARD_OF_HEARING_VALUES.OK,
isAwarenessChallenge: true,
toRephrase: true,
}),
domainBuilder.buildLocalizedChallenge({
id: `${challengeId1}Nl`,
Expand Down
6 changes: 2 additions & 4 deletions api/tests/unit/domain/usecases/preview-challenge_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ describe('Unit | Domain | Usecases | preview-challenge', function() {
locale,
geography: 'TJ',
});
const localizedChallengeRepository = {
getByChallengeIdAndLocale: vi.fn().mockResolvedValueOnce(localizedChallenge),
};

const challenge = domainBuilder.buildChallenge({
localizedChallenges: [localizedChallenge],
geography: 'Tadjikistan',
Expand All @@ -30,7 +28,7 @@ describe('Unit | Domain | Usecases | preview-challenge', function() {
const refreshCache = vi.fn().mockResolvedValueOnce();

// when
const url = await previewChallenge({ challengeId, locale }, { localizedChallengeRepository, challengeRepository, refreshCache });
const url = await previewChallenge({ challengeId, locale }, { challengeRepository, refreshCache });

// then
expect(url).to.equal(`https://preview.url.org/challenges/${localizedChallengeId}/preview?lang=fr`);
Expand Down

0 comments on commit 1f74aba

Please sign in to comment.