1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-desktop/integration-tests/models/NoteList.ts

39 lines
1.2 KiB
TypeScript

import activateMainMenuItem from '../util/activateMainMenuItem';
import { ElectronApplication, Locator, Page, expect } from '@playwright/test';
export default class NoteList {
public readonly container: Locator;
public constructor(page: Page) {
this.container = page.locator('.rli-noteList');
}
public waitFor() {
return this.container.waitFor();
}
private async sortBy(electronApp: ElectronApplication, sortMethod: string) {
const success = await activateMainMenuItem(electronApp, sortMethod, 'Sort notes by');
if (!success) {
throw new Error(`Unable to find sorting menu item: ${sortMethod}`);
}
}
public async sortByTitle(electronApp: ElectronApplication) {
return this.sortBy(electronApp, 'Title');
}
public async focusContent(electronApp: ElectronApplication) {
await activateMainMenuItem(electronApp, 'Note list', 'Focus');
}
// The resultant locator may fail to resolve if the item is not visible
public getNoteItemByTitle(title: string|RegExp) {
return this.container.getByRole('option', { name: title });
}
public async expectNoteToBeSelected(title: string|RegExp) {
await expect(this.getNoteItemByTitle(title)).toHaveAttribute('aria-selected', 'true');
}
}