Merge pull request #14486 from mozilla/password-test-playwright

test(functional): rewrite password tests using playwright
This commit is contained in:
Ankita Shrivastava 2022-11-23 10:22:41 -05:00 коммит произвёл GitHub
Родитель 65909aa79c 82ce236de2
Коммит e5d8cd8ae4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 134 добавлений и 0 удалений

Просмотреть файл

@ -26,6 +26,14 @@ export const selectors = {
VPASSWORD: '#vpassword',
SYNC_CONNECTED_HEADER: '#fxa-connected-heading',
NOTES_HEADER: '#notes-by-firefox',
MIN_LENGTH_MET: '#password-too-short.password-strength-met',
MIN_LENGTH_FAIL: '#password-too-short.password-strength-fail',
NOT_COMMON_FAIL: '#password-too-common.password-strength-fail',
NOT_COMMON_UNMET: '#password-too-common.password-strength-unmet',
NOT_COMMON_MET: '#password-too-common.password-strength-met',
NOT_EMAIL_UNMET: '#password-same-as-email.password-strength-unmet',
NOT_EMAIL_MET: '#password-same-as-email.password-strength-met',
NOT_EMAIL_FAIL: '#password-same-as-email.password-strength-fail',
};
export class LoginPage extends BaseLayout {
@ -56,6 +64,14 @@ export class LoginPage extends BaseLayout {
TOOLTIP: '.tooltip',
VPASSWORD: '#vpassword',
SYNC_CONNECTED_HEADER: '#fxa-connected-heading',
MIN_LENGTH_MET: '#password-too-short.password-strength-met',
MIN_LENGTH_FAIL: '#password-too-short.password-strength-fail',
NOT_COMMON_FAIL: '#password-too-common.password-strength-fail',
NOT_COMMON_UNMET: '#password-too-common.password-strength-unmet',
NOT_COMMON_MET: '#password-too-common.password-strength-met',
NOT_EMAIL_UNMET: '#password-same-as-email.password-strength-unmet',
NOT_EMAIL_MET: '#password-same-as-email.password-strength-met',
NOT_EMAIL_FAIL: '#password-same-as-email.password-strength-fail',
};
get emailHeader() {
@ -108,6 +124,54 @@ export class LoginPage extends BaseLayout {
}
}
async minLengthFailError() {
const error = this.page.locator(this.selectors.MIN_LENGTH_FAIL);
await error.waitFor({ state: 'visible' });
return error.isVisible();
}
async minLengthSuccess() {
const error = this.page.locator(this.selectors.MIN_LENGTH_MET);
await error.waitFor({ state: 'visible' });
return error.isVisible();
}
async notEmailUnmetError() {
const error = this.page.locator(this.selectors.NOT_EMAIL_UNMET);
await error.waitFor({ state: 'visible' });
return error.isVisible();
}
async notEmailFailError() {
const error = this.page.locator(this.selectors.NOT_EMAIL_FAIL);
await error.waitFor({ state: 'visible' });
return error.isVisible();
}
async notEmailSuccess() {
const error = this.page.locator(this.selectors.NOT_EMAIL_MET);
await error.waitFor({ state: 'visible' });
return error.isVisible();
}
async notCommonPasswordUnmetError() {
const error = this.page.locator(this.selectors.NOT_COMMON_UNMET);
await error.waitFor({ state: 'visible' });
return error.isVisible();
}
async notCommonPasswordSuccess() {
const error = this.page.locator(this.selectors.NOT_COMMON_MET);
await error.waitFor({ state: 'visible' });
return error.isVisible();
}
async notCommonPasswordFailError() {
const error = this.page.locator(this.selectors.NOT_COMMON_FAIL);
await error.waitFor({ state: 'visible' });
return error.isVisible();
}
async fillOutFirstSignUp(
email: string,
password: string,

Просмотреть файл

@ -57,3 +57,73 @@ test.describe('severity-1 #smoke', () => {
expect(status).toEqual('Not Set');
});
});
test.describe('password strength tests', () => {
test.beforeEach(async ({ target, credentials, page, pages: { login } }) => {
const email = login.createEmail();
await page.goto(target.contentServerUrl, { waitUntil: 'networkidle' });
credentials.email = email;
//Enter email at email first and then goto the sign up page
await login.setEmail(credentials.email);
await login.submit();
});
test('test different password errors and success', async ({
credentials,
pages: { login },
}) => {
//Submit without providing a password
await login.submitButton.click();
//Verify the error
expect(await login.minLengthFailError()).toBe(true);
expect(await login.notEmailUnmetError()).toBe(true);
expect(await login.notCommonPasswordUnmetError()).toBe(true);
//Submit a short password
await login.setPassword('p');
await login.submitButton.click();
//Verify the error
expect(await login.minLengthFailError()).toBe(true);
expect(await login.notEmailUnmetError()).toBe(true);
expect(await login.notCommonPasswordUnmetError()).toBe(true);
//Submit a common password
await login.setPassword('password');
await login.submitButton.click();
//Verify the error
expect(await login.minLengthSuccess()).toBe(true);
expect(await login.notEmailSuccess()).toBe(true);
expect(await login.notCommonPasswordFailError()).toBe(true);
//Submit password same as email
await login.setPassword(credentials.email);
await login.submitButton.click();
//Verify the error
expect(await login.minLengthSuccess()).toBe(true);
expect(await login.notEmailFailError()).toBe(true);
expect(await login.notCommonPasswordUnmetError()).toBe(true);
//Submit password same as local part of email
const newEmail = credentials.email.split('@')[0];
await login.setPassword(newEmail);
await login.submitButton.click();
//Verify the error
expect(await login.minLengthSuccess()).toBe(true);
expect(await login.notEmailFailError()).toBe(true);
expect(await login.notCommonPasswordUnmetError()).toBe(true);
//Submit a common password
await login.setPassword('password123123');
//Verify the success message
expect(await login.minLengthSuccess()).toBe(true);
expect(await login.notEmailSuccess()).toBe(true);
expect(await login.notCommonPasswordSuccess()).toBe(true);
});
});