Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions e2e/helpers/pages/admin/login-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export class LoginPage extends AdminPage {
readonly forgotButton: Locator;
readonly passwordResetSuccessMessage: Locator;

private setupNewUserUrl = 'setup';

constructor(page: Page) {
super(page);
this.pageUrl = '/ghost/#/signin';
Expand All @@ -22,8 +20,6 @@ export class LoginPage extends AdminPage {
};

async signIn(email: string, password: string) {
await this.emailAddressField.waitFor({state: 'visible'});

await this.emailAddressField.fill(email);
await this.passwordField.fill(password);
await this.signInButton.click();
Expand All @@ -40,24 +36,12 @@ export class LoginPage extends AdminPage {
}

async waitForLoginPageAfterUserCreated(): Promise<void> {
let counter = 0;

while (counter < 5) {
await this.goto();

try {
await this.page.waitForURL(
url => !url.href.includes(this.setupNewUserUrl),
{timeout: 1000}
);

break;
} catch (error) {
counter += 1;
if (counter >= 5) {
throw error;
}
}
const response = await this.goto();
if (!response) {
throw new Error('Error going to signin page (no response)');
}
if (!response.ok) {
throw new Error(`Error going to signin page (${response.status})`);
}
}
}
3 changes: 2 additions & 1 deletion e2e/helpers/pages/admin/settings/settings-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export class SettingsPage extends BasePage {
}

async goto() {
await super.goto();
const result = await super.goto();
await this.sidebar.waitFor({state: 'visible'});
return result;
}
}
6 changes: 3 additions & 3 deletions e2e/helpers/pages/base-page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Locator, Page} from '@playwright/test';
import {PageHttpLogger} from './page-http-logger';
import {appConfig} from '@/helpers/utils/app-config';
import type {Locator, Page, Response} from '@playwright/test';

export interface pageGotoOptions {
referer?: string;
Expand Down Expand Up @@ -31,9 +31,9 @@ export class BasePage {
await this.page.reload();
}

async goto(url?: string, options?: pageGotoOptions) {
async goto(url?: string, options?: pageGotoOptions): Promise<null | Response> {
const urlToVisit = url || this.pageUrl;
await this.page.goto(urlToVisit, options);
return await this.page.goto(urlToVisit, options);
}

async pressKey(key: string) {
Expand Down
5 changes: 3 additions & 2 deletions e2e/helpers/pages/public/public-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,19 @@ export class PublicPage extends BasePage {
});
}

async goto(url?: string, options?: pageGotoOptions): Promise<void> {
async goto(url?: string, options?: pageGotoOptions): Promise<null | Response> {
const testInfo = test.info();
let pageHitPromise = null;
if (testInfo.project.name === 'analytics') {
await this.enableAnalyticsRequests();
pageHitPromise = this.pageHitRequestPromise();
}
await this.enableAnalyticsRequests();
await super.goto(url, options);
const result = await super.goto(url, options);
if (pageHitPromise) {
await pageHitPromise;
}
return result;
}

pageHitRequestPromise(): Promise<Response> {
Expand Down
Loading