72 lines
2.3 KiB
JavaScript
72 lines
2.3 KiB
JavaScript
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
const $ = {
|
|
form: 'vn-out-layout form'
|
|
};
|
|
|
|
describe('ChangePassword path', async() => {
|
|
let browser;
|
|
let page;
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
const oldPassword = 'nightmare';
|
|
const newPassword = 'newPass.1234';
|
|
describe('Bad login', async() => {
|
|
it('should receive an error when the password is expired', async() => {
|
|
// Expired login
|
|
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');
|
|
|
|
// Bad attempt: incorrect current password
|
|
message = await page.sendForm($.form, {
|
|
oldPassword: newPassword,
|
|
newPassword: oldPassword,
|
|
repeatPassword: oldPassword
|
|
});
|
|
|
|
expect(message.text).toContain('Invalid current password');
|
|
|
|
// Bad attempt: password not meet requirements
|
|
message = await page.sendForm($.form, {
|
|
oldPassword: oldPassword,
|
|
newPassword: oldPassword,
|
|
repeatPassword: oldPassword
|
|
});
|
|
|
|
expect(message.text).toContain('Password does not meet requirements');
|
|
|
|
// Correct attempt: change password
|
|
message = await page.sendForm($.form, {
|
|
oldPassword: oldPassword,
|
|
newPassword: newPassword,
|
|
repeatPassword: newPassword
|
|
});
|
|
|
|
expect(message.text).toContain('Password updated!');
|
|
expect(await page.getState()).toContain('login');
|
|
|
|
// Bad login, old password
|
|
await page.doLogin('Maintenance', oldPassword);
|
|
message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Invalid login');
|
|
|
|
// Correct login, new password
|
|
await page.doLogin('Maintenance', newPassword);
|
|
await page.waitForSelector('vn-home');
|
|
|
|
expect(await page.getState()).toBe('home');
|
|
});
|
|
});
|
|
});
|