2024-07-31 15:10:58 +02:00
|
|
|
|
|
|
|
import { ElectronApplication, expect, Locator, Page } from '@playwright/test';
|
|
|
|
import MainScreen from './MainScreen';
|
|
|
|
import activateMainMenuItem from '../util/activateMainMenuItem';
|
|
|
|
|
|
|
|
export default class GoToAnything {
|
|
|
|
public readonly containerLocator: Locator;
|
|
|
|
public readonly inputLocator: Locator;
|
|
|
|
|
|
|
|
public constructor(page: Page, private readonly mainScreen: MainScreen) {
|
|
|
|
this.containerLocator = page.locator('.go-to-anything-dialog[open]');
|
|
|
|
this.inputLocator = this.containerLocator.getByRole('textbox');
|
|
|
|
}
|
|
|
|
|
|
|
|
public async open(electronApp: ElectronApplication) {
|
|
|
|
await this.mainScreen.waitFor();
|
2024-09-04 13:14:12 +02:00
|
|
|
await activateMainMenuItem(electronApp, 'Goto Anything...');
|
2024-07-31 15:10:58 +02:00
|
|
|
|
|
|
|
return this.waitFor();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async waitFor() {
|
|
|
|
await this.containerLocator.waitFor();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async expectToBeClosed() {
|
|
|
|
await expect(this.containerLocator).not.toBeAttached();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async expectToBeOpen() {
|
|
|
|
await expect(this.containerLocator).toBeAttached();
|
|
|
|
}
|
2024-09-26 12:35:32 +02:00
|
|
|
|
|
|
|
public async runCommand(electronApp: ElectronApplication, command: string) {
|
|
|
|
if (!command.startsWith(':')) {
|
|
|
|
command = `:${command}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.open(electronApp);
|
|
|
|
await this.inputLocator.fill(command);
|
|
|
|
await this.containerLocator.locator('.match-highlight').first().waitFor();
|
|
|
|
await this.inputLocator.press('Enter');
|
|
|
|
await this.expectToBeClosed();
|
|
|
|
}
|
2024-07-31 15:10:58 +02:00
|
|
|
}
|