Skip to content

Commit a692a94

Browse files
committed
Update typography.spec.js
1 parent 8c1ab43 commit a692a94

1 file changed

Lines changed: 30 additions & 7 deletions

File tree

‎tests/e2e/specs/typography.spec.js‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,26 +169,49 @@ test.describe('typography', () => {
169169
await editor.publishPost();
170170

171171
// Go to published post.
172-
await page
172+
const viewPageButton = page
173173
.locator('.components-button', {
174174
hasText: 'View Page',
175175
})
176-
.first()
177-
.click();
176+
.first();
177+
178+
const viewPageHref = await viewPageButton.getAttribute('href');
179+
180+
let frontendPage = page;
181+
182+
if (viewPageHref) {
183+
await page.goto(viewPageHref);
184+
await page.waitForLoadState('domcontentloaded');
185+
} else {
186+
const popupPromise = page
187+
.waitForEvent('popup', { timeout: 3000 })
188+
.catch(() => null);
189+
190+
await viewPageButton.click();
191+
192+
const popupPage = await popupPromise;
193+
194+
if (popupPage) {
195+
frontendPage = popupPage;
196+
await frontendPage.waitForLoadState('domcontentloaded');
197+
} else {
198+
await page.waitForLoadState('domcontentloaded');
199+
}
200+
}
178201

179202
// Frontend.
180203
// Checking links to Google fonts
181204
await expect(
182-
page.locator('#ghostkit-fonts-google-css')
205+
frontendPage.locator('#ghostkit-fonts-google-css')
183206
).toHaveAttribute('href', googleFontsLinkPredefined);
184207

185-
const paragraph = page.locator('.wp-block-post-content > p');
208+
const paragraph = frontendPage.locator('.wp-block-post-content > p');
186209

187-
const button = page.locator(
210+
const button = frontendPage.locator(
188211
'.wp-block-post-content .ghostkit-button-text'
189212
);
190213

191-
const title = page.locator('#just-a-title');
214+
const title = frontendPage.locator('#just-a-title');
192215

193216
// Check visible blocks on editor.
194217
await expect(paragraph).toBeVisible();

0 commit comments

Comments
 (0)