Files
2026-08-07 09:48:59 +02:00

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');
}
}