diff --git a/e2e/paths/01-salix/05_changePassword.spec.js b/e2e/paths/01-salix/05_changePassword.spec.js index 318e26799..6e4cfb7f3 100644 --- a/e2e/paths/01-salix/05_changePassword.spec.js +++ b/e2e/paths/01-salix/05_changePassword.spec.js @@ -16,60 +16,56 @@ describe('ChangePassword path', async() => { 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 newPassword = 'newPass.1234'; describe('Bad login', async() => { it('should receive an error when the password is expired', async() => { // Expired login - await saveExpets(await page.doLogin( - 'Maintenance', - oldPassword - ), 'The password has expired, change it from Salix', 'change-password'); + 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 - await saveExpets(await page.sendForm($.form, { + message = await page.sendForm($.form, { oldPassword: newPassword, newPassword: oldPassword, repeatPassword: oldPassword - }), 'Invalid current password'); + }); + + expect(message.text).toContain('Invalid current password'); // Bad attempt: password not meet requirements - await saveExpets(await page.sendForm($.form, { + message = await page.sendForm($.form, { oldPassword: oldPassword, newPassword: oldPassword, repeatPassword: oldPassword - }), 'Password does not meet requirements'); + }); + + expect(message.text).toContain('Password does not meet requirements'); // Correct attempt: change password - await saveExpets(await page.sendForm($.form, { + message = await page.sendForm($.form, { oldPassword: oldPassword, newPassword: newPassword, repeatPassword: newPassword - }), 'Password updated!', 'login'); + }); + + expect(message.text).toContain('Password updated!'); + expect(await page.getState()).toContain('login'); // Bad login, old password - await saveExpets(await page.doLogin( - 'Maintenance', - oldPassword - ), 'Invalid login'); + await page.doLogin('Maintenance', oldPassword); + message = await page.waitForSnackbar(); + + expect(message.text).toContain('Invalid login'); // Correct login, new password - await saveExpets(await page.doLogin( - 'Maintenance', - newPassword - ), null, 'login'); + await page.doLogin('Maintenance', newPassword); + await page.waitForSelector('vn-home'); - for (let toExpect of toExpects) - expect(toExpect.value).toContain(toExpect.expected); // eslint-disable-line + expect(await page.getState()).toBe('home'); }); }); });