From 84d455046200dd2215ca32ffbe5ab5b9b775453c Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 15:15:06 +0200 Subject: [PATCH 1/9] refactor(admin): restore sinon stubs between each test --- admin/tests/test-helper.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/admin/tests/test-helper.js b/admin/tests/test-helper.js index 3b182f6ab20..da9b5c96431 100644 --- a/admin/tests/test-helper.js +++ b/admin/tests/test-helper.js @@ -3,6 +3,7 @@ import { clearAllCookies } from 'ember-cookies/test-support'; import start from 'ember-exam/test-support/start'; import * as QUnit from 'qunit'; import { setup } from 'qunit-dom'; +import sinon from 'sinon'; import Application from '../app'; import config from '../config/environment'; @@ -17,6 +18,11 @@ QUnit.hooks.beforeEach(function () { clearAllCookies(); }); +// Restore all sinon stubs after each test to avoid side-effects +QUnit.hooks.afterEach(function () { + sinon.restore(); +}); + setup(QUnit.assert); setApplication(Application.create(config.APP)); start(); From 7a348504fe27a9376c9926d4703374f5a04047cd Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 15:15:33 +0200 Subject: [PATCH 2/9] refactor(admin): remove useless sinon.restore() in tests --- .../administration/access/anonymize-gar-import-test.gjs | 4 ---- .../administration/common/create-attestations-test.gjs | 4 ---- .../administration/common/user-quest-checker-test.gjs | 4 ---- .../deployment/certification-centers-batch-archive-test.gjs | 4 ---- .../deployment/organizations-batch-archive-test.gjs | 4 ---- .../deployment/update-organizations-in-batch-test.gjs | 4 ---- .../certification-centers/membership-item-test.gjs | 4 ---- .../certification/informations/global-actions-test.gjs | 6 +----- .../components/organizations/member-item-test.gjs | 4 ---- .../users/certification-centers/membership-item-test.gjs | 3 --- admin/tests/unit/authenticators/oidc-test.js | 4 ---- .../authenticated/sessions/session/informations-test.js | 4 ---- admin/tests/unit/metrics-adapters/plausible-adapter-test.js | 1 + .../unit/routes/authenticated/target-profiles/list-test.js | 4 ---- admin/tests/unit/routes/authenticated/users/get-test.js | 6 +----- admin/tests/unit/routes/authentication/login-oidc-test.js | 5 ----- admin/tests/unit/routes/login-test.js | 6 +----- admin/tests/unit/services/current-domain-test.js | 4 ---- admin/tests/unit/services/pix-metrics-test.js | 4 ---- admin/tests/unit/services/request-manager-test.js | 4 ---- admin/tests/unit/utils/location-test.js | 6 +----- 21 files changed, 5 insertions(+), 84 deletions(-) diff --git a/admin/tests/integration/components/administration/access/anonymize-gar-import-test.gjs b/admin/tests/integration/components/administration/access/anonymize-gar-import-test.gjs index a6ef5ce28d3..0e52f414aff 100644 --- a/admin/tests/integration/components/administration/access/anonymize-gar-import-test.gjs +++ b/admin/tests/integration/components/administration/access/anonymize-gar-import-test.gjs @@ -24,10 +24,6 @@ module('Integration | Component | administration/anonymize-gar-import', functio sinon.stub(window, 'fetch'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when import fully succeeds', function () { test('it displays a success notification', async function (assert) { // given diff --git a/admin/tests/integration/components/administration/common/create-attestations-test.gjs b/admin/tests/integration/components/administration/common/create-attestations-test.gjs index dc4b30b6917..a6b56803582 100644 --- a/admin/tests/integration/components/administration/common/create-attestations-test.gjs +++ b/admin/tests/integration/components/administration/common/create-attestations-test.gjs @@ -20,10 +20,6 @@ module('Integration | Component | administration/create-attestations', function sinon.stub(requestManagerService, 'request'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when all fields are filled', function () { test('it should enable submit button', async function (assert) { const screen = await render(); diff --git a/admin/tests/integration/components/administration/common/user-quest-checker-test.gjs b/admin/tests/integration/components/administration/common/user-quest-checker-test.gjs index 57f625720dd..8fc720114d8 100644 --- a/admin/tests/integration/components/administration/common/user-quest-checker-test.gjs +++ b/admin/tests/integration/components/administration/common/user-quest-checker-test.gjs @@ -12,10 +12,6 @@ import setupIntlRenderingTest from '../../../../helpers/setup-intl-rendering'; module('Integration | Component | administration/user-quest-checker', function (hooks) { setupIntlRenderingTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - test('it should display a form', async function (assert) { // when const screen = await render(); diff --git a/admin/tests/integration/components/administration/deployment/certification-centers-batch-archive-test.gjs b/admin/tests/integration/components/administration/deployment/certification-centers-batch-archive-test.gjs index 63122d36b12..1769ef2f53e 100644 --- a/admin/tests/integration/components/administration/deployment/certification-centers-batch-archive-test.gjs +++ b/admin/tests/integration/components/administration/deployment/certification-centers-batch-archive-test.gjs @@ -15,10 +15,6 @@ module('Integration | Component | administration/certification-centers-batch-arc sinon.stub(window, 'fetch'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when batch archive succeeds', function () { test('it displays a success notification', async function (assert) { // given diff --git a/admin/tests/integration/components/administration/deployment/organizations-batch-archive-test.gjs b/admin/tests/integration/components/administration/deployment/organizations-batch-archive-test.gjs index 71e80b36b36..e1754bf159e 100644 --- a/admin/tests/integration/components/administration/deployment/organizations-batch-archive-test.gjs +++ b/admin/tests/integration/components/administration/deployment/organizations-batch-archive-test.gjs @@ -17,10 +17,6 @@ module('Integration | Component | administration/organizations-batch-archive', f sinon.stub(requestManagerService, 'request'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when batch archive succeeds', function () { test('it displays the correct number of archived organizations in success notification', async function (assert) { // given diff --git a/admin/tests/integration/components/administration/deployment/update-organizations-in-batch-test.gjs b/admin/tests/integration/components/administration/deployment/update-organizations-in-batch-test.gjs index 428ce93c009..40fe5ea489c 100644 --- a/admin/tests/integration/components/administration/deployment/update-organizations-in-batch-test.gjs +++ b/admin/tests/integration/components/administration/deployment/update-organizations-in-batch-test.gjs @@ -24,10 +24,6 @@ module('Integration | Component | administration/update-organizations-in-batch' sinon.stub(window, 'fetch'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when import succeeds', function () { test('it displays a success notification', async function (assert) { // given diff --git a/admin/tests/integration/components/certification-centers/membership-item-test.gjs b/admin/tests/integration/components/certification-centers/membership-item-test.gjs index a9c0550aa45..7c99cf12a1a 100644 --- a/admin/tests/integration/components/certification-centers/membership-item-test.gjs +++ b/admin/tests/integration/components/certification-centers/membership-item-test.gjs @@ -18,10 +18,6 @@ module('Integration | Component | certification-centers/membership-item', funct intl = this.owner.lookup('service:intl'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('displays a certification center membership table row item', function () { test('with last access date if exists', async function (assert) { // given diff --git a/admin/tests/integration/components/certifications/certification/informations/global-actions-test.gjs b/admin/tests/integration/components/certifications/certification/informations/global-actions-test.gjs index b6cdde1751b..bdc68b01dda 100644 --- a/admin/tests/integration/components/certifications/certification/informations/global-actions-test.gjs +++ b/admin/tests/integration/components/certifications/certification/informations/global-actions-test.gjs @@ -923,11 +923,7 @@ module('Integration | Component | Certifications | Certification | Information | }); }); - module('when button is displayed', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('when button is displayed', function () { test('should trigger rescoring and show success notification', async function (assert) { assert.expect(1); diff --git a/admin/tests/integration/components/organizations/member-item-test.gjs b/admin/tests/integration/components/organizations/member-item-test.gjs index 29efad4efb9..126c8f68b13 100644 --- a/admin/tests/integration/components/organizations/member-item-test.gjs +++ b/admin/tests/integration/components/organizations/member-item-test.gjs @@ -20,10 +20,6 @@ module('Integration | Component | MemberItem', function (hooks) { currentUser.adminMember = { isSuperAdmin: true }; }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('displays an organization member details', async function (assert) { // given const member = { diff --git a/admin/tests/integration/components/users/certification-centers/membership-item-test.gjs b/admin/tests/integration/components/users/certification-centers/membership-item-test.gjs index 3d8837490b2..e84e94230fe 100644 --- a/admin/tests/integration/components/users/certification-centers/membership-item-test.gjs +++ b/admin/tests/integration/components/users/certification-centers/membership-item-test.gjs @@ -16,9 +16,6 @@ module('Integration | Component | users | certification-centers | membership-ite store = this.owner.lookup('service:store'); }); - hooks.afterEach(function () { - sinon.restore(); - }); module('displays a certification center membership table row item', function () { test('with last access date if there is one', async function (assert) { // given diff --git a/admin/tests/unit/authenticators/oidc-test.js b/admin/tests/unit/authenticators/oidc-test.js index b1043630592..0cb616655d7 100644 --- a/admin/tests/unit/authenticators/oidc-test.js +++ b/admin/tests/unit/authenticators/oidc-test.js @@ -60,10 +60,6 @@ module('Unit | Authenticator | oidc', function (hooks) { oidcIdentityProvidersService.set('store', storeStub); }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('fetches token with authentication key', async function (assert) { // given const authenticator = this.owner.lookup('authenticator:oidc'); diff --git a/admin/tests/unit/controllers/authenticated/sessions/session/informations-test.js b/admin/tests/unit/controllers/authenticated/sessions/session/informations-test.js index 929821ffbd2..78c87be2f27 100644 --- a/admin/tests/unit/controllers/authenticated/sessions/session/informations-test.js +++ b/admin/tests/unit/controllers/authenticated/sessions/session/informations-test.js @@ -190,10 +190,6 @@ module('Unit | Controller | authenticated/sessions/session/informations', functi const adapter = store.adapterFor('session'); getDownloadLinkStub = sinon.stub(adapter, 'getDownloadLink'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('it should retrieve link from api and copy it', async function (assert) { // given const session = sinon.stub(); diff --git a/admin/tests/unit/metrics-adapters/plausible-adapter-test.js b/admin/tests/unit/metrics-adapters/plausible-adapter-test.js index c30951db3b2..d56f170f955 100644 --- a/admin/tests/unit/metrics-adapters/plausible-adapter-test.js +++ b/admin/tests/unit/metrics-adapters/plausible-adapter-test.js @@ -16,6 +16,7 @@ module('Unit | MetricsAdapter | plausible-adapter', function (hooks) { }); hooks.afterEach(function () { + sinon.restore(); // must restore before uninstall, which deletes window.plausible this.adapter.uninstall(); }); diff --git a/admin/tests/unit/routes/authenticated/target-profiles/list-test.js b/admin/tests/unit/routes/authenticated/target-profiles/list-test.js index a067be92967..e2c607cd664 100644 --- a/admin/tests/unit/routes/authenticated/target-profiles/list-test.js +++ b/admin/tests/unit/routes/authenticated/target-profiles/list-test.js @@ -26,10 +26,6 @@ module('Unit | Route | authenticated/target-profiles/list', function (hooks) { }; }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when queryParams filters are falsy', function () { test('it should call store.query with no filters on name and id', async function (assert) { // when diff --git a/admin/tests/unit/routes/authenticated/users/get-test.js b/admin/tests/unit/routes/authenticated/users/get-test.js index 5a200c3e2fd..bd42235ad4b 100644 --- a/admin/tests/unit/routes/authenticated/users/get-test.js +++ b/admin/tests/unit/routes/authenticated/users/get-test.js @@ -5,11 +5,7 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/users/get', function (hooks) { setupTest(hooks); - module('beforeModel', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('beforeModel', function () { test('loads all available identity providers', async function (assert) { // given const route = this.owner.lookup('route:authenticated/users/get'); diff --git a/admin/tests/unit/routes/authentication/login-oidc-test.js b/admin/tests/unit/routes/authentication/login-oidc-test.js index 8961df6f13c..c931db82f0e 100644 --- a/admin/tests/unit/routes/authentication/login-oidc-test.js +++ b/admin/tests/unit/routes/authentication/login-oidc-test.js @@ -30,10 +30,6 @@ module('Unit | Route | login-oidc', function (hooks) { oidcIdentityProvidersService.set('store', storeStub); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when identity provider is not supported', function () { test('redirects the user to main login page', async function (assert) { // given @@ -65,7 +61,6 @@ module('Unit | Route | login-oidc', function (hooks) { ); sinon.assert.calledWith(replaceStub, 'https://oidc.example.net/connexion'); assert.ok(true); - sinon.restore(); }); }); }); diff --git a/admin/tests/unit/routes/login-test.js b/admin/tests/unit/routes/login-test.js index 8afa7d158e1..0a94a6d0600 100644 --- a/admin/tests/unit/routes/login-test.js +++ b/admin/tests/unit/routes/login-test.js @@ -10,11 +10,7 @@ module('Unit | Route | login', function (hooks) { assert.ok(route); }); - module('model', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('model', function () { test('loads ready identity providers', async function (assert) { // given const route = this.owner.lookup('route:login'); diff --git a/admin/tests/unit/services/current-domain-test.js b/admin/tests/unit/services/current-domain-test.js index 6d97d3eaba8..5fa047eeb96 100644 --- a/admin/tests/unit/services/current-domain-test.js +++ b/admin/tests/unit/services/current-domain-test.js @@ -5,10 +5,6 @@ import sinon from 'sinon'; module('Unit | Service | currentDomain', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#getExtension', function () { module('when location is FR TLD', function () { test(`returns fr`, function (assert) { diff --git a/admin/tests/unit/services/pix-metrics-test.js b/admin/tests/unit/services/pix-metrics-test.js index 30083d5def0..737500aa2b6 100644 --- a/admin/tests/unit/services/pix-metrics-test.js +++ b/admin/tests/unit/services/pix-metrics-test.js @@ -17,10 +17,6 @@ module('Unit | Service | PixMetrics', function (hooks) { sinon.stub(metricsService, 'trackEvent'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('trackPage', function () { test('it should redact id from url', function (assert) { // given diff --git a/admin/tests/unit/services/request-manager-test.js b/admin/tests/unit/services/request-manager-test.js index c65e371201a..f03e4f74f44 100644 --- a/admin/tests/unit/services/request-manager-test.js +++ b/admin/tests/unit/services/request-manager-test.js @@ -21,10 +21,6 @@ module('Unit | Service | request-manager', function (hooks) { sinon.stub(localeService, 'acceptLanguageHeader').value('fr'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('request()', function () { test('it requests successfully with default headers', async function (assert) { // given diff --git a/admin/tests/unit/utils/location-test.js b/admin/tests/unit/utils/location-test.js index 22dd440bf3d..e14db41e488 100644 --- a/admin/tests/unit/utils/location-test.js +++ b/admin/tests/unit/utils/location-test.js @@ -2,11 +2,7 @@ import Location from 'pix-admin/utils/location'; import { module, test } from 'qunit'; import sinon from 'sinon'; -module('Unit | Utility | location', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - +module('Unit | Utility | location', function () { module('#getHref', function () { test('should return the full URL', function (assert) { // given From f54f3d3c457fc83db85982c449d982fb54b49f74 Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 15:21:31 +0200 Subject: [PATCH 3/9] refactor(orga): restore sinon stubs between each test --- orga/tests/test-helper.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/orga/tests/test-helper.js b/orga/tests/test-helper.js index 5987b26853c..076531d7f3b 100644 --- a/orga/tests/test-helper.js +++ b/orga/tests/test-helper.js @@ -6,6 +6,7 @@ import Application from 'pix-orga/app'; import config from 'pix-orga/config/environment'; import * as QUnit from 'qunit'; import { setup } from 'qunit-dom'; +import sinon from 'sinon'; export async function start(options) { // Set default browser locale @@ -18,6 +19,11 @@ export async function start(options) { clearAllCookies(); }); + // Restore all sinon stubs after each test to avoid side-effects + QUnit.hooks.afterEach(function () { + sinon.restore(); + }); + setApplication(Application.create(config.APP)); setup(QUnit.assert); From ee1704e23dd959d6d796b1b59cfb949b2836a5e3 Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 15:25:20 +0200 Subject: [PATCH 4/9] refactor(orga): remove useless sinon.restore() in tests --- orga/tests/acceptance/certifications-test.js | 10 +--------- .../components/analysis/analysis-header-test.gjs | 4 ---- .../components/banner/certification-test.gjs | 4 ---- .../charts/campaign-badge-acquisition-test.gjs | 4 ---- .../campaign/charts/result-distribution-test.gjs | 4 ---- .../sco-organization-participant/list-test.gjs | 4 ---- orga/tests/integration/components/tube/list-test.gjs | 4 ---- orga/tests/unit/adapters/user-orga-setting-test.js | 4 ---- orga/tests/unit/authenticators/oidc-test.js | 6 ------ orga/tests/unit/routes/application-test.js | 3 --- .../campaigns/campaign/activity-test.js | 4 ---- .../campaigns/campaign/analysis-test.js | 4 ---- .../campaigns/campaign/assessment-results-test.js | 6 +----- .../campaigns/campaign/profile-results-test.js | 6 +----- .../campaigns/campaign/settings-test.js | 12 ++---------- .../authenticated/campaigns/combined-courses-test.js | 4 ---- .../unit/routes/authenticated/campaigns/new-test.js | 4 ---- .../campaigns/participant-assessment-test.js | 6 +----- .../participant-assessment/analysis-test.js | 4 ---- .../campaigns/participant-assessment/results-test.js | 4 ---- .../campaigns/participant-profile-test.js | 6 +----- .../unit/routes/authenticated/catalogue-test.js | 4 ---- .../routes/authenticated/catalogue/index-test.js | 4 ---- .../unit/routes/authenticated/catalogue/list-test.js | 4 ---- .../routes/authenticated/combined-course-test.js | 4 ---- .../combined-course/participation-detail-test.js | 4 ---- .../combined-course/participations-test.js | 4 ---- .../organization-participants/list-test.js | 3 --- .../authenticated/preselect-target-profile-test.js | 4 ---- .../sco-organization-participants/list-test.js | 4 ---- .../sup-organization-participants/list-test.js | 4 ---- .../unit/routes/authentication/oidc/flow-test.js | 4 ---- orga/tests/unit/services/current-domain-test.js | 4 ---- orga/tests/unit/services/locale-loader-test.js | 3 --- orga/tests/unit/services/pix-metrics-test.js | 4 ---- orga/tests/unit/services/request-manager-test.js | 4 ---- orga/tests/unit/utils/location-test.js | 6 +----- 37 files changed, 8 insertions(+), 163 deletions(-) diff --git a/orga/tests/acceptance/certifications-test.js b/orga/tests/acceptance/certifications-test.js index 25e11c4e2c7..31b9516792b 100644 --- a/orga/tests/acceptance/certifications-test.js +++ b/orga/tests/acceptance/certifications-test.js @@ -17,15 +17,7 @@ module('Acceptance | Certifications page', function (hooks) { await authenticateSession(user.id); }); - hooks.afterEach(function () { - sinon.restore(); - }); - - module('When user arrives on certifications page', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('When user arrives on certifications page', function () { test('should display certification banner when it is time to', async function (assert) { sinon.useFakeTimers({ now: new Date('2001-04-01T10:42:00Z'), shouldAdvanceTime: true }); diff --git a/orga/tests/integration/components/analysis/analysis-header-test.gjs b/orga/tests/integration/components/analysis/analysis-header-test.gjs index 708f82d146f..6a2991a11f9 100644 --- a/orga/tests/integration/components/analysis/analysis-header-test.gjs +++ b/orga/tests/integration/components/analysis/analysis-header-test.gjs @@ -10,10 +10,6 @@ import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; module('Integration | Component | analysis-header', function (hooks) { setupIntlRenderingTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('for campaign or global analysis', function () { test('it should navigate the competences view', async function (assert) { // given diff --git a/orga/tests/integration/components/banner/certification-test.gjs b/orga/tests/integration/components/banner/certification-test.gjs index d9a14b214ad..fd738608f77 100644 --- a/orga/tests/integration/components/banner/certification-test.gjs +++ b/orga/tests/integration/components/banner/certification-test.gjs @@ -14,10 +14,6 @@ module('Integration | Component | Banner::Certification', function (hooks) { sinon.useFakeTimers({ now: new Date('2001-04-01T10:42:00Z') }); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when prescriber’s organization is of type SCO that manages students', function () { class CurrentUserStub extends Service { organization = { isSco: true }; diff --git a/orga/tests/integration/components/campaign/charts/campaign-badge-acquisition-test.gjs b/orga/tests/integration/components/campaign/charts/campaign-badge-acquisition-test.gjs index d9133bf3020..c10bcae1134 100644 --- a/orga/tests/integration/components/campaign/charts/campaign-badge-acquisition-test.gjs +++ b/orga/tests/integration/components/campaign/charts/campaign-badge-acquisition-test.gjs @@ -14,10 +14,6 @@ module('Integration | Component | Campaign::Charts::BadgeAcquisitionCards', func adapter = store.adapterFor('campaign-stats'); }); - hooks.afterEach(async function () { - sinon.restore(); - }); - module('When the campaign has badges acquired', function (hooks) { hooks.beforeEach(async function () { sinon.stub(adapter, 'getBadgeAcquisitions').resolves({ diff --git a/orga/tests/integration/components/campaign/charts/result-distribution-test.gjs b/orga/tests/integration/components/campaign/charts/result-distribution-test.gjs index 1bf6cbfa1d7..c762ac44e68 100644 --- a/orga/tests/integration/components/campaign/charts/result-distribution-test.gjs +++ b/orga/tests/integration/components/campaign/charts/result-distribution-test.gjs @@ -16,10 +16,6 @@ module('Integration | Component | Campaign::Charts::ResultDistribution', functio adapter = store.adapterFor('campaign-stats'); }); - hooks.afterEach(async function () { - sinon.restore(); - }); - module('when the campaign has no stages', function (hooks) { hooks.beforeEach(async function () { dataFetcher = sinon.stub(adapter, 'getParticipationsByMasteryRate'); diff --git a/orga/tests/integration/components/sco-organization-participant/list-test.gjs b/orga/tests/integration/components/sco-organization-participant/list-test.gjs index eeb8f10b884..ba0e0d58d58 100644 --- a/orga/tests/integration/components/sco-organization-participant/list-test.gjs +++ b/orga/tests/integration/components/sco-organization-participant/list-test.gjs @@ -1136,10 +1136,6 @@ module('Integration | Component | ScoOrganizationParticipant::List', function (h this.certificability = []; }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('displays action bar', async function (assert) { // given const students = [ diff --git a/orga/tests/integration/components/tube/list-test.gjs b/orga/tests/integration/components/tube/list-test.gjs index 0eaa1ee59d8..6050971678c 100644 --- a/orga/tests/integration/components/tube/list-test.gjs +++ b/orga/tests/integration/components/tube/list-test.gjs @@ -126,10 +126,6 @@ module('Integration | Component | tube:list', function (hooks) { ]; }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('it should display frameworks title', async function (assert) { // given const frameworks = allFrameworks.slice(); diff --git a/orga/tests/unit/adapters/user-orga-setting-test.js b/orga/tests/unit/adapters/user-orga-setting-test.js index 31bda83d235..4d9ce65032a 100644 --- a/orga/tests/unit/adapters/user-orga-setting-test.js +++ b/orga/tests/unit/adapters/user-orga-setting-test.js @@ -14,10 +14,6 @@ module('Unit | Adapters | user-orga-setting', function (hooks) { adapter.set('ajax', ajaxStub); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#urlForUpdateRecord', function () { test('it should build update url from user id', async function (assert) { // when diff --git a/orga/tests/unit/authenticators/oidc-test.js b/orga/tests/unit/authenticators/oidc-test.js index 36da2843c43..636b4e70bb6 100644 --- a/orga/tests/unit/authenticators/oidc-test.js +++ b/orga/tests/unit/authenticators/oidc-test.js @@ -57,10 +57,6 @@ module('Unit | Authenticator | oidc', function (hooks) { oidcIdentityProvidersService.set('store', storeStub); }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('retrieves an access token with authentication key', async function (assert) { // given const authenticator = this.owner.lookup('authenticator:oidc'); @@ -194,7 +190,6 @@ module('Unit | Authenticator | oidc', function (hooks) { // then assert.strictEqual(authenticator.session.routeAfterInvalidation, redirectLogoutUrl); - sinon.restore(); }); }); @@ -227,7 +222,6 @@ module('Unit | Authenticator | oidc', function (hooks) { '/connexion?error=USER_HAS_NO_ORGANIZATION_MEMBERSHIP', ); sinon.assert.notCalled(window.fetch); - sinon.restore(); }); }); }); diff --git a/orga/tests/unit/routes/application-test.js b/orga/tests/unit/routes/application-test.js index cfdb1e8ee34..1cc73d4dc7a 100644 --- a/orga/tests/unit/routes/application-test.js +++ b/orga/tests/unit/routes/application-test.js @@ -14,9 +14,6 @@ module('Unit | Route | application', function (hooks) { sinon.stub(this.route.locale, 'setBestLocale').resolves(); sinon.stub(this.route.localeLoader, 'load').resolves(); }); - hooks.afterEach(function () { - sinon.restore(); - }); module('model', function () { test('does not fetch sco organization banner', async function (assert) { // given diff --git a/orga/tests/unit/routes/authenticated/campaigns/campaign/activity-test.js b/orga/tests/unit/routes/authenticated/campaigns/campaign/activity-test.js index 01ba339ca80..7cb5d54ca03 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/campaign/activity-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/campaign/activity-test.js @@ -11,10 +11,6 @@ module('Unit | Route | authenticated/campaigns/campaign/activity', function (hoo store = this.owner.lookup('service:store'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('model', function () { test('should fetch data', async function (assert) { //given diff --git a/orga/tests/unit/routes/authenticated/campaigns/campaign/analysis-test.js b/orga/tests/unit/routes/authenticated/campaigns/campaign/analysis-test.js index 260277f9538..843bdeacba3 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/campaign/analysis-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/campaign/analysis-test.js @@ -11,10 +11,6 @@ module('Unit | Route | authenticated/campaigns/campaign/analysis', function (hoo currentUser = this.owner.lookup('service:current-user'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('beforeModel', function () { module('When places limit is reached', function () { test('should redirect on main campaign page', function (assert) { diff --git a/orga/tests/unit/routes/authenticated/campaigns/campaign/assessment-results-test.js b/orga/tests/unit/routes/authenticated/campaigns/campaign/assessment-results-test.js index add1329885d..9a3f21663e1 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/campaign/assessment-results-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/campaign/assessment-results-test.js @@ -83,11 +83,7 @@ module('Unit | Route | authenticated/campaigns/campaign/assessment-results', fun }); }); - module('beforeModel', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('beforeModel', function () { module('When places limit is reached', function () { test('should redirect to main campaign page', function (assert) { //given diff --git a/orga/tests/unit/routes/authenticated/campaigns/campaign/profile-results-test.js b/orga/tests/unit/routes/authenticated/campaigns/campaign/profile-results-test.js index 39a15a5084f..6d82245e4e7 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/campaign/profile-results-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/campaign/profile-results-test.js @@ -99,11 +99,7 @@ module('Unit | Route | authenticated/campaigns/campaign/profile-results', functi }); }); - module('beforeModel', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('beforeModel', function () { module('When places limit is reached', function () { test('should redirect to main campaign page', function (assert) { //given diff --git a/orga/tests/unit/routes/authenticated/campaigns/campaign/settings-test.js b/orga/tests/unit/routes/authenticated/campaigns/campaign/settings-test.js index 50bd2628020..9c23038b6c4 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/campaign/settings-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/campaign/settings-test.js @@ -11,11 +11,7 @@ module('Unit | Route | authenticated/campaigns/campaign/settings', function (hoo }); module('beforeModel', function () { - module('When campaign is from combined course', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('When campaign is from combined course', function () { test('should redirect on main campaign page', function (assert) { //given const campaignId = Symbol('CampaignId'); @@ -41,11 +37,7 @@ module('Unit | Route | authenticated/campaigns/campaign/settings', function (hoo }); }); - module('When campaign is not from combined course', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('When campaign is not from combined course', function () { test('should not redirect on main campaign page', function (assert) { //given const campaignId = Symbol('CampaignId'); diff --git a/orga/tests/unit/routes/authenticated/campaigns/combined-courses-test.js b/orga/tests/unit/routes/authenticated/campaigns/combined-courses-test.js index 67e9e70f112..f3649d1a3ce 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/combined-courses-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/combined-courses-test.js @@ -15,10 +15,6 @@ module('Unit | Route | authenticated/campaigns/combined-courses', function (hook currentUser = this.owner.lookup('service:current-user'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('model', function () { test('should query combined-courses with organizationId and pagination params', async function (assert) { // given diff --git a/orga/tests/unit/routes/authenticated/campaigns/new-test.js b/orga/tests/unit/routes/authenticated/campaigns/new-test.js index 74f02a37be9..62940674859 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/new-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/new-test.js @@ -747,10 +747,6 @@ module('Unit | Route | authenticated/campaigns/new', function (hooks) { route = this.owner.lookup('route:authenticated/campaigns/new'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('When places limit is reached', function () { test('should redirect to main campaign page', function (assert) { //given diff --git a/orga/tests/unit/routes/authenticated/campaigns/participant-assessment-test.js b/orga/tests/unit/routes/authenticated/campaigns/participant-assessment-test.js index 7d0ce9c6a92..7890f4bd354 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/participant-assessment-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/participant-assessment-test.js @@ -5,11 +5,7 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/campaigns/{campaignId}/evaluation/{campaignParticipationId}', function (hooks) { setupTest(hooks); - module('Before model', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('Before model', function () { module('When places limit is reached', function () { test('should redirect on main campaign page', function (assert) { //given diff --git a/orga/tests/unit/routes/authenticated/campaigns/participant-assessment/analysis-test.js b/orga/tests/unit/routes/authenticated/campaigns/participant-assessment/analysis-test.js index eb8365f247d..e78f625c070 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/participant-assessment/analysis-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/participant-assessment/analysis-test.js @@ -7,10 +7,6 @@ module( function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('before model', function () { module('When places limit is reached', function () { test('should redirect on main campaign page', function (assert) { diff --git a/orga/tests/unit/routes/authenticated/campaigns/participant-assessment/results-test.js b/orga/tests/unit/routes/authenticated/campaigns/participant-assessment/results-test.js index 878322072e9..b54f9732b31 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/participant-assessment/results-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/participant-assessment/results-test.js @@ -7,10 +7,6 @@ module( function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('Before model', function () { module('When places limit is reached', function () { test('should redirect on main campaign page', function (assert) { diff --git a/orga/tests/unit/routes/authenticated/campaigns/participant-profile-test.js b/orga/tests/unit/routes/authenticated/campaigns/participant-profile-test.js index e9af6e9cfd1..0857dc5cbc1 100644 --- a/orga/tests/unit/routes/authenticated/campaigns/participant-profile-test.js +++ b/orga/tests/unit/routes/authenticated/campaigns/participant-profile-test.js @@ -5,11 +5,7 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/campaigns/{campaignId}/profils/{campaignParticipationId}', function (hooks) { setupTest(hooks); - module('Before model', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - + module('Before model', function () { module('When places limit is reached', function () { test('should redirect on main campaign page', function (assert) { //given diff --git a/orga/tests/unit/routes/authenticated/catalogue-test.js b/orga/tests/unit/routes/authenticated/catalogue-test.js index 4286a7052a7..7a832edc5c7 100644 --- a/orga/tests/unit/routes/authenticated/catalogue-test.js +++ b/orga/tests/unit/routes/authenticated/catalogue-test.js @@ -5,10 +5,6 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/catalogue', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('beforeModel', function () { test("it should redirect to index page if user can't access campaign page", async function (assert) { // given diff --git a/orga/tests/unit/routes/authenticated/catalogue/index-test.js b/orga/tests/unit/routes/authenticated/catalogue/index-test.js index ee0eb5db12e..f139047bf81 100644 --- a/orga/tests/unit/routes/authenticated/catalogue/index-test.js +++ b/orga/tests/unit/routes/authenticated/catalogue/index-test.js @@ -5,10 +5,6 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/catalogue/index', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('beforeModel', function () { test('it should redirect to catalogue all list page', async function (assert) { // given diff --git a/orga/tests/unit/routes/authenticated/catalogue/list-test.js b/orga/tests/unit/routes/authenticated/catalogue/list-test.js index 5862290c289..2143c1e813b 100644 --- a/orga/tests/unit/routes/authenticated/catalogue/list-test.js +++ b/orga/tests/unit/routes/authenticated/catalogue/list-test.js @@ -5,10 +5,6 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/catalogue/list', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('beforeModel', function () { ['all', 'targetProfile', 'blueprint'].forEach((type) => { test(`it should not redirect if param type=${type}`, async function (assert) { diff --git a/orga/tests/unit/routes/authenticated/combined-course-test.js b/orga/tests/unit/routes/authenticated/combined-course-test.js index c1ccc5a623c..2067124738f 100644 --- a/orga/tests/unit/routes/authenticated/combined-course-test.js +++ b/orga/tests/unit/routes/authenticated/combined-course-test.js @@ -4,10 +4,6 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/combined-course', function (hooks) { setupTest(hooks); - - hooks.afterEach(function () { - sinon.restore(); - }); module('beforeModel', function () { test('user is redirected to index when he has no access', async function (assert) { // given diff --git a/orga/tests/unit/routes/authenticated/combined-course/participation-detail-test.js b/orga/tests/unit/routes/authenticated/combined-course/participation-detail-test.js index 3409f939288..8f0bc502aa7 100644 --- a/orga/tests/unit/routes/authenticated/combined-course/participation-detail-test.js +++ b/orga/tests/unit/routes/authenticated/combined-course/participation-detail-test.js @@ -5,10 +5,6 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/combined-course', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('beforeModel', function () { test('user is redirected to index when he has no access', async function (assert) { // given diff --git a/orga/tests/unit/routes/authenticated/combined-course/participations-test.js b/orga/tests/unit/routes/authenticated/combined-course/participations-test.js index 0497540d6d9..c5950c9000d 100644 --- a/orga/tests/unit/routes/authenticated/combined-course/participations-test.js +++ b/orga/tests/unit/routes/authenticated/combined-course/participations-test.js @@ -15,10 +15,6 @@ module('Unit | Route | authenticated/combined-course-participations', function ( }; }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('model', function () { test('fetch model for combined course', async function (assert) { // given diff --git a/orga/tests/unit/routes/authenticated/organization-participants/list-test.js b/orga/tests/unit/routes/authenticated/organization-participants/list-test.js index c481aa09069..bce837be869 100644 --- a/orga/tests/unit/routes/authenticated/organization-participants/list-test.js +++ b/orga/tests/unit/routes/authenticated/organization-participants/list-test.js @@ -33,9 +33,6 @@ module('Unit | Route | authenticated/organization-participants/list', function ( pageNumber: pageNumberSymbol, pageSize: pageSizeSymbol, }; - hooks.afterEach(function () { - sinon.restore(); - }); hooks.beforeEach(function () { route = this.owner.lookup('route:authenticated/organization-participants/list'); store = this.owner.lookup('service:store'); diff --git a/orga/tests/unit/routes/authenticated/preselect-target-profile-test.js b/orga/tests/unit/routes/authenticated/preselect-target-profile-test.js index 07e1c83844d..4cce32fd954 100644 --- a/orga/tests/unit/routes/authenticated/preselect-target-profile-test.js +++ b/orga/tests/unit/routes/authenticated/preselect-target-profile-test.js @@ -5,10 +5,6 @@ import sinon from 'sinon'; module('Unit | Route | authenticated/preselect-target-profile', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('model', function () { test('fetch a frameworks', async function (assert) { // given diff --git a/orga/tests/unit/routes/authenticated/sco-organization-participants/list-test.js b/orga/tests/unit/routes/authenticated/sco-organization-participants/list-test.js index 98feebb9c79..0c9c5b4a76c 100644 --- a/orga/tests/unit/routes/authenticated/sco-organization-participants/list-test.js +++ b/orga/tests/unit/routes/authenticated/sco-organization-participants/list-test.js @@ -29,10 +29,6 @@ module('Unit | Route | authenticated/sco-organization-participants/list', functi divisionSort: divisionSortSymbol, }; - hooks.afterEach(function () { - sinon.restore(); - }); - hooks.beforeEach(function () { route = this.owner.lookup('route:authenticated/sco-organization-participants/list'); store = this.owner.lookup('service:store'); diff --git a/orga/tests/unit/routes/authenticated/sup-organization-participants/list-test.js b/orga/tests/unit/routes/authenticated/sup-organization-participants/list-test.js index 23ed3fa0315..471c71ed21f 100644 --- a/orga/tests/unit/routes/authenticated/sup-organization-participants/list-test.js +++ b/orga/tests/unit/routes/authenticated/sup-organization-participants/list-test.js @@ -27,10 +27,6 @@ module('Unit | Route | authenticated/sup-organization-participants/list', functi lastnameSort: lastnameSortSymbol, }; - hooks.afterEach(function () { - sinon.restore(); - }); - hooks.beforeEach(function () { route = this.owner.lookup('route:authenticated/sup-organization-participants/list'); store = this.owner.lookup('service:store'); diff --git a/orga/tests/unit/routes/authentication/oidc/flow-test.js b/orga/tests/unit/routes/authentication/oidc/flow-test.js index cb1968a1d4f..3917488412f 100644 --- a/orga/tests/unit/routes/authentication/oidc/flow-test.js +++ b/orga/tests/unit/routes/authentication/oidc/flow-test.js @@ -10,10 +10,6 @@ module('Unit | Route | Authentication | OIDC | flow', function (hooks) { setupTest(hooks); setupIntl(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#model', function (hooks) { hooks.beforeEach(function () { stubOidcIdentityProvidersService(this.owner, { diff --git a/orga/tests/unit/services/current-domain-test.js b/orga/tests/unit/services/current-domain-test.js index 0329f5e8611..9d96f94d6ba 100644 --- a/orga/tests/unit/services/current-domain-test.js +++ b/orga/tests/unit/services/current-domain-test.js @@ -5,10 +5,6 @@ import sinon from 'sinon'; module('Unit | Service | currentDomain', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#getExtension', function () { module('when location is FR TLD', function () { test(`returns fr`, function (assert) { diff --git a/orga/tests/unit/services/locale-loader-test.js b/orga/tests/unit/services/locale-loader-test.js index 6a8364f8548..091ab5e933a 100644 --- a/orga/tests/unit/services/locale-loader-test.js +++ b/orga/tests/unit/services/locale-loader-test.js @@ -19,9 +19,6 @@ module('Unit | Services | locale-loader', function (hooks) { sinon.stub(intlService, 'addTranslations'); sinon.stub(dayjs, 'locale'); }); - hooks.afterEach(function () { - sinon.restore(); - }); test('loads daysjs language file from locale', async function (assert) { // when await localeLoaderService.load('de-AT'); diff --git a/orga/tests/unit/services/pix-metrics-test.js b/orga/tests/unit/services/pix-metrics-test.js index 79af62a7230..71841a4b0b9 100644 --- a/orga/tests/unit/services/pix-metrics-test.js +++ b/orga/tests/unit/services/pix-metrics-test.js @@ -17,10 +17,6 @@ module('Unit | Service | PixMetrics', function (hooks) { sinon.stub(metricsService, 'trackEvent'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('trackPage', function () { test('it should redact id from url', function (assert) { // given diff --git a/orga/tests/unit/services/request-manager-test.js b/orga/tests/unit/services/request-manager-test.js index aa5987f6fe2..1ddeb42162b 100644 --- a/orga/tests/unit/services/request-manager-test.js +++ b/orga/tests/unit/services/request-manager-test.js @@ -25,10 +25,6 @@ module('Unit | Service | request-manager', function (hooks) { sinon.stub(localeService, 'acceptLanguageHeader').value('fr'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('request()', function () { test('it requests successfully with default headers', async function (assert) { // given diff --git a/orga/tests/unit/utils/location-test.js b/orga/tests/unit/utils/location-test.js index 2201e0be9b9..99b66d0d7ae 100644 --- a/orga/tests/unit/utils/location-test.js +++ b/orga/tests/unit/utils/location-test.js @@ -2,11 +2,7 @@ import Location from 'pix-orga/utils/location'; import { module, test } from 'qunit'; import sinon from 'sinon'; -module('Unit | Utility | location', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - +module('Unit | Utility | location', function () { module('#getHref', function () { test('should return the full URL', function (assert) { // given From 5ac1ae01008ab2ce886485161f885fbe0a783e4c Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 15:36:00 +0200 Subject: [PATCH 5/9] refactor(certif): restore sinon stubs between each test --- certif/tests/test-helper.js | 6 ++++++ .../tests/unit/metrics-adapters/plausible-adapter-test.js | 2 ++ 2 files changed, 8 insertions(+) diff --git a/certif/tests/test-helper.js b/certif/tests/test-helper.js index 81e7e0fd8e6..44c5ccf499d 100644 --- a/certif/tests/test-helper.js +++ b/certif/tests/test-helper.js @@ -3,6 +3,7 @@ import { clearAllCookies } from 'ember-cookies/test-support'; import start from 'ember-exam/test-support/start'; import * as QUnit from 'qunit'; import { setup } from 'qunit-dom'; +import sinon from 'sinon'; import Application from '../app'; import config from '../config/environment'; @@ -17,6 +18,11 @@ QUnit.hooks.beforeEach(function () { clearAllCookies(); }); +// Restore all sinon stubs after each test to avoid side-effects +QUnit.hooks.afterEach(function () { + sinon.restore(); +}); + setApplication(Application.create(config.APP)); setup(QUnit.assert); start(); diff --git a/certif/tests/unit/metrics-adapters/plausible-adapter-test.js b/certif/tests/unit/metrics-adapters/plausible-adapter-test.js index a7758d9443d..9cb269ea16e 100644 --- a/certif/tests/unit/metrics-adapters/plausible-adapter-test.js +++ b/certif/tests/unit/metrics-adapters/plausible-adapter-test.js @@ -17,6 +17,8 @@ module('Unit | MetricsAdapter | plausible-adapter', function (hooks) { }); hooks.afterEach(function () { + // stubs must be restored before uninstalling the adapter, which removes `window.plausible` + sinon.restore(); this.adapter.uninstall(); }); From f6b57e6c1fc589a1af1d66b337e2712456605e2d Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 15:38:07 +0200 Subject: [PATCH 6/9] refactor(certif): remove useless sinon.restore() in tests --- .../tests/integration/components/auth/register-form-test.js | 4 ---- certif/tests/integration/components/members-list-test.js | 4 ---- certif/tests/integration/components/members-table-test.gjs | 4 ---- .../integration/components/team/invitations-list-test.js | 4 ---- .../components/team/modal/remove-member-modal-test.js | 4 ---- .../tests/unit/controllers/authenticated/team/list-test.js | 4 ---- .../controllers/authenticated/team/list/invitations-test.js | 4 ---- .../controllers/authenticated/team/list/members-test.js | 4 ---- certif/tests/unit/instance-initializers/session-test.js | 1 - certif/tests/unit/routes/application-test.js | 4 ---- certif/tests/unit/services/pix-metrics-test.js | 4 ---- certif/tests/unit/utils/location-test.js | 6 +----- 12 files changed, 1 insertion(+), 46 deletions(-) diff --git a/certif/tests/integration/components/auth/register-form-test.js b/certif/tests/integration/components/auth/register-form-test.js index 3066a31a464..e02864cfa5d 100644 --- a/certif/tests/integration/components/auth/register-form-test.js +++ b/certif/tests/integration/components/auth/register-form-test.js @@ -160,10 +160,6 @@ module('Integration | Component | Auth::RegisterForm', function (hooks) { store = this.owner.lookup('service:store'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - async function _fillValidForm() { await fillByLabel(firstNameInputLabel, 'Alain'); await fillByLabel(lastNameInputLabel, 'Ternational'); diff --git a/certif/tests/integration/components/members-list-test.js b/certif/tests/integration/components/members-list-test.js index b3ba46c4d44..0dea67e3ec1 100644 --- a/certif/tests/integration/components/members-list-test.js +++ b/certif/tests/integration/components/members-list-test.js @@ -20,10 +20,6 @@ module('Integration | Component | MembersList', function (hooks) { sinon.stub(currentUser, 'currentAllowedCertificationCenterAccess').value({ name: 'Certif NextGen' }); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('For edit role button', function () { test('displays a modal', async function (assert) { // given diff --git a/certif/tests/integration/components/members-table-test.gjs b/certif/tests/integration/components/members-table-test.gjs index 3af44b9da72..b5ef9169b82 100644 --- a/certif/tests/integration/components/members-table-test.gjs +++ b/certif/tests/integration/components/members-table-test.gjs @@ -17,10 +17,6 @@ module('Integration | Component | Members Table', function (hooks) { currentUser = this.owner.lookup('service:current-user'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('it displays members firstName, lastName and role', async function (assert) { // given const memberWithMemberRole = store.createRecord('member', { diff --git a/certif/tests/integration/components/team/invitations-list-test.js b/certif/tests/integration/components/team/invitations-list-test.js index 3e4c1ce42a0..5e6057ca5bd 100644 --- a/certif/tests/integration/components/team/invitations-list-test.js +++ b/certif/tests/integration/components/team/invitations-list-test.js @@ -23,10 +23,6 @@ module('Integration | Component | team/invitation-list', function (hooks) { this.set('resendInvitation', resendInvitation); }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('displays email address, last sending date and actions headers', async function (assert) { // given const invitation = store.createRecord('certification-center-invitation', { diff --git a/certif/tests/integration/components/team/modal/remove-member-modal-test.js b/certif/tests/integration/components/team/modal/remove-member-modal-test.js index 84d70343244..a7c1d1ed050 100644 --- a/certif/tests/integration/components/team/modal/remove-member-modal-test.js +++ b/certif/tests/integration/components/team/modal/remove-member-modal-test.js @@ -8,10 +8,6 @@ import setupIntlRenderingTest from '../../../../helpers/setup-intl-rendering'; module('Integration | Components | Team::Modal::RemoveMemberModal', function (hooks) { setupIntlRenderingTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when the modal is open', function (hooks) { let screen; let closeRemoveMembershipModal, onRemoveButtonClicked; diff --git a/certif/tests/unit/controllers/authenticated/team/list-test.js b/certif/tests/unit/controllers/authenticated/team/list-test.js index ba6ec2222c6..639935edd04 100644 --- a/certif/tests/unit/controllers/authenticated/team/list-test.js +++ b/certif/tests/unit/controllers/authenticated/team/list-test.js @@ -17,10 +17,6 @@ module('Unit | Controller | authenticated/team/list', function (hooks) { store = this.owner.lookup('service:store'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#shouldDisplayNoRefererSection', function () { module('when certification center has CLEA habilitation', function (hooks) { hooks.beforeEach(function () { diff --git a/certif/tests/unit/controllers/authenticated/team/list/invitations-test.js b/certif/tests/unit/controllers/authenticated/team/list/invitations-test.js index 32a0cf5c920..7801d0aea65 100644 --- a/certif/tests/unit/controllers/authenticated/team/list/invitations-test.js +++ b/certif/tests/unit/controllers/authenticated/team/list/invitations-test.js @@ -16,10 +16,6 @@ module('Unit | Controller | authenticated/team/list/invitations', function (hook controller = this.owner.lookup('controller:authenticated/team/list/invitations'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#cancelInvitation', function () { test('cancel invitation and displays a success notification', async function (assert) { // given diff --git a/certif/tests/unit/controllers/authenticated/team/list/members-test.js b/certif/tests/unit/controllers/authenticated/team/list/members-test.js index 3a6bb0bc742..8623d09d482 100644 --- a/certif/tests/unit/controllers/authenticated/team/list/members-test.js +++ b/certif/tests/unit/controllers/authenticated/team/list/members-test.js @@ -16,10 +16,6 @@ module('Unit | Controller | authenticated/team/list/members', function (hooks) { store = this.owner.lookup('service:store'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#leaveCertificationCenter', function () { test('deletes the current user membership', async function (assert) { // given diff --git a/certif/tests/unit/instance-initializers/session-test.js b/certif/tests/unit/instance-initializers/session-test.js index f77e5551afd..5d6ee5262de 100644 --- a/certif/tests/unit/instance-initializers/session-test.js +++ b/certif/tests/unit/instance-initializers/session-test.js @@ -23,7 +23,6 @@ module('Unit | Instance Initializer | session', function (hooks) { hooks.afterEach(function () { this.instance.destroy(); this.application.destroy(); - sinon.restore(); }); module('when a session exists', function () { diff --git a/certif/tests/unit/routes/application-test.js b/certif/tests/unit/routes/application-test.js index 01ff5dccf06..fd21d264e67 100644 --- a/certif/tests/unit/routes/application-test.js +++ b/certif/tests/unit/routes/application-test.js @@ -14,10 +14,6 @@ module('Unit | Route | application', function (hooks) { sinon.stub(this.route.currentUser, 'load').resolves(); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('beforeModel', function () { test('sets best locale', async function (assert) { // given diff --git a/certif/tests/unit/services/pix-metrics-test.js b/certif/tests/unit/services/pix-metrics-test.js index 212233c1570..a82290b9210 100644 --- a/certif/tests/unit/services/pix-metrics-test.js +++ b/certif/tests/unit/services/pix-metrics-test.js @@ -17,10 +17,6 @@ module('Unit | Service | PixMetrics', function (hooks) { sinon.stub(metricsService, 'trackEvent'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('trackPage', function () { test('it should redact id from url', function (assert) { // given diff --git a/certif/tests/unit/utils/location-test.js b/certif/tests/unit/utils/location-test.js index cbdc5bed9c2..0d8db9daf8d 100644 --- a/certif/tests/unit/utils/location-test.js +++ b/certif/tests/unit/utils/location-test.js @@ -2,11 +2,7 @@ import Location from 'pix-certif/utils/location'; import { module, test } from 'qunit'; import sinon from 'sinon'; -module('Unit | Utility | location (certif)', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - +module('Unit | Utility | location (certif)', function () { module('#getHref', function () { test('should return the full URL', function (assert) { // given From 929f9e01cc3bf6a244d67bb3721376a4318293f6 Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 16:06:36 +0200 Subject: [PATCH 7/9] refactor(mon-pix): restore sinon stubs between each test --- mon-pix/tests/test-helper.js | 6 ++++++ .../tests/unit/metrics-adapters/plausible-adapter-test.js | 2 ++ 2 files changed, 8 insertions(+) diff --git a/mon-pix/tests/test-helper.js b/mon-pix/tests/test-helper.js index 81e7e0fd8e6..44c5ccf499d 100644 --- a/mon-pix/tests/test-helper.js +++ b/mon-pix/tests/test-helper.js @@ -3,6 +3,7 @@ import { clearAllCookies } from 'ember-cookies/test-support'; import start from 'ember-exam/test-support/start'; import * as QUnit from 'qunit'; import { setup } from 'qunit-dom'; +import sinon from 'sinon'; import Application from '../app'; import config from '../config/environment'; @@ -17,6 +18,11 @@ QUnit.hooks.beforeEach(function () { clearAllCookies(); }); +// Restore all sinon stubs after each test to avoid side-effects +QUnit.hooks.afterEach(function () { + sinon.restore(); +}); + setApplication(Application.create(config.APP)); setup(QUnit.assert); start(); diff --git a/mon-pix/tests/unit/metrics-adapters/plausible-adapter-test.js b/mon-pix/tests/unit/metrics-adapters/plausible-adapter-test.js index 5ec78ee2783..d0c5e126e64 100644 --- a/mon-pix/tests/unit/metrics-adapters/plausible-adapter-test.js +++ b/mon-pix/tests/unit/metrics-adapters/plausible-adapter-test.js @@ -16,6 +16,8 @@ module('Unit | MetricsAdapter | plausible-adapter', function (hooks) { }); hooks.afterEach(function () { + // stubs must be restored before uninstall, which deletes the stubbed `window.plausible` + sinon.restore(); this.adapter.uninstall(); }); From 4e938fec9ccf89459e88e3c848090d0850d58929 Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 16:06:36 +0200 Subject: [PATCH 8/9] refactor(mon-pix): remove useless sinon.restore() in tests --- .../campaign-results-recommendation-engine-test.js | 1 - .../acceptance/user-account/connection-methods-test.js | 4 ---- .../tests/acceptance/user-account/delete-account-test.js | 5 ----- .../integration/components/assessments/live-alert-test.gjs | 4 ---- .../password-reset-demand-form-test.gjs | 4 ---- .../evaluation-results-recommendation-engine-test.gjs | 1 - .../results-recommendation-engine/trainings-test.gjs | 1 - .../tests/integration/components/challenge/content-test.gjs | 4 ---- .../tests/integration/components/challenge/item-test.gjs | 4 ---- .../tests/integration/components/companion/blocker-test.gjs | 4 ---- .../data-protection-policy-information-banner-test.gjs | 4 ---- .../components/download-session-results-test.gjs | 4 ---- mon-pix/tests/integration/modifiers/on-intersect-test.gjs | 1 - mon-pix/tests/unit/adapters/application-test.js | 1 - mon-pix/tests/unit/authenticators/gar-test.js | 5 ----- mon-pix/tests/unit/authenticators/oidc-test.js | 5 ----- .../tests/unit/controllers/assessments/challenge-test.js | 4 ---- .../unit/errors/factories/create-application-error-test.js | 4 ---- mon-pix/tests/unit/instance-initializers/session-test.js | 5 ----- mon-pix/tests/unit/routes/authentication/login-gar-test.js | 4 ---- mon-pix/tests/unit/routes/authentication/login-oidc-test.js | 4 ---- mon-pix/tests/unit/routes/campaigns/entry-point-test.js | 4 ---- .../unit/routes/campaigns/existing-participation-test.js | 4 ---- mon-pix/tests/unit/services/authentication-test.js | 4 ---- mon-pix/tests/unit/services/current-domain-test.js | 4 ---- mon-pix/tests/unit/services/file-saver-test.js | 4 ---- .../focused-certification-challenge-warning-manager-test.js | 4 ---- mon-pix/tests/unit/services/request-manager-test.js | 4 ---- mon-pix/tests/unit/utils/location-test.js | 6 +----- 29 files changed, 1 insertion(+), 106 deletions(-) diff --git a/mon-pix/tests/acceptance/campaigns/campaign-results-recommendation-engine-test.js b/mon-pix/tests/acceptance/campaigns/campaign-results-recommendation-engine-test.js index 137edf32613..442ff1c934e 100644 --- a/mon-pix/tests/acceptance/campaigns/campaign-results-recommendation-engine-test.js +++ b/mon-pix/tests/acceptance/campaigns/campaign-results-recommendation-engine-test.js @@ -286,7 +286,6 @@ module('Acceptance | Campaigns | Results | Recommendation Engine', function (hoo hooks.afterEach(function () { delete window.IntersectionObserver; - sinon.restore(); }); test('should display the drawer when user has not answered the survey', async function (assert) { diff --git a/mon-pix/tests/acceptance/user-account/connection-methods-test.js b/mon-pix/tests/acceptance/user-account/connection-methods-test.js index 89c6ea131ef..0d66e2ac7ed 100644 --- a/mon-pix/tests/acceptance/user-account/connection-methods-test.js +++ b/mon-pix/tests/acceptance/user-account/connection-methods-test.js @@ -20,10 +20,6 @@ module('Acceptance | user-account | connection-methods', function (hooks) { setupMirage(hooks); setupIntl(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('connection method details', function () { test("displays user's email and username", async function (assert) { // given diff --git a/mon-pix/tests/acceptance/user-account/delete-account-test.js b/mon-pix/tests/acceptance/user-account/delete-account-test.js index bc170ef4b6b..3b7c66339c5 100644 --- a/mon-pix/tests/acceptance/user-account/delete-account-test.js +++ b/mon-pix/tests/acceptance/user-account/delete-account-test.js @@ -3,7 +3,6 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import { t } from 'ember-intl/test-support'; import { setupApplicationTest } from 'ember-qunit'; import { module, test } from 'qunit'; -import sinon from 'sinon'; import { authenticate } from '../../helpers/authentication'; import setupIntl from '../../helpers/setup-intl'; @@ -13,10 +12,6 @@ module('Acceptance | user-account | delete-account', function (hooks) { setupMirage(hooks); setupIntl(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when user can self-delete their account', function () { test('it deletes their account', async function (assert) { // given diff --git a/mon-pix/tests/integration/components/assessments/live-alert-test.gjs b/mon-pix/tests/integration/components/assessments/live-alert-test.gjs index b7a73747a54..34e73f26460 100644 --- a/mon-pix/tests/integration/components/assessments/live-alert-test.gjs +++ b/mon-pix/tests/integration/components/assessments/live-alert-test.gjs @@ -10,10 +10,6 @@ import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; module('Integration | Component | Assessments | live-alert', function (hooks) { setupIntlRenderingTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - test('it displays challenge live alert', async function (assert) { // given const message = t('pages.challenge.live-alerts.companion.message'); diff --git a/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-form-test.gjs b/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-form-test.gjs index 90b482752c5..7e62f5ced17 100644 --- a/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-form-test.gjs +++ b/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-form-test.gjs @@ -99,10 +99,6 @@ module('Integration | Component | Authentication | PasswordResetDemand | passwor sinon.stub(window, 'fetch'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when the password-reset-demand is successful', function () { test('it displays a "password reset demand received" info (without any error message)', async function (assert) { // given diff --git a/mon-pix/tests/integration/components/campaigns/assessment/evaluation-results-recommendation-engine-test.gjs b/mon-pix/tests/integration/components/campaigns/assessment/evaluation-results-recommendation-engine-test.gjs index 601a3ea13c6..3ff6c2a077b 100644 --- a/mon-pix/tests/integration/components/campaigns/assessment/evaluation-results-recommendation-engine-test.gjs +++ b/mon-pix/tests/integration/components/campaigns/assessment/evaluation-results-recommendation-engine-test.gjs @@ -70,7 +70,6 @@ module( module('tracking', function (hooks) { hooks.afterEach(function () { delete window.IntersectionObserver; - sinon.restore(); }); test('it should send tracking when drawer is displayed', async function (assert) { diff --git a/mon-pix/tests/integration/components/campaigns/assessment/results-recommendation-engine/trainings-test.gjs b/mon-pix/tests/integration/components/campaigns/assessment/results-recommendation-engine/trainings-test.gjs index e0548f6ccd2..776eb9232ec 100644 --- a/mon-pix/tests/integration/components/campaigns/assessment/results-recommendation-engine/trainings-test.gjs +++ b/mon-pix/tests/integration/components/campaigns/assessment/results-recommendation-engine/trainings-test.gjs @@ -28,7 +28,6 @@ module('Integration | Components | Campaigns | Assessment | ResultsRecommendatio hooks.afterEach(function () { delete window.IntersectionObserver; - sinon.restore(); }); test('it should display the trainings list', async function (assert) { diff --git a/mon-pix/tests/integration/components/challenge/content-test.gjs b/mon-pix/tests/integration/components/challenge/content-test.gjs index 42332100f8c..7b7e1c0df0d 100644 --- a/mon-pix/tests/integration/components/challenge/content-test.gjs +++ b/mon-pix/tests/integration/components/challenge/content-test.gjs @@ -47,10 +47,6 @@ module('Integration | Component | Challenge | Content', function (hooks) { ); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('on challenge skip', function () { test('should disable the live alert button', async function (assert) { // then diff --git a/mon-pix/tests/integration/components/challenge/item-test.gjs b/mon-pix/tests/integration/components/challenge/item-test.gjs index cce0f2fa65d..d1f44bb9cb7 100644 --- a/mon-pix/tests/integration/components/challenge/item-test.gjs +++ b/mon-pix/tests/integration/components/challenge/item-test.gjs @@ -128,10 +128,6 @@ module('Integration | Component | Challenge | Item', function (hooks) { this.owner.register('service:current-user', CurrentUserStub); }); - hooks.afterEach(function () { - sinon.restore(); - }); - async function renderItem() { const noop = () => {}; const screen = await render( diff --git a/mon-pix/tests/integration/components/companion/blocker-test.gjs b/mon-pix/tests/integration/components/companion/blocker-test.gjs index 2e6b5963227..c4e9fc65cff 100644 --- a/mon-pix/tests/integration/components/companion/blocker-test.gjs +++ b/mon-pix/tests/integration/components/companion/blocker-test.gjs @@ -12,10 +12,6 @@ import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; module('Integration | Component | Companion | blocker', function (hooks) { setupIntlRenderingTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - test('it display children elements when extension is detected', async function (assert) { // given class PixCompanionStub extends Service { diff --git a/mon-pix/tests/integration/components/data-protection-policy-information-banner-test.gjs b/mon-pix/tests/integration/components/data-protection-policy-information-banner-test.gjs index aeb53591a45..4411203e704 100644 --- a/mon-pix/tests/integration/components/data-protection-policy-information-banner-test.gjs +++ b/mon-pix/tests/integration/components/data-protection-policy-information-banner-test.gjs @@ -13,10 +13,6 @@ import setupIntlRenderingTest from '../../helpers/setup-intl-rendering'; module('Integration | Component | data-protection-policy-information-banner', function (hooks) { setupIntlRenderingTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when user is not logged in', function () { test('does not display the data protection policy banner', async function (assert) { // given diff --git a/mon-pix/tests/integration/components/download-session-results-test.gjs b/mon-pix/tests/integration/components/download-session-results-test.gjs index 94862788fed..8acdb772be4 100644 --- a/mon-pix/tests/integration/components/download-session-results-test.gjs +++ b/mon-pix/tests/integration/components/download-session-results-test.gjs @@ -19,10 +19,6 @@ module('Integration | Component | download-session-results', function (hooks) { sinon.stub(fileSaver, 'save'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('should display component', async function (assert) { // given // when diff --git a/mon-pix/tests/integration/modifiers/on-intersect-test.gjs b/mon-pix/tests/integration/modifiers/on-intersect-test.gjs index 96a1d25194d..e36564775e3 100644 --- a/mon-pix/tests/integration/modifiers/on-intersect-test.gjs +++ b/mon-pix/tests/integration/modifiers/on-intersect-test.gjs @@ -25,7 +25,6 @@ module('Integration | Modifier | on-intersect', function (hooks) { hooks.afterEach(function () { delete window.IntersectionObserver; - sinon.restore(); }); test('it observes the element on insertion', async function (assert) { diff --git a/mon-pix/tests/unit/adapters/application-test.js b/mon-pix/tests/unit/adapters/application-test.js index b9309e34848..19bde03fefe 100644 --- a/mon-pix/tests/unit/adapters/application-test.js +++ b/mon-pix/tests/unit/adapters/application-test.js @@ -94,7 +94,6 @@ module('Unit | Adapters | ApplicationAdapter', function (hooks) { // then sinon.assert.notCalled(sessionService.invalidate); sinon.assert.calledOnce(RESTAdapter.prototype.handleResponse); - sinon.restore(); assert.ok(true); }); }); diff --git a/mon-pix/tests/unit/authenticators/gar-test.js b/mon-pix/tests/unit/authenticators/gar-test.js index 686d59f7a06..298a52ea230 100644 --- a/mon-pix/tests/unit/authenticators/gar-test.js +++ b/mon-pix/tests/unit/authenticators/gar-test.js @@ -1,14 +1,9 @@ import { setupTest } from 'ember-qunit'; import { module, test } from 'qunit'; -import sinon from 'sinon'; module('Unit | Authenticator | gar', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#authenticate', function () { test('should authenticate the user', async function (assert) { // given diff --git a/mon-pix/tests/unit/authenticators/oidc-test.js b/mon-pix/tests/unit/authenticators/oidc-test.js index d0a8477e76d..ac19077abb2 100644 --- a/mon-pix/tests/unit/authenticators/oidc-test.js +++ b/mon-pix/tests/unit/authenticators/oidc-test.js @@ -57,10 +57,6 @@ module('Unit | Authenticator | oidc', function (hooks) { oidcIdentityProvidersService.set('store', storeStub); }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('retrieves an access token with authentication key', async function (assert) { // given const authenticator = this.owner.lookup('authenticator:oidc'); @@ -193,7 +189,6 @@ module('Unit | Authenticator | oidc', function (hooks) { // then assert.strictEqual(authenticator.session.alternativeRootURL, redirectLogoutUrl); - sinon.restore(); }); }); }); diff --git a/mon-pix/tests/unit/controllers/assessments/challenge-test.js b/mon-pix/tests/unit/controllers/assessments/challenge-test.js index 48ed9aa251e..005e090175d 100644 --- a/mon-pix/tests/unit/controllers/assessments/challenge-test.js +++ b/mon-pix/tests/unit/controllers/assessments/challenge-test.js @@ -15,10 +15,6 @@ module('Unit | Controller | Assessments | Challenge', function (hooks) { controller.intl = intl; }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#pageTitle', function () { test('should return Épreuve 2 sur 5', function (assert) { // given diff --git a/mon-pix/tests/unit/errors/factories/create-application-error-test.js b/mon-pix/tests/unit/errors/factories/create-application-error-test.js index 12384211b88..d332c458e93 100644 --- a/mon-pix/tests/unit/errors/factories/create-application-error-test.js +++ b/mon-pix/tests/unit/errors/factories/create-application-error-test.js @@ -6,10 +6,6 @@ import sinon from 'sinon'; module('Unit | Errors | Factories | create-application-error', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('when the error code is provided', function () { test('returns an application error with a translated message', function (assert) { // Given diff --git a/mon-pix/tests/unit/instance-initializers/session-test.js b/mon-pix/tests/unit/instance-initializers/session-test.js index 12e3c1708b3..ebf357e35fa 100644 --- a/mon-pix/tests/unit/instance-initializers/session-test.js +++ b/mon-pix/tests/unit/instance-initializers/session-test.js @@ -43,7 +43,6 @@ module('Unit | Instance Initializer | session', function () { assert.notOk(session); this.instance.destroy(); this.application.destroy(); - sinon.restore(); }); }); @@ -83,7 +82,6 @@ module('Unit | Instance Initializer | session', function () { assert.notOk(session); this.instance.destroy(); this.application.destroy(); - sinon.restore(); }); }); }); @@ -121,7 +119,6 @@ module('Unit | Instance Initializer | session', function () { assert.notOk(session); this.instance.destroy(); this.application.destroy(); - sinon.restore(); }); }); @@ -157,7 +154,6 @@ module('Unit | Instance Initializer | session', function () { assert.notOk(session); this.instance.destroy(); this.application.destroy(); - sinon.restore(); }); }); @@ -193,7 +189,6 @@ module('Unit | Instance Initializer | session', function () { assert.notOk(session); this.instance.destroy(); this.application.destroy(); - sinon.restore(); }); }); }); diff --git a/mon-pix/tests/unit/routes/authentication/login-gar-test.js b/mon-pix/tests/unit/routes/authentication/login-gar-test.js index 4339b39aa64..c47eb56e520 100644 --- a/mon-pix/tests/unit/routes/authentication/login-gar-test.js +++ b/mon-pix/tests/unit/routes/authentication/login-gar-test.js @@ -7,10 +7,6 @@ import sinon from 'sinon'; module('Unit | Routes | authentication | login-gar', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#beforeModel', function () { module('when a token is set as an hash of an url', function () { test('should authenticate the user', async function (assert) { diff --git a/mon-pix/tests/unit/routes/authentication/login-oidc-test.js b/mon-pix/tests/unit/routes/authentication/login-oidc-test.js index 001d2f64a1c..5eabe7ce855 100644 --- a/mon-pix/tests/unit/routes/authentication/login-oidc-test.js +++ b/mon-pix/tests/unit/routes/authentication/login-oidc-test.js @@ -12,10 +12,6 @@ module('Unit | Route | login-oidc', function (hooks) { setupTest(hooks); setupIntl(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#beforeModel', function () { module('when receives error from identity provider', function () { test('it throws an error', function (assert) { diff --git a/mon-pix/tests/unit/routes/campaigns/entry-point-test.js b/mon-pix/tests/unit/routes/campaigns/entry-point-test.js index 2550d4ff774..72ac7e7b3e2 100644 --- a/mon-pix/tests/unit/routes/campaigns/entry-point-test.js +++ b/mon-pix/tests/unit/routes/campaigns/entry-point-test.js @@ -27,10 +27,6 @@ module('Unit | Route | Entry Point', function (hooks) { route.currentUser = { user: {} }; }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#beforeModel', function () { test('should invalidate session when a user is connected and anonymous', async function (assert) { //given diff --git a/mon-pix/tests/unit/routes/campaigns/existing-participation-test.js b/mon-pix/tests/unit/routes/campaigns/existing-participation-test.js index b1364b82dc1..f3dedd18303 100644 --- a/mon-pix/tests/unit/routes/campaigns/existing-participation-test.js +++ b/mon-pix/tests/unit/routes/campaigns/existing-participation-test.js @@ -21,10 +21,6 @@ module('Unit | Route | ExistingParticipation', function (hooks) { route.store = { queryRecord: sinon.stub() }; }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#beforeModel', function () { test('should call session requireAuthenticationAndApprovedTermsOfService with transition', async function (assert) { //given diff --git a/mon-pix/tests/unit/services/authentication-test.js b/mon-pix/tests/unit/services/authentication-test.js index fe8edcd224d..fa854e9adf0 100644 --- a/mon-pix/tests/unit/services/authentication-test.js +++ b/mon-pix/tests/unit/services/authentication-test.js @@ -14,10 +14,6 @@ module('Unit | Services | authentication', function (hooks) { sinon.stub(authenticationService.router, 'replaceWith'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#handleAnonymousAuthentication', function () { module('when there is no session', function () { module('when the route is available for an anonymous user', function () { diff --git a/mon-pix/tests/unit/services/current-domain-test.js b/mon-pix/tests/unit/services/current-domain-test.js index c0d81bb9c0a..6ad6ba54071 100644 --- a/mon-pix/tests/unit/services/current-domain-test.js +++ b/mon-pix/tests/unit/services/current-domain-test.js @@ -6,10 +6,6 @@ import sinon from 'sinon'; module('Unit | Service | currentDomain', function (hooks) { setupTest(hooks); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#getExtension', function () { module('when location is FR TLD', function () { test(`returns fr`, function (assert) { diff --git a/mon-pix/tests/unit/services/file-saver-test.js b/mon-pix/tests/unit/services/file-saver-test.js index b8e56780608..fe610dfc6fd 100644 --- a/mon-pix/tests/unit/services/file-saver-test.js +++ b/mon-pix/tests/unit/services/file-saver-test.js @@ -45,10 +45,6 @@ module('Unit | Service | file-saver', function (hooks) { }); }); - hooks.afterEach(function () { - sinon.restore(); - }); - test('should override the HTTP method', async function (assert) { // given const expectedMethod = 'PATCH'; diff --git a/mon-pix/tests/unit/services/focused-certification-challenge-warning-manager-test.js b/mon-pix/tests/unit/services/focused-certification-challenge-warning-manager-test.js index f9797893aeb..ec4b4b29d2e 100644 --- a/mon-pix/tests/unit/services/focused-certification-challenge-warning-manager-test.js +++ b/mon-pix/tests/unit/services/focused-certification-challenge-warning-manager-test.js @@ -11,10 +11,6 @@ module('Unit | Service | focused-certification-challenge-warning-manager', funct getItemStub = sinon.stub(window.localStorage, 'getItem'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('#setToConfirmed', function () { test('should set to true', function (assert) { // given diff --git a/mon-pix/tests/unit/services/request-manager-test.js b/mon-pix/tests/unit/services/request-manager-test.js index aa5987f6fe2..1ddeb42162b 100644 --- a/mon-pix/tests/unit/services/request-manager-test.js +++ b/mon-pix/tests/unit/services/request-manager-test.js @@ -25,10 +25,6 @@ module('Unit | Service | request-manager', function (hooks) { sinon.stub(localeService, 'acceptLanguageHeader').value('fr'); }); - hooks.afterEach(function () { - sinon.restore(); - }); - module('request()', function () { test('it requests successfully with default headers', async function (assert) { // given diff --git a/mon-pix/tests/unit/utils/location-test.js b/mon-pix/tests/unit/utils/location-test.js index 71f806fce0e..058cb9bfe12 100644 --- a/mon-pix/tests/unit/utils/location-test.js +++ b/mon-pix/tests/unit/utils/location-test.js @@ -2,11 +2,7 @@ import Location from 'mon-pix/utils/location'; import { module, test } from 'qunit'; import sinon from 'sinon'; -module('Unit | Utility | location', function (hooks) { - hooks.afterEach(function () { - sinon.restore(); - }); - +module('Unit | Utility | location', function () { module('#getHref', function () { test('should return the full URL', function (assert) { // given From 04aafa90b0110a772d1f5321d74ba126e9ca239b Mon Sep 17 00:00:00 2001 From: Benjamin Petetot Date: Fri, 14 Aug 2026 16:13:57 +0200 Subject: [PATCH 9/9] refactor(junior): restore sinon stubs between each test --- junior/tests/test-helper.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/junior/tests/test-helper.js b/junior/tests/test-helper.js index ebb2bf2979d..fe228ca1b0b 100644 --- a/junior/tests/test-helper.js +++ b/junior/tests/test-helper.js @@ -4,10 +4,15 @@ import { setApplication } from '@ember/test-helpers'; import start from 'ember-exam/test-support/start'; import * as QUnit from 'qunit'; import { setup } from 'qunit-dom'; +import sinon from 'sinon'; import Application from '../app'; import config from '../config/environment'; +QUnit.hooks.afterEach(function () { + sinon.restore(); +}); + setApplication(Application.create(config.APP)); setup(QUnit.assert); start();