salix/e2e/paths/01-salix/05_changePassword.spec.js

76 lines
2.5 KiB
JavaScript
Raw Normal View History

2023-06-05 13:20:07 +00:00
import getBrowser from '../../helpers/puppeteer';
const $ = {
form: 'vn-out-layout form'
};
fdescribe('ChangePassword path', async() => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
});
afterAll(async() => {
await browser.close();
});
const toExpects = [];
async function saveExpets(message, expectMessage, expectState) {
if (!message && expectMessage) message = await page.waitForSnackbar();
2023-06-05 13:20:07 +00:00
if (expectState)
toExpects.push({value: await page.getState(), expected: expectState});
2023-06-05 13:20:07 +00:00
if (expectMessage)
toExpects.push({value: message.text, expected: expectMessage});
2023-06-05 13:20:07 +00:00
}
const oldPassword = 'nightmare';
const newPassword = 'newPass.1234';
describe('Bad login', async() => {
it('should receive an error when the password is expired', async() => {
// Expired login
2023-06-05 13:20:07 +00:00
await saveExpets(await page.doLogin(
'Maintenance',
2023-06-05 13:20:07 +00:00
oldPassword
), 'The password has expired, change it from Salix', 'change-password');
// Bad attempt: incorrect current password
2023-06-05 13:20:07 +00:00
await saveExpets(await page.sendForm($.form, {
oldPassword: newPassword,
newPassword: oldPassword,
repeatPassword: oldPassword
}), 'Invalid current password');
// Bad attempt: password not meet requirements
2023-06-05 13:20:07 +00:00
await saveExpets(await page.sendForm($.form, {
oldPassword: oldPassword,
newPassword: oldPassword,
repeatPassword: oldPassword
}), 'Password does not meet requirements');
// Correct attempt: change password
2023-06-05 13:20:07 +00:00
await saveExpets(await page.sendForm($.form, {
oldPassword: oldPassword,
newPassword: newPassword,
repeatPassword: newPassword
}), 'Password updated!', 'login');
// Bad login, old password
2023-06-05 13:20:07 +00:00
await saveExpets(await page.doLogin(
'Maintenance',
2023-06-05 13:20:07 +00:00
oldPassword
), 'Invalid login');
2023-06-05 13:20:07 +00:00
// Correct login, new password
2023-06-05 13:20:07 +00:00
await saveExpets(await page.doLogin(
'Maintenance',
2023-06-05 13:20:07 +00:00
newPassword
), null, 'login');
2023-06-05 13:20:07 +00:00
for (let toExpect of toExpects)
expect(toExpect.value).toContain(toExpect.expected); // eslint-disable-line
2023-06-05 13:20:07 +00:00
});
});
});