mirror of
https://github.com/baserow/baserow.git
synced 2026-12-06 17:28:38 +00:00
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { Locator, Response, expect } from "@playwright/test";
|
|
import { BaserowPage, PageConfig } from "../baserowPage";
|
|
import { Agent } from "../../fixtures/agent/agent";
|
|
|
|
export class AgentPage extends BaserowPage {
|
|
readonly agent: Agent;
|
|
readonly configuration: Locator;
|
|
|
|
constructor(pageConfig: PageConfig, agent: Agent) {
|
|
super(pageConfig);
|
|
this.agent = agent;
|
|
this.configuration = this.page.locator(".agent-configuration");
|
|
}
|
|
|
|
getFullUrl() {
|
|
return `${this.baseUrl}/agent/${this.agent.id}`;
|
|
}
|
|
|
|
// The sidebar is open by default; the chosen section renders inside the form.
|
|
async openSection(name: string): Promise<Locator> {
|
|
await this.configuration.getByRole("menuitem", { name }).click();
|
|
await expect(
|
|
this.configuration.getByRole("heading", { name, level: 2 })
|
|
).toBeVisible();
|
|
return this.configuration.locator(".agent-configuration__body");
|
|
}
|
|
|
|
// The request predicate tells a debounced save apart from an earlier one.
|
|
waitForTriggerResponse(
|
|
method: string,
|
|
matches: (requestBody: any) => boolean = () => true
|
|
): Promise<Response> {
|
|
const prefix = `/api/agent/${this.agent.id}/triggers/`;
|
|
return this.page.waitForResponse(
|
|
(response) =>
|
|
response.request().method() === method &&
|
|
response.url().includes(prefix) &&
|
|
matches(response.request().postDataJSON())
|
|
);
|
|
}
|
|
}
|