mirror of
https://codeberg.org/Kankys/doxa.git
synced 2026-11-11 14:44:36 +01:00
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { expect, type Locator, type Page } from '@playwright/test';
|
|
|
|
export class HomePage {
|
|
readonly page: Page;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
}
|
|
|
|
// 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('doxa-notes.org') ? '' : 'web/';
|
|
await this.page.goto(`${prefix}${file}`);
|
|
}
|
|
|
|
|
|
// Otestování, zda jsou všechny odkazy v menu viditelné
|
|
async checkMenuTexts(expectedTexts: string[]) {
|
|
for (const text of expectedTexts) {
|
|
const item = this.page.getByText(text, { exact: true });
|
|
await expect(item).toBeVisible();
|
|
}
|
|
}
|
|
|
|
// test externí odkazy
|
|
|
|
async getPageTitle(): Promise<string> {
|
|
return await this.page.title();
|
|
}
|
|
|
|
async getMetaDescription(): Promise<string | null> {
|
|
const meta = this.page.locator('meta[name="description"]');
|
|
return await meta.getAttribute('content');
|
|
}
|
|
|
|
async getCanonical(): Promise<string | null> {
|
|
const link = this.page.locator('link[rel="canonical"]');
|
|
return await link.getAttribute('href');
|
|
}
|
|
|
|
// test kliku na externí odkaz
|
|
async clickExternalLink(text: string) {
|
|
await this.page.locator(text).click();
|
|
|
|
}
|
|
|
|
}
|