mirror of
https://codeberg.org/Kankys/doxa.git
synced 2026-11-11 14:44:36 +01:00
new-doxa-monorepo
This commit is contained in:
1 parent
b4401527a3
commit
5eacbb0182
162 files changed
+21820
-2
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { AppPage } from '../pages/AppPage';
|
||||
|
||||
test.describe('DOXA Web App - Core Functionality', () => {
|
||||
let appPage: AppPage;
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
appPage = new AppPage(page);
|
||||
await appPage.navigate();
|
||||
});
|
||||
|
||||
test('Vytvoření, editace a ověření poznámky s tagy', async () => {
|
||||
// 1. Vytvoření nové poznámky
|
||||
const noteName = 'Moje Stoická Poznámka';
|
||||
await appPage.createNewNote(noteName);
|
||||
|
||||
// Ověříme, že se poznámka objevila v seznamu jako aktivní
|
||||
const notes = await appPage.getNoteList();
|
||||
await expect(notes.first()).toContainText(noteName);
|
||||
await expect(notes.first()).toHaveClass(/active/);
|
||||
|
||||
// 2. Editace poznámky a tagů
|
||||
await appPage.fillNote('Dnes odepřena digitální iluze.', 'filozofie, stoicismus');
|
||||
|
||||
// 3. Ověření uložení a zobrazení tagu
|
||||
await expect(notes.first().locator('.note-preview-tags')).toContainText('🏷️ filozofie, stoicismus');
|
||||
});
|
||||
|
||||
test('Slash Commands menu se zobrazí po napsání /', async () => {
|
||||
const noteName = 'Test slash příkazů';
|
||||
await appPage.createNewNote(noteName);
|
||||
|
||||
// Klikneme do editoru a napíšeme "/"
|
||||
await appPage.noteEditor.focus();
|
||||
await appPage.page.keyboard.type('/');
|
||||
|
||||
// Ověříme, že se menu zobrazilo
|
||||
await expect(appPage.slashMenu).toBeVisible();
|
||||
await expect(appPage.slashMenu).toContainText('Vložit dnešní datum');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
export const expectedMenuTexts = [
|
||||
"Domů",
|
||||
"Wiki",
|
||||
"Ochrana soukromí",
|
||||
"O projektu",
|
||||
];
|
||||
@@ -0,0 +1,65 @@
|
||||
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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { HomePage } from '../pages/HomePage';
|
||||
import { expectedMenuTexts } from '../assets/text/textHelpers';
|
||||
|
||||
|
||||
test.describe('DOXA Notes HomePage - POM', () => {
|
||||
let homePage: HomePage;
|
||||
|
||||
// Před každým testem vytvoříme novou instanci stránky
|
||||
test.beforeEach(async ({ page }) => {
|
||||
homePage = new HomePage(page);
|
||||
await homePage.navigate();
|
||||
});
|
||||
|
||||
test.describe('navigate', () => {
|
||||
|
||||
test('check all menu items visibility', async () => {
|
||||
await homePage.checkMenuTexts(expectedMenuTexts);
|
||||
});
|
||||
|
||||
test('navigation to Ochrana soukromí', async () => {
|
||||
await homePage.navigate('privacy.html'); // Naviguje správně podle prostředí
|
||||
await expect(homePage.page).toHaveURL(/\/privacy\.html$/); // Odolné testování URL
|
||||
});
|
||||
|
||||
test('navigation to O projektu', async () => {
|
||||
await homePage.navigate('about.html');
|
||||
await expect(homePage.page).toHaveURL(/\/about\.html$/);
|
||||
});
|
||||
|
||||
|
||||
test('externí odkaz do DOXA app', async ({ page }) => {
|
||||
await homePage.clickExternalLink('.btnHomePage');
|
||||
const newPage = await page.waitForEvent('popup');
|
||||
const newpage = await newPage.waitForLoadState();
|
||||
expect(await newPage.url()).toBe('https://app.doxa-notes.org/');
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
|
||||
test.describe('SEO - Search Engine Optimization', () => {
|
||||
test('check title, meta description and canonical link on home page', async () => {
|
||||
const title = await homePage.getPageTitle();
|
||||
expect(title).toBe('DOXA Notes — Local-First poznámky a minimalistický Markdown editor');
|
||||
|
||||
const desc = await homePage.getMetaDescription();
|
||||
expect(desc).toBe('DOXA Notes je minimalistická, local‑first poznámková aplikace s podporou Markdownu a otevřeným formátem JSON. Absolutní soukromí pro vaše myšlenky.');
|
||||
|
||||
const canonical = await homePage.getCanonical();
|
||||
expect(canonical).toBe('https://doxa-notes.org/index.html');
|
||||
});
|
||||
|
||||
test('check title and canonical link on O projektu page', async ({ page }) => {
|
||||
await homePage.navigate('O projektu');
|
||||
await expect(page).toHaveTitle('O projektu — DOXA Notes');
|
||||
const canonical = await page.locator('link[rel="canonical"]').getAttribute('href');
|
||||
expect(canonical).toBe('https://doxa-notes.org/about.html');
|
||||
});
|
||||
|
||||
test('check title and canonical link on Ochrana soukromí page', async ({ page }) => {
|
||||
await homePage.navigate('privacy.html');
|
||||
await expect(homePage.page).toHaveTitle('Ochrana soukromí — DOXA Notes');
|
||||
const canonical = await page.locator('link[rel="canonical"]').getAttribute('href');
|
||||
expect(canonical).toBe('https://doxa-notes.org/privacy.html');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user