This commit is contained in:
parent
3e39564695
commit
f797cc1761
|
@ -16,60 +16,56 @@ describe('ChangePassword path', async() => {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
const toExpects = [];
|
|
||||||
async function saveExpets(message, expectMessage, expectState) {
|
|
||||||
if (!message && expectMessage) message = await page.waitForSnackbar();
|
|
||||||
if (expectState)
|
|
||||||
toExpects.push({value: await page.getState(), expected: expectState});
|
|
||||||
if (expectMessage)
|
|
||||||
toExpects.push({value: message.text, expected: expectMessage});
|
|
||||||
}
|
|
||||||
|
|
||||||
const oldPassword = 'nightmare';
|
const oldPassword = 'nightmare';
|
||||||
const newPassword = 'newPass.1234';
|
const newPassword = 'newPass.1234';
|
||||||
describe('Bad login', async() => {
|
describe('Bad login', async() => {
|
||||||
it('should receive an error when the password is expired', async() => {
|
it('should receive an error when the password is expired', async() => {
|
||||||
// Expired login
|
// Expired login
|
||||||
await saveExpets(await page.doLogin(
|
await page.doLogin('Maintenance', oldPassword);
|
||||||
'Maintenance',
|
let message = await page.waitForSnackbar();
|
||||||
oldPassword
|
|
||||||
), 'The password has expired, change it from Salix', 'change-password');
|
expect(message.text).toContain('The password has expired, change it from Salix');
|
||||||
|
expect(await page.getState()).toContain('change-password');
|
||||||
|
|
||||||
// Bad attempt: incorrect current password
|
// Bad attempt: incorrect current password
|
||||||
await saveExpets(await page.sendForm($.form, {
|
message = await page.sendForm($.form, {
|
||||||
oldPassword: newPassword,
|
oldPassword: newPassword,
|
||||||
newPassword: oldPassword,
|
newPassword: oldPassword,
|
||||||
repeatPassword: oldPassword
|
repeatPassword: oldPassword
|
||||||
}), 'Invalid current password');
|
});
|
||||||
|
|
||||||
|
expect(message.text).toContain('Invalid current password');
|
||||||
|
|
||||||
// Bad attempt: password not meet requirements
|
// Bad attempt: password not meet requirements
|
||||||
await saveExpets(await page.sendForm($.form, {
|
message = await page.sendForm($.form, {
|
||||||
oldPassword: oldPassword,
|
oldPassword: oldPassword,
|
||||||
newPassword: oldPassword,
|
newPassword: oldPassword,
|
||||||
repeatPassword: oldPassword
|
repeatPassword: oldPassword
|
||||||
}), 'Password does not meet requirements');
|
});
|
||||||
|
|
||||||
|
expect(message.text).toContain('Password does not meet requirements');
|
||||||
|
|
||||||
// Correct attempt: change password
|
// Correct attempt: change password
|
||||||
await saveExpets(await page.sendForm($.form, {
|
message = await page.sendForm($.form, {
|
||||||
oldPassword: oldPassword,
|
oldPassword: oldPassword,
|
||||||
newPassword: newPassword,
|
newPassword: newPassword,
|
||||||
repeatPassword: newPassword
|
repeatPassword: newPassword
|
||||||
}), 'Password updated!', 'login');
|
});
|
||||||
|
|
||||||
|
expect(message.text).toContain('Password updated!');
|
||||||
|
expect(await page.getState()).toContain('login');
|
||||||
|
|
||||||
// Bad login, old password
|
// Bad login, old password
|
||||||
await saveExpets(await page.doLogin(
|
await page.doLogin('Maintenance', oldPassword);
|
||||||
'Maintenance',
|
message = await page.waitForSnackbar();
|
||||||
oldPassword
|
|
||||||
), 'Invalid login');
|
expect(message.text).toContain('Invalid login');
|
||||||
|
|
||||||
// Correct login, new password
|
// Correct login, new password
|
||||||
await saveExpets(await page.doLogin(
|
await page.doLogin('Maintenance', newPassword);
|
||||||
'Maintenance',
|
await page.waitForSelector('vn-home');
|
||||||
newPassword
|
|
||||||
), null, 'login');
|
|
||||||
|
|
||||||
for (let toExpect of toExpects)
|
expect(await page.getState()).toBe('home');
|
||||||
expect(toExpect.value).toContain(toExpect.expected); // eslint-disable-line
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue