-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mon-pix): add tests for new SigninForm
- Loading branch information
Showing
5 changed files
with
395 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
139 changes: 139 additions & 0 deletions
139
mon-pix/tests/acceptance/authentication/authentication-redirections-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import { visit } from '@1024pix/ember-testing-library'; | ||
import { click, currentURL, fillIn } from '@ember/test-helpers'; | ||
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 { authenticateByEmail, authenticateByUsername } from '../../helpers/authentication'; | ||
import setupIntl from '../../helpers/setup-intl'; | ||
|
||
module('Acceptance | Authentication redirections', function (hooks) { | ||
setupApplicationTest(hooks); | ||
setupMirage(hooks); | ||
setupIntl(hooks); | ||
|
||
let user; | ||
|
||
hooks.beforeEach(function () { | ||
user = server.create('user', 'withEmail'); | ||
}); | ||
|
||
module('when "New authentication design" feature toggle is disabled', function (hooks) { | ||
hooks.beforeEach(function () { | ||
server.create('feature-toggle', { | ||
id: 0, | ||
isNewAuthenticationDesignEnabled: false, | ||
}); | ||
}); | ||
|
||
module('Success cases', function () { | ||
module('Accessing to the default page page while disconnected', function () { | ||
test('should redirect to the connexion page', async function (assert) { | ||
// when | ||
await visit('/'); | ||
|
||
// then | ||
assert.strictEqual(currentURL(), '/connexion'); | ||
}); | ||
}); | ||
|
||
module('Log-in phase', function () { | ||
test('should redirect to /accueil after connexion', async function (assert) { | ||
// when | ||
await authenticateByEmail(user); | ||
|
||
// then | ||
assert.strictEqual(currentURL(), '/accueil'); | ||
}); | ||
}); | ||
}); | ||
|
||
module('Error case', function () { | ||
test('should stay in /connexion, when authentication failed', async function (assert) { | ||
// given | ||
const screen = await visit('/connexion'); | ||
await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), '[email protected]'); | ||
await fillIn(screen.getByLabelText('Mot de passe'), 'Pix20!!'); | ||
|
||
// when | ||
await click(screen.getByRole('button', { name: t('pages.sign-in.actions.submit') })); | ||
|
||
// then | ||
assert.strictEqual(currentURL(), '/connexion'); | ||
}); | ||
|
||
module('when user should change password', function () { | ||
test('should redirect to /update-expired-password', async function (assert) { | ||
// given | ||
user = server.create('user', 'withUsername', 'shouldChangePassword'); | ||
|
||
// when | ||
await authenticateByUsername(user); | ||
|
||
// then | ||
assert.strictEqual(currentURL(), '/mise-a-jour-mot-de-passe-expire'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
module('when "New authentication design" feature toggle is enabled', function (hooks) { | ||
hooks.beforeEach(function () { | ||
server.create('feature-toggle', { | ||
id: 0, | ||
isNewAuthenticationDesignEnabled: true, | ||
}); | ||
}); | ||
|
||
module('Success cases', function () { | ||
module('Accessing to the default page page while disconnected', function () { | ||
test('should redirect to the connexion page', async function (assert) { | ||
// when | ||
await visit('/'); | ||
|
||
// then | ||
assert.strictEqual(currentURL(), '/connexion'); | ||
}); | ||
}); | ||
|
||
module('Log-in phase', function () { | ||
test('should redirect to /accueil after connexion', async function (assert) { | ||
// when | ||
await authenticateByEmail(user); | ||
|
||
// then | ||
assert.strictEqual(currentURL(), '/accueil'); | ||
}); | ||
}); | ||
}); | ||
|
||
module('Error case', function () { | ||
test('should stay in /connexion, when authentication failed', async function (assert) { | ||
// given | ||
const screen = await visit('/connexion'); | ||
await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), '[email protected]'); | ||
await fillIn(screen.getByLabelText('Mot de passe'), 'Pix20!!'); | ||
|
||
// when | ||
await click(screen.getByRole('button', { name: t('pages.sign-in.actions.submit') })); | ||
|
||
// then | ||
assert.strictEqual(currentURL(), '/connexion'); | ||
}); | ||
|
||
module('when user should change password', function () { | ||
test('should redirect to /update-expired-password', async function (assert) { | ||
// given | ||
user = server.create('user', 'withUsername', 'shouldChangePassword'); | ||
|
||
// when | ||
await authenticateByUsername(user); | ||
|
||
// then | ||
assert.strictEqual(currentURL(), '/mise-a-jour-mot-de-passe-expire'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.