多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

// playwright-dev-page.ts
import { expect, Page } from "@playwright/test";
import BasePage from "../Base";
export class ProjectsPage extends BasePage {
constructor(rootPage: Page) {
super(rootPage);
}
get() {
return this.rootPage.locator("html");
}
async selectAndGetProject(projectName: string) {
let project: any;
await Promise.all([
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 === projectName;
if(isRequiredResponse){
project = json;
}
return isRequiredResponse;
}),
this.get().locator(`.ant-table-cell`,{
hasText: projectName
}).click()
]);
return project;
}
async delete({title}: {title: string}) {
await this.get().locator(`[pw-data="delete-project-${title}"]`).click();
await this.rootPage.locator(`button:has-text("Yes")`).click();
}
}