Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid login issue in deployment E2E tests #2065

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from
36 changes: 32 additions & 4 deletions packages/playground/website/playwright/e2e/deployment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@ import { test, expect } from '../playground-fixtures.ts';
import { startVersionSwitchingServer as startServer } from '../version-switching-server.ts';

const port = 7999;
const url = `http://localhost:${port}`;
const blueprint = {
steps: [
{
step: 'setSiteOptions',
options: {
// Set the admin email lifespan to the maximum value to prevent
// the admin email from expiring and causing the login step to fail.
// https://github.com/WordPress/wordpress-develop/blob/f008049c49195dbfa954631fecc7fbfff0cc8ca2/src/wp-login.php#L1379-L1388
admin_email_lifespan: '2147483647',
},
},
{
step: 'login',
username: 'admin',
password: 'password',
},
],
};
const url = new URL(`http://localhost:${port}`);
// TODO: Say why
url.searchParams.set(
'blueprint-url',
`data:application/json;base64,${btoa(JSON.stringify(blueprint))}`
);

const maxDiffPixels = 4000;

Expand Down Expand Up @@ -50,14 +73,17 @@ for (const cachingEnabled of [true, false]) {
})`, async ({ website, page, wordpress }) => {
server!.setHttpCacheEnabled(cachingEnabled);

await page.goto(url);
await page.goto(url.href);
await website.waitForNestedIframes();
await expect(page).toHaveScreenshot('website-old.png', {
maxDiffPixels,
});

server!.switchToNewVersion();
await page.goto(url);
// Reload the page instead of navigating to the URL again
// because it didn't seem to actually cause a reload when
// navigating to the same URL containing a hash component.
await page.reload();
await website.waitForNestedIframes();
await expect(
website.page.getByLabel('Open Site Manager')
Expand All @@ -79,7 +105,9 @@ test.skip(
server!.setHttpCacheEnabled(true);
server!.switchToMidVersion();

await page.goto(`${url}/?wp=6.5`);
const urlWithWordPress65 = new URL(url);
urlWithWordPress65.searchParams.append('wp', '6.5');
await page.goto(urlWithWordPress65.href);
await website.waitForNestedIframes();

// Switching to the new app version does not trigger a page reload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const playwrightConfig: PlaywrightTestConfig = {
trace: 'on-first-retry',
actionTimeout: 120000,
navigationTimeout: 120000,
screenshot: 'only-on-failure',
},

timeout: 300000,
Expand Down
7 changes: 7 additions & 0 deletions packages/playground/website/playwright/website-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export class WebsitePage {
return response;
}

async reload(options?: any) {
const originalReload = this.page.reload.bind(this.page);
const response = await originalReload(options);
await this.waitForNestedIframes();
return response;
}

async ensureSiteManagerIsOpen() {
const siteManagerHeading = this.page.locator('.main-sidebar');
if (await siteManagerHeading.isHidden({ timeout: 5000 })) {
Expand Down
Loading