Browse Source

fix(playwright): waitForResponse in ProjectPage

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

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

@ -136,34 +136,33 @@ export class ProjectsPage extends BasePage {
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