fix(functional-tests): Fix oauth signin token code tests

Because:

* Oauth signin token code tests were failing on the step to fill the input

This commit:

* Add a more specific locator for the input on the signin token code page
* Split the test into 3 tests for better compartimentalizarion: valid code, invalid code and resend code
* Remove fixme annotation

Closes #FXA-9931
This commit is contained in:
Valerie Pomerleau 2024-06-25 10:27:30 -07:00
Родитель 632c038af9
Коммит 7bcc45cefb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 33A451F0BB2180B4
2 изменённых файлов: 57 добавлений и 17 удалений

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

@ -12,6 +12,13 @@ export class SigninTokenCodePage extends BaseTokenCodePage {
return this.page.getByRole('heading', { name: /^Enter confirmation code/ });
}
get codeInput() {
this.checkPath();
return this.page
.getByLabel('Enter 6-digit code') // React
.or(this.page.getByPlaceholder('Enter 6-digit code')); //Backbone
}
get resendCodeButton() {
this.checkPath();
return (

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

@ -41,13 +41,12 @@ test.describe('severity-2 #smoke', () => {
const credentials = await testAccountTracker.signUpSync();
await relier.goto(toQueryString(queryParameters));
// Click the Email First flow, which should direct to the sign in page
await relier.clickEmailFirst();
// Enter email, then enter password
await signin.fillOutEmailFirstForm(credentials.email);
await signin.fillOutPasswordForm(credentials.password);
// Check that the sign in page is show, and is asking for a sign in code
await expect(page).toHaveURL(/signin_token_code/);
await expect(signinTokenCode.heading).toBeVisible();
@ -65,29 +64,15 @@ test.describe('severity-2 #smoke', () => {
pages: { page, signin, relier, signinTokenCode },
testAccountTracker,
}) => {
test.fixme(true, 'TODO in FXA-9931');
// The `sync` prefix is needed to force confirmation.
const credentials = await testAccountTracker.signUpSync();
await relier.goto(toQueryString(queryParameters));
// Click the Email First flow, which should direct to the sign in page
await relier.clickEmailFirst();
// Enter email, then enter password
await signin.fillOutEmailFirstForm(credentials.email);
await signin.fillOutPasswordForm(credentials.password);
// Enter invalid code, ensure it doesn't work
await expect(page).toHaveURL(/signin_token_code/);
await signinTokenCode.fillOutCodeForm('123456');
await expect(page.getByText(/Invalid or expired/)).toBeVisible();
// Resend the code
await expect(signinTokenCode.resendCodeButton).toBeVisible();
await signinTokenCode.resendCodeButton.click();
await expect(page.getByText(/Email re-?sent/)).toBeVisible();
// Correctly submits the token code and navigates to oauth page
const code = await target.emailClient.getVerifyLoginCode(
credentials.email
);
@ -95,5 +80,53 @@ test.describe('severity-2 #smoke', () => {
await expect(page).toHaveURL(/notes\/fxa/);
});
test('verified - invalid code', async ({
pages: { page, signin, relier, signinTokenCode },
testAccountTracker,
}) => {
// The `sync` prefix is needed to force confirmation.
const credentials = await testAccountTracker.signUpSync();
await relier.goto(toQueryString(queryParameters));
await relier.clickEmailFirst();
await signin.fillOutEmailFirstForm(credentials.email);
await signin.fillOutPasswordForm(credentials.password);
// Enter invalid code, ensure it doesn't work
await expect(page).toHaveURL(/signin_token_code/);
await signinTokenCode.fillOutCodeForm('123456');
await expect(page.getByText(/Invalid or expired/)).toBeVisible();
});
test('verified - resend code', async ({
target,
pages: { page, signin, relier, signinTokenCode },
testAccountTracker,
}) => {
// The `sync` prefix is needed to force confirmation.
const credentials = await testAccountTracker.signUpSync();
await relier.goto(toQueryString(queryParameters));
await relier.clickEmailFirst();
await signin.fillOutEmailFirstForm(credentials.email);
await signin.fillOutPasswordForm(credentials.password);
await expect(page).toHaveURL(/signin_token_code/);
// retrieve the first code and delete the email
let code = await target.emailClient.getVerifyLoginCode(credentials.email);
await expect(signinTokenCode.resendCodeButton).toBeVisible();
await signinTokenCode.resendCodeButton.click();
await expect(page.getByText(/Email re-?sent/)).toBeVisible();
// Retrieves the code from the new email
code = await target.emailClient.getVerifyLoginCode(credentials.email);
await signinTokenCode.fillOutCodeForm(code);
await expect(page).toHaveURL(/notes\/fxa/);
});
});
});