2023-06-05 13:20:07 +00:00
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
|
|
|
|
const $ = {
|
|
|
|
form: 'vn-out-layout form'
|
|
|
|
};
|
|
|
|
|
2023-06-07 11:34:13 +00:00
|
|
|
describe('ChangePassword path', async() => {
|
2023-06-05 13:20:07 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
2023-06-28 07:59:55 +00:00
|
|
|
const badPassword = 'badpass';
|
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() => {
|
2023-06-06 13:09:01 +00:00
|
|
|
// Expired login
|
2023-06-09 06:31:05 +00:00
|
|
|
await page.doLogin('Maintenance', oldPassword);
|
|
|
|
let message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.text).toContain('The password has expired, change it from Salix');
|
|
|
|
expect(await page.getState()).toContain('change-password');
|
2023-06-05 13:20:07 +00:00
|
|
|
|
2023-06-06 13:09:01 +00:00
|
|
|
// Bad attempt: incorrect current password
|
2023-06-09 06:31:05 +00:00
|
|
|
message = await page.sendForm($.form, {
|
2023-06-05 13:20:07 +00:00
|
|
|
oldPassword: newPassword,
|
|
|
|
newPassword: oldPassword,
|
|
|
|
repeatPassword: oldPassword
|
2023-06-09 06:31:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(message.text).toContain('Invalid current password');
|
2023-06-05 13:20:07 +00:00
|
|
|
|
2023-06-06 13:09:01 +00:00
|
|
|
// Bad attempt: password not meet requirements
|
2023-06-28 07:59:55 +00:00
|
|
|
message = await page.sendForm($.form, {
|
|
|
|
oldPassword: oldPassword,
|
|
|
|
newPassword: badPassword,
|
|
|
|
repeatPassword: badPassword
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(message.text).toContain('Password does not meet requirements');
|
|
|
|
|
|
|
|
// Bad attempt: same password
|
2023-06-09 06:31:05 +00:00
|
|
|
message = await page.sendForm($.form, {
|
2023-06-05 13:20:07 +00:00
|
|
|
oldPassword: oldPassword,
|
|
|
|
newPassword: oldPassword,
|
|
|
|
repeatPassword: oldPassword
|
2023-06-09 06:31:05 +00:00
|
|
|
});
|
|
|
|
|
2023-06-28 07:59:55 +00:00
|
|
|
expect(message.text).toContain('You can not use the same password');
|
2023-06-05 13:20:07 +00:00
|
|
|
|
2023-06-06 13:09:01 +00:00
|
|
|
// Correct attempt: change password
|
2023-06-09 06:31:05 +00:00
|
|
|
message = await page.sendForm($.form, {
|
2023-06-05 13:20:07 +00:00
|
|
|
oldPassword: oldPassword,
|
|
|
|
newPassword: newPassword,
|
|
|
|
repeatPassword: newPassword
|
2023-06-09 06:31:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(message.text).toContain('Password updated!');
|
|
|
|
expect(await page.getState()).toContain('login');
|
2023-06-05 13:20:07 +00:00
|
|
|
|
2023-06-06 13:09:01 +00:00
|
|
|
// Bad login, old password
|
2023-06-09 06:31:05 +00:00
|
|
|
await page.doLogin('Maintenance', oldPassword);
|
|
|
|
message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.text).toContain('Invalid login');
|
2023-06-05 13:20:07 +00:00
|
|
|
|
2023-06-06 13:09:01 +00:00
|
|
|
// Correct login, new password
|
2023-06-09 06:31:05 +00:00
|
|
|
await page.doLogin('Maintenance', newPassword);
|
|
|
|
await page.waitForSelector('vn-home');
|
2023-06-05 13:20:07 +00:00
|
|
|
|
2023-06-09 06:31:05 +00:00
|
|
|
expect(await page.getState()).toBe('home');
|
2023-06-05 13:20:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|