Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(<template><CreateAttestations /></template>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(<template><UserQuestChecker /></template>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions admin/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
4 changes: 0 additions & 4 deletions admin/tests/unit/authenticators/oidc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions admin/tests/unit/routes/authenticated/users/get-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 0 additions & 5 deletions admin/tests/unit/routes/authentication/login-oidc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
});
});
});
Expand Down
6 changes: 1 addition & 5 deletions admin/tests/unit/routes/login-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 0 additions & 4 deletions admin/tests/unit/services/current-domain-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions admin/tests/unit/services/pix-metrics-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions admin/tests/unit/services/request-manager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions admin/tests/unit/utils/location-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 0 additions & 4 deletions certif/tests/integration/components/members-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions certif/tests/integration/components/members-table-test.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions certif/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
4 changes: 0 additions & 4 deletions certif/tests/unit/controllers/authenticated/team/list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion certif/tests/unit/instance-initializers/session-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 2 additions & 0 deletions certif/tests/unit/metrics-adapters/plausible-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
4 changes: 0 additions & 4 deletions certif/tests/unit/routes/application-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading