Browse Source

fix(playwright): waitForResponse in ProjectPage

pull/5903/head
Wing-Kam Wong 1 year ago
parent
commit
f9568866d0
  1. 47
      tests/playwright/pages/ProjectsPage/index.ts

47
tests/playwright/pages/ProjectsPage/index.ts

@ -135,35 +135,34 @@ export class ProjectsPage extends BasePage {
if (!withoutPrefix) title = this.prefixTitle(title); if (!withoutPrefix) title = this.prefixTitle(title);
let project: any; let project: any;
const openProjectUiAction = this.get() const responsePromise = this.rootPage.waitForResponse(async res => {
let json: any = {};
try {
json = await res.json();
} catch (e) {
return false;
}
const isRequiredResponse =
res.request().url().includes('/api/v1/db/meta/projects') &&
['GET'].includes(res.request().method()) &&
json?.title === title;
if (isRequiredResponse) {
project = json;
}
return isRequiredResponse;
})
await this.get()
.locator(`.ant-table-cell`, { .locator(`.ant-table-cell`, {
hasText: title, hasText: title,
}) })
.click(); .click();
await Promise.all([ await responsePromise
this.rootPage.waitForResponse(async res => {
let json: any = {};
try {
json = await res.json();
} catch (e) {
return false;
}
const isRequiredResponse =
res.request().url().includes('/api/v1/db/meta/projects') &&
['GET'].includes(res.request().method()) &&
json?.title === title;
if (isRequiredResponse) {
project = json;
}
return isRequiredResponse;
}),
openProjectUiAction,
]);
const dashboard = new DashboardPage(this.rootPage, project); const dashboard = new DashboardPage(this.rootPage, project);

Loading…
Cancel
Save