mirror of
https://codeberg.org/Kankys/doxa.git
synced 2026-11-11 14:44:36 +01:00
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import { Page, Locator, expect } from '@playwright/test';
|
|
|
|
export class AppPage {
|
|
readonly page: Page;
|
|
|
|
|
|
|
|
readonly newNoteButton: Locator;
|
|
readonly noteTitleInput: Locator;
|
|
readonly noteTagsInput: Locator;
|
|
readonly noteEditor: Locator;
|
|
readonly saveButton: Locator;
|
|
readonly notesContainer: Locator;
|
|
readonly searchTagInput: Locator;
|
|
readonly slashMenu: Locator;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
this.newNoteButton = page.locator('#newNoteButton');
|
|
this.noteTitleInput = page.locator('#noteTitle');
|
|
this.noteTagsInput = page.locator('#noteTags');
|
|
this.noteEditor = page.locator('#noteInput');
|
|
this.saveButton = page.getByRole('button', { name: 'Uložit nyní' });
|
|
this.notesContainer = page.locator('#notesContainer');
|
|
this.searchTagInput = page.locator('#searchTagInput');
|
|
this.slashMenu = page.locator('#slashCommandMenu');
|
|
}
|
|
|
|
// Přidej metodu pro navigaci na konkrétní soubor
|
|
async navigate(file: string = 'index.html') {
|
|
// Pokud jsme na lokálu, přidáme složku /web/
|
|
// Pokud jsme na produkci, předpokládáme root /
|
|
const prefix = process.env.BASE_URL?.includes('app.doxa-notes.org') ? '' : 'web_app/';
|
|
await this.page.goto(`${prefix}${file}`);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// async navigate() {
|
|
// await this.page.goto(this.path);
|
|
// }
|
|
|
|
async createNewNote(name: string) {
|
|
// Zachytíme nativní JS prompt
|
|
this.page.once('dialog', async dialog => {
|
|
await dialog.accept(name);
|
|
});
|
|
await this.newNoteButton.click();
|
|
}
|
|
|
|
async fillNote(content: string, tags?: string) {
|
|
await this.noteEditor.fill(content);
|
|
if (tags) {
|
|
await this.noteTagsInput.fill(tags);
|
|
}
|
|
await this.saveButton.click();
|
|
}
|
|
|
|
async getNoteList() {
|
|
return this.notesContainer.locator('.note-item');
|
|
}
|
|
} |