Skip to content

Commit 7f6172c

Browse files
Merge pull request #16478 from mozilla/change-selector-objects
update waitForSelector() to page.locator()
2 parents c3ad606 + 4a448c3 commit 7f6172c

File tree

15 files changed

+45
-49
lines changed

15 files changed

+45
-49
lines changed

packages/functional-tests/pages/cookiesDisabled.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ import { BaseLayout } from './layout';
77
export class CookiesDisabledPage extends BaseLayout {
88
readonly path = 'cookies_disabled';
99

10-
async waitForCookiesDisabledHeader() {
11-
await this.page.waitForSelector('.card-header', {
12-
timeout: 3000,
13-
});
10+
async cookiesDisabledHeader() {
11+
const header = this.page.locator('.card-header');
12+
await header.waitFor();
13+
return header;
1414
}
1515

1616
async clickRetry() {
1717
return this.page.getByRole('button', { name: 'Try again' }).click();
1818
}
1919

2020
async isCookiesDiabledError() {
21-
return this.page
22-
.getByText('Local storage or cookies are still disabled')
23-
.isVisible();
21+
return this.page.getByText('Local storage or cookies are still disabled');
2422
}
2523
}

packages/functional-tests/pages/login.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,12 @@ export class LoginPage extends BaseLayout {
253253
return header.isVisible();
254254
}
255255

256-
async waitForSignUpCodeHeader() {
257-
await this.page.waitForSelector(selectors.SIGN_UP_CODE_HEADER, {
258-
timeout: 3000,
259-
});
256+
signUpCodeHeader() {
257+
return this.page.locator(selectors.SIGN_UP_CODE_HEADER);
260258
}
261259

262-
async waitForSignInCodeHeader() {
263-
await this.page.waitForSelector(selectors.SIGN_IN_CODE_HEADER, {
264-
timeout: 2000,
265-
});
260+
signInCodeHeader() {
261+
return this.page.locator(selectors.SIGN_IN_CODE_HEADER);
266262
}
267263

268264
async confirmEmail() {
@@ -303,10 +299,8 @@ export class LoginPage extends BaseLayout {
303299
return this.page.locator(selectors.PERMISSION_ACCEPT).click();
304300
}
305301

306-
async waitForSigninUnblockHeader() {
307-
await this.page.waitForSelector(selectors.SIGNIN_UNBLOCK_HEADER, {
308-
timeout: 2000,
309-
});
302+
signInUnblockHeader() {
303+
return this.page.locator(selectors.SIGNIN_UNBLOCK_HEADER);
310304
}
311305

312306
async signInError() {
@@ -411,9 +405,9 @@ export class LoginPage extends BaseLayout {
411405
}
412406

413407
async waitForPasswordHeader() {
414-
await this.page.waitForSelector(selectors.PASSWORD_HEADER, {
415-
timeout: 4000,
416-
});
408+
const header = this.page.locator(selectors.PASSWORD_HEADER);
409+
await header.waitFor();
410+
return header;
417411
}
418412

419413
async clickSignIn() {

packages/functional-tests/pages/relier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class RelierPage extends BaseLayout {
7575
}
7676

7777
async promptNoneError() {
78-
await this.page.waitForSelector('.error');
78+
this.page.locator('.error');
7979
return this.page.innerText('.error');
8080
}
8181

packages/functional-tests/tests/misc/cookiesDisabled.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ test.describe('cookies disabled', () => {
2424

2525
//Verify the Cookies disabled header
2626
await page.waitForURL(/\/cookies_disabled/);
27-
await cookiesDisabled.waitForCookiesDisabledHeader();
27+
expect(await cookiesDisabled.cookiesDisabledHeader()).toBeVisible();
2828

2929
//Click retry
3030
await cookiesDisabled.clickRetry();
3131

3232
//Verify the error
33-
expect(await cookiesDisabled.isCookiesDiabledError()).toBe(true);
33+
expect(await cookiesDisabled.isCookiesDiabledError()).toBeVisible();
3434
});
3535

3636
test('synthesize enabling cookies by visiting the enter email page, then cookies_disabled, then clicking "try again', async ({
@@ -56,7 +56,7 @@ test.describe('cookies disabled', () => {
5656

5757
//Verify the Cookies disabled header
5858
await page.waitForURL(/\/cookies_disabled/);
59-
await cookiesDisabled.waitForCookiesDisabledHeader();
59+
expect(await cookiesDisabled.cookiesDisabledHeader()).toBeVisible();
6060

6161
//Click retry
6262
await cookiesDisabled.clickRetry();
@@ -84,6 +84,6 @@ test.describe('cookies disabled', () => {
8484
await page.waitForTimeout(500);
8585

8686
//Verify the Cookies disabled header
87-
await cookiesDisabled.waitForCookiesDisabledHeader();
87+
expect(await cookiesDisabled.cookiesDisabledHeader()).toBeVisible();
8888
});
8989
});

packages/functional-tests/tests/oauth/oauthPermissions.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test.describe('severity-1 #smoke', () => {
3535
await login.fillOutFirstSignUp(email, password, { verify: false });
3636

3737
//no permissions asked for, straight to confirm
38-
await login.waitForSignUpCodeHeader();
38+
expect(login.signUpCodeHeader()).toBeVisible();
3939
});
4040

4141
test('signup with `prompt=consent`', async ({
@@ -56,7 +56,7 @@ test.describe('severity-1 #smoke', () => {
5656
await login.acceptOauthPermissions();
5757

5858
//Verify sign up code header
59-
await login.waitForSignUpCodeHeader();
59+
expect(login.signUpCodeHeader()).toBeVisible();
6060
});
6161
});
6262

packages/functional-tests/tests/oauth/oauthPromptNone.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ test.describe('severity-1 #smoke', () => {
119119
target,
120120
pages: { relier, login },
121121
}) => {
122+
test.fixme(true, 'test to be fixed, see FXA-9194');
122123
await target.auth.signUp(email, password, {
123124
lang: 'en',
124125
preVerified: 'false',
@@ -129,7 +130,7 @@ test.describe('severity-1 #smoke', () => {
129130
await login.fillOutEmailFirstSignIn(email, password);
130131

131132
//Verify sign up code header
132-
await login.waitForSignUpCodeHeader();
133+
expect(login.signUpCodeHeader()).toBeVisible();
133134

134135
const query = new URLSearchParams({
135136
login_hint: email,

packages/functional-tests/tests/oauth/signUp.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ test.describe('severity-1 #smoke', () => {
3939
await login.fillOutFirstSignUp(email, password, { verify: false });
4040

4141
//Verify sign up code header
42-
await login.waitForSignUpCodeHeader();
42+
expect(login.signUpCodeHeader()).toBeVisible();
4343

4444
await login.fillOutSignUpCode(email);
4545

@@ -58,7 +58,7 @@ test.describe('severity-1 #smoke', () => {
5858
await login.fillOutFirstSignUp(bouncedEmail, password, { verify: false });
5959

6060
//Verify sign up code header
61-
await login.waitForSignUpCodeHeader();
61+
expect(login.signUpCodeHeader()).toBeVisible();
6262
await client.accountDestroy(bouncedEmail, password);
6363

6464
//Verify error message
@@ -71,7 +71,7 @@ test.describe('severity-1 #smoke', () => {
7171
await login.fillOutFirstSignUp(email, password, { verify: false });
7272

7373
//Verify sign up code header
74-
await login.waitForSignUpCodeHeader();
74+
expect(login.signUpCodeHeader()).toBeVisible();
7575
await login.fillOutSignUpCode(email);
7676

7777
//Verify logged in on relier page

packages/functional-tests/tests/signUp/signUp.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test.describe('severity-2 #smoke', () => {
4747
});
4848

4949
// Verify the confirm code header and the email
50-
await login.waitForSignUpCodeHeader();
50+
expect(login.signUpCodeHeader()).toBeVisible();
5151
expect(await login.confirmEmail()).toContain(emailWithoutSpace);
5252

5353
// Need to clear the cache to get the new email
@@ -60,7 +60,7 @@ test.describe('severity-2 #smoke', () => {
6060
await login.fillOutFirstSignUp(emailWithSpace, password, {
6161
verify: false,
6262
});
63-
await login.waitForSignUpCodeHeader();
63+
expect(login.signUpCodeHeader()).toBeVisible();
6464
expect(await login.confirmEmail()).toContain(emailWithoutSpace);
6565
});
6666

packages/functional-tests/tests/signin/signIn.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ test.describe('severity-2 #smoke', () => {
121121
await login.fillOutEmailFirstSignIn(email, password);
122122

123123
// Verify the header after login
124-
await login.waitForSignInCodeHeader();
124+
expect(login.signInCodeHeader()).toBeVisible();
125125
await target.auth.accountDestroy(email, password);
126126
await page.waitForURL(/signin_bounced/);
127127

packages/functional-tests/tests/signin/signinBlocked.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test.describe('severity-2 #smoke', () => {
5353
await login.fillOutEmailFirstSignIn(blockedEmail, password);
5454

5555
//Verify sign in block header
56-
await login.waitForSigninUnblockHeader();
56+
expect(login.signInUnblockHeader()).toBeVisible();
5757
expect(await login.getUnblockEmail()).toContain(blockedEmail);
5858

5959
//Unblock the email
@@ -74,7 +74,7 @@ test.describe('severity-2 #smoke', () => {
7474
await login.fillOutEmailFirstSignIn(blockedEmail, password);
7575

7676
//Verify sign in block header
77-
await login.waitForSigninUnblockHeader();
77+
expect(login.signInUnblockHeader()).toBeVisible();
7878
expect(await login.getUnblockEmail()).toContain(blockedEmail);
7979
await login.enterUnblockCode('incorrect');
8080

@@ -101,7 +101,7 @@ test.describe('severity-2 #smoke', () => {
101101
await login.fillOutEmailFirstSignIn(blockedEmail, password);
102102

103103
//Verify sign in block header
104-
await login.waitForSigninUnblockHeader();
104+
expect(login.signInUnblockHeader()).toBeVisible();
105105
expect(await login.getUnblockEmail()).toContain(blockedEmail);
106106

107107
//Click resend link
@@ -144,7 +144,7 @@ test.describe('severity-2 #smoke', () => {
144144
await login.fillOutEmailFirstSignIn(newEmail, password);
145145

146146
//Verify sign in block header
147-
await login.waitForSigninUnblockHeader();
147+
expect(login.signInUnblockHeader()).toBeVisible();
148148
expect(await login.getUnblockEmail()).toContain(newEmail);
149149

150150
//Unblock the email
@@ -161,14 +161,14 @@ test.describe('severity-2 #smoke', () => {
161161
await login.fillOutEmailFirstSignIn(unverifiedEmail, password);
162162

163163
//Verify sign in block header
164-
await login.waitForSigninUnblockHeader();
164+
expect(login.signInUnblockHeader()).toBeVisible();
165165
expect(await login.getUnblockEmail()).toContain(unverifiedEmail);
166166

167167
//Unblock the email
168168
await login.unblock(unverifiedEmail);
169169

170170
//Verify confirm code header
171-
await login.waitForSignUpCodeHeader();
171+
expect(login.signUpCodeHeader()).toBeVisible();
172172

173173
await login.fillOutSignInCode(unverifiedEmail);
174174

0 commit comments

Comments
 (0)