Convert spotlight tests to playwright (#12033)

* Convert tests

* Use existing code

* Remove code from settings

* Change names

* Change comment

* Update comment
This commit is contained in:
R Midhun Suresh 2023-12-18 11:34:15 +05:30 committed by GitHub
parent 7508e62eda
commit d1562befc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 408 additions and 460 deletions

View file

@ -28,8 +28,13 @@ export class Spotlight {
constructor(private page: Page) {}
public async open() {
await this.page.keyboard.press(`${CommandOrControl}+KeyK`);
this.root = this.page.locator('[role=dialog][aria-label="Search Dialog"]');
const isSpotlightAlreadyOpen = !!(await this.root.count());
if (isSpotlightAlreadyOpen) {
// Close dialog if it is already open
await this.page.keyboard.press(`${CommandOrControl}+KeyK`);
}
await this.page.keyboard.press(`${CommandOrControl}+KeyK`);
}
public async filter(filter: Filter) {
@ -49,10 +54,18 @@ export class Spotlight {
}
public async search(query: string) {
await this.root.locator(".mx_SpotlightDialog_searchBox").getByRole("textbox", { name: "Search" }).fill(query);
await this.searchBox.getByRole("textbox", { name: "Search" }).fill(query);
}
public get searchBox() {
return this.root.locator(".mx_SpotlightDialog_searchBox");
}
public get results() {
return this.root.locator(".mx_SpotlightDialog_section.mx_SpotlightDialog_results .mx_SpotlightDialog_option");
}
public get dialog() {
return this.root;
}
}