Skip to content

Commit 9e5c692

Browse files
authored
fixed flakey test with comparing titles (#1508)
* fixed flakey test with comparing titles * more await
1 parent 79aaee5 commit 9e5c692

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

special-pages/pages/special-error/integration-tests/special-error.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class SpecialErrorPage {
154154
async showsExpiredPage() {
155155
const { page } = this;
156156

157-
this.showsPageTitle('Warning: This site may be insecure');
157+
await this.showsPageTitle('Warning: This site may be insecure');
158158

159159
await expect(page.getByText('Warning: This site may be insecure', { exact: true })).toBeVisible();
160160
await expect(
@@ -175,14 +175,11 @@ export class SpecialErrorPage {
175175
}
176176

177177
/**
178-
*
179178
* @param {string} pageTitle
180179
*/
181180
async showsPageTitle(pageTitle) {
182181
const { page } = this;
183-
184-
const title = await page.locator('title').textContent();
185-
expect(title).toBe(pageTitle);
182+
await page.waitForFunction((title) => document.title === title, pageTitle, { timeout: 2000 });
186183
}
187184

188185
async showsExpiredPageInPolish() {
@@ -193,7 +190,7 @@ export class SpecialErrorPage {
193190
async showsInvalidPage() {
194191
const { page } = this;
195192

196-
this.showsPageTitle('Warning: This site may be insecure');
193+
await this.showsPageTitle('Warning: This site may be insecure');
197194

198195
await expect(page.getByText('Warning: This site may be insecure', { exact: true })).toBeVisible();
199196
await expect(
@@ -215,7 +212,7 @@ export class SpecialErrorPage {
215212
async showsSelfSignedPage() {
216213
const { page } = this;
217214

218-
this.showsPageTitle('Warning: This site may be insecure');
215+
await this.showsPageTitle('Warning: This site may be insecure');
219216

220217
await expect(page.getByText('Warning: This site may be insecure', { exact: true })).toBeVisible();
221218
await expect(
@@ -237,7 +234,7 @@ export class SpecialErrorPage {
237234
async showsWrongHostPage() {
238235
const { page } = this;
239236

240-
this.showsPageTitle('Warning: This site may be insecure');
237+
await this.showsPageTitle('Warning: This site may be insecure');
241238

242239
await expect(page.getByText('Warning: This site may be insecure', { exact: true })).toBeVisible();
243240
await expect(
@@ -259,8 +256,7 @@ export class SpecialErrorPage {
259256
async showsPhishingPage() {
260257
const { page } = this;
261258

262-
const title = await page.locator('title').textContent();
263-
expect(title).toBe('Warning: Security Risk');
259+
await this.showsPageTitle('Warning: Security Risk');
264260

265261
await expect(page.getByText('Warning: This site may be a security risk', { exact: true })).toBeVisible();
266262
await expect(
@@ -281,8 +277,7 @@ export class SpecialErrorPage {
281277
async showsMalwarePage() {
282278
const { page } = this;
283279

284-
const title = await page.locator('title').textContent();
285-
expect(title).toBe('Warning: Security Risk');
280+
await this.showsPageTitle('Warning: Security Risk');
286281

287282
await expect(page.getByText('Warning: This site may be a security risk', { exact: true })).toBeVisible();
288283
await expect(

0 commit comments

Comments
 (0)