mirror of
https://codeberg.org/Kankys/eos.git
synced 2026-11-11 06:54:36 +01:00
sloučení
This commit is contained in:
1 parent
53ab611702
commit
4dfb1dacbf
388 files changed
+19439
No files matched your search
@@ -0,0 +1,16 @@
|
||||
name: Playwright Tests
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest # Runner musí mít tento label
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Install Playwright Browsers
|
||||
run: npx playwright install
|
||||
- name: Run Playwright tests
|
||||
run: npx playwright test --project=chromium --project=firefox
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
# Playwright
|
||||
node_modules/
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
||||
/playwright/.auth/
|
||||
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Kankys
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,3 @@
|
||||
## Automatizované testy pro web České komunity EndeavourOS
|
||||
frmework - playwright
|
||||
|
||||
Generated
+97
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"name": "eos_automationtest",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "eos_automationtest",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.59.1",
|
||||
"@types/node": "^25.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.1.tgz",
|
||||
"integrity": "sha512-PG6q63nQg5c9rIi4/Z5lR5IVF7yU5MqmKaPOe0HSc0O2cX1fPi96sUQu5j7eo4gKCkB2AnNGoWt7y4/Xx3Kcqg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.59.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "25.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.6.0.tgz",
|
||||
"integrity": "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~7.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.59.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.1.tgz",
|
||||
"integrity": "sha512-C8oWjPR3F81yljW9o5OxcWzfh6avkVwDD2VYdwIGqTkl+OGFISgypqzfu7dOe4QNLL2aqcWBmI3PMtLIK233lw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.59.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.59.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.1.tgz",
|
||||
"integrity": "sha512-HBV/RJg81z5BiiZ9yPzIiClYV/QMsDCKUyogwH9p3MCP6IYjUFu/MActgYAvK0oWyV9NlwM3GLBjADyWgydVyg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.19.2",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.19.2.tgz",
|
||||
"integrity": "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "eos_automationtest",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/Kankys/eos_automationTest.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "commonjs",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.59.1",
|
||||
"@types/node": "^25.6.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// import dotenv from 'dotenv';
|
||||
// import path from 'path';
|
||||
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: './tests',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: !!process.env.CI,
|
||||
/* Retry on CI only */
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: 'html',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('')`. */
|
||||
// baseURL: 'http://localhost:3000',
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry',
|
||||
screenshot: 'only-on-failure',
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
},
|
||||
|
||||
{
|
||||
name: 'firefox',
|
||||
use: { ...devices['Desktop Firefox'] },
|
||||
},
|
||||
/*
|
||||
{
|
||||
name: 'webkit',
|
||||
use: { ...devices['Desktop Safari'] },
|
||||
},*/
|
||||
|
||||
|
||||
/* Test against mobile viewports. */
|
||||
// {
|
||||
// name: 'Mobile Chrome',
|
||||
// use: { ...devices['Pixel 5'] },
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: { ...devices['iPhone 12'] },
|
||||
// },
|
||||
|
||||
/* Test against branded browsers. */
|
||||
// {
|
||||
// name: 'Microsoft Edge',
|
||||
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||
// },
|
||||
// {
|
||||
// name: 'Google Chrome',
|
||||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||
// },
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
// webServer: {
|
||||
// command: 'npm run start',
|
||||
// url: 'http://localhost:3000',
|
||||
// reuseExistingServer: !process.env.CI,
|
||||
// },
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
id -> #
|
||||
|
||||
class -> .
|
||||
|
||||
|
||||
**Code:**
|
||||
|
||||
- theme:
|
||||
|
||||
```
|
||||
test('přepínač na stránce změní režim na světlý', async ({ page }) => {
|
||||
await page.goto('https://tvuj-web.cz');
|
||||
|
||||
// 1. Najdi a klikni na přepínač režimu
|
||||
const themeButton = page.locator('#theme-switcher');
|
||||
await themeButton.click();
|
||||
|
||||
// 2. Ověř, že se na elementu <html> nebo <body> objevila správná třída
|
||||
// Mnoho webů používá třídu .light-mode nebo atribut data-theme
|
||||
await expect(page.locator('html')).toHaveAttribute('data-theme', 'light');
|
||||
|
||||
// 3. Nebo ověř konkrétní barvu prvku
|
||||
const header = page.locator('header');
|
||||
await expect(header).toHaveCSS('color', 'rgb(0, 0, 0)'); // Černý text ve světlém režimu
|
||||
});
|
||||
```
|
||||
**TODO:**
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Pro všechny obrazovky
|
||||
*/
|
||||
|
||||
// Očekávané texty v menu
|
||||
export const expectedMenuTexts = [
|
||||
"Domů",
|
||||
"EndeavourOS",
|
||||
"Články",
|
||||
"Krátké návody",
|
||||
"Fórum",
|
||||
"O nás"
|
||||
];
|
||||
|
||||
export const expectedSearchPlaceholder = "Hledat v článcích..";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Pouze pro HomePage
|
||||
*/
|
||||
export const expectedMainHeading = "🇨🇿 Vítám Tě na webu České komunity EndeavourOS! 🇨🇿";
|
||||
// Texty HomePage
|
||||
export const expectedHalloText = "Lehká, rychlá a moderní distribuce založená na Arch Linuxu. Je navržena tak, aby poskytovala uživatelům přístup k nejnovějším technologiím a softwaru, přičemž zachovává jednoduchost a stabilitu. Distribuce nabízí několik předinstalovaných prostředí."
|
||||
export const expectedHeroToHaveText =
|
||||
"🇨🇿 Vítám Tě na webu České komunity EndeavourOS! 🇨🇿 Lehká, rychlá a moderní distribuce založená na Arch Linuxu."
|
||||
;
|
||||
export const expectedHalloToHaveText1 = "Lehká, rychlá a moderní distribuce založená na Arch Linuxu.";
|
||||
export const expectedHalloToHaveText2 = "Je navržena tak, aby poskytovala uživatelům přístup k nejnovějším technologiím a softwaru, přičemž zachovává jednoduchost a stabilitu. Distribuce nabízí několik předinstalovaných prostředí.";
|
||||
|
||||
// Karty na HomePage
|
||||
export const homePageCards = [
|
||||
{
|
||||
title: "🚀 Přecházíme na Linux: Kompletní průvodce světem EndeavourOS a GNOME",
|
||||
description: "Máte pocit, že váš počítač s Windows je čím dál pomalejší? Štve vás, že si systém dělá, co chce, a vy nad ním nemáte kon..."
|
||||
},
|
||||
{
|
||||
title: "⛵ Co je to ten Linux, EndeavourOS a GNOME? Malý slovníček pro úplné začátečníky",
|
||||
description: "Rozhodli jste se zkusit Linux, ale točí se vám hlava z názvů jako distribuce, prostředí, balíčky nebo AUR? Nebojte se. Ve světě Windows..."
|
||||
},
|
||||
{
|
||||
title: "🚀 Jak oživit počítač moderním systémem: Instalujeme EndeavourOS s GNOME",
|
||||
description: "Láká vás svět Linuxu, konkrétně pověstná rychlost a aktuálnost Arch Linuxu, ale odrazuje vás složitá instalace přes č..."
|
||||
},
|
||||
{
|
||||
title: "🔥 Záchranná brzda pro váš systém: Co je to LTS jádro a proč ho mít nainstalované",
|
||||
description: "Užíváte si rychlost EndeavourOS? Skvělé. Ale co když jednoho dne po aktualizaci zapnete počítač a nenaběhne grafika, nebo přesta..."
|
||||
},
|
||||
{
|
||||
title: "💽 Jak připojit nový SSD disk v EndeavourOS",
|
||||
description: "Určíme přidaný disk (dle názvu či velikosti), v mém případě ..."
|
||||
},
|
||||
{
|
||||
title: "🧰 Jak lehce instalovat aplikace pomocí grafického správce Pamac",
|
||||
description: "Jak lehce instalovat aplikace pomocí grafického správce Pamac..."
|
||||
},
|
||||
{
|
||||
title: "💾 AUR packages a jak nainstalovat aplikaci pomocí YAY",
|
||||
description: "EndeavourOS jako všechny ostatní distribuce rodiny Arch Linuxnabízí obří seznam balíčků..."
|
||||
},
|
||||
{
|
||||
title: "🚨 Jak zapnout upozornění na nové aktualizace",
|
||||
description: "Jak zapnout upozornění na nové aktualizace..."
|
||||
},
|
||||
{
|
||||
title: "🐧 Linux pacman příkazy",
|
||||
description: "Linux pacman příkazy. Pacman je nedílnou součástí Arch Linuxu a distribucí na Arc..."
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Nezařazené
|
||||
*/
|
||||
|
||||
// externí liky
|
||||
export const externalLinks = [
|
||||
{
|
||||
name: "Fórum",
|
||||
url: "https://forum.arch-linux.cz/"
|
||||
}
|
||||
// Sem můžeš v budoucnu přidávat další, např.:
|
||||
// { name: "Wiki", url: "https://wiki.archlinux.org/" }
|
||||
];
|
||||
Whitespace-only changes.
@@ -0,0 +1,18 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { EndeavourosPage } from './pages/EndeavourosPage';
|
||||
test.describe('endeavourosPage', () => {
|
||||
let endeavourosPage: EndeavourosPage;
|
||||
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
endeavourosPage = new EndeavourosPage(page);
|
||||
await endeavourosPage.navigate();
|
||||
});
|
||||
|
||||
test.describe('EOS text', () => {
|
||||
test('main heading', async () => {
|
||||
await expect(endeavourosPage.mainHeading).toBeVisible();
|
||||
await expect(endeavourosPage.mainHeading).toHaveText('Minimální systémové požadavky pro EndeavourOS:');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,177 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { HomePage } from './pages/HomePage';
|
||||
import { expectedMenuTexts, homePageCards, expectedHalloText, expectedMainHeading, expectedHeroToHaveText, expectedHalloToHaveText2, expectedSearchPlaceholder} from './assets/texts/textHelpers';
|
||||
import { time } from 'console';
|
||||
|
||||
test.describe('EndeavourOS 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('homePage text', () => {
|
||||
|
||||
test('overification of basic elements', async ({ page }) => {
|
||||
await expect(page).toHaveTitle('Domů - EndeavourOS CZ');
|
||||
await expect(homePage.mainHeading).toBeVisible();
|
||||
await expect(homePage.halloDescription).toBeVisible();
|
||||
await expect(homePage.mainHeading).toHaveText(expectedMainHeading);
|
||||
});
|
||||
|
||||
test('check all hello text visibility', async ({ page }) => {
|
||||
await homePage.checkHalloText(expectedHalloText);
|
||||
const locator = page.locator('.hero');
|
||||
|
||||
await expect(locator).toHaveText(expectedHeroToHaveText);
|
||||
await expect(homePage.halloDescription2).toHaveText(expectedHalloToHaveText2);
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('navigate', () => {
|
||||
|
||||
test('search for a term', async ({page}) => {
|
||||
await homePage.searchInput.fill('EndeavourOS');
|
||||
// nejdříve je nutno opravit vyhledávaní na webu
|
||||
// await page.getByText('Linux pacman příkazy').click();
|
||||
|
||||
});
|
||||
|
||||
test('check all menu items visibility', async () => {
|
||||
await homePage.checkMenuTexts(expectedMenuTexts);
|
||||
});
|
||||
|
||||
test('navigation to EndeavourOS', async ({ page }) => {
|
||||
await homePage.clickMenuItem('EndeavourOS');
|
||||
await expect(page).toHaveURL(new RegExp(`.*${homePage.url}/endeavouros`));
|
||||
});
|
||||
|
||||
test('navigation to Články', async ({ page }) => {
|
||||
await homePage.clickMenuItem('Články');
|
||||
await expect(page).toHaveURL(new RegExp(`.*${homePage.url}/rozcestnik`));
|
||||
});
|
||||
|
||||
test('navigation to Krátké návody', async ({ page }) => {
|
||||
await homePage.clickMenuItem('Krátké návody');
|
||||
await expect(page).toHaveURL(new RegExp(`.*${homePage.url}/cheatsheet`));
|
||||
});
|
||||
|
||||
// Seznam externích odkazů, které chceme prověřit
|
||||
// Nyní nejde nutno doopravit
|
||||
// test('externí odkazy v menu jsou platné', async ({ page, request }) => {
|
||||
// const homePage = new HomePage(page);
|
||||
// await homePage.navigate();
|
||||
|
||||
// Seznam externích odkazů, které chceme prověřit
|
||||
// test('kontrola externích odkazů na zdraví (status 200)', async ({ page, request }) => {
|
||||
// const homePage = new HomePage(page);
|
||||
// await homePage.navigate();
|
||||
|
||||
// for (const link of externalLinks) {
|
||||
// // Ověříme, že text tlačítka je na stránce vidět
|
||||
// const href = await homePage.getMenuItemHref(link.name);
|
||||
|
||||
// // Ověříme, že href v HTML odpovídá tomu, co máme v datech
|
||||
// expect(href).toBe(link.url);
|
||||
|
||||
// // Provedeme rychlou kontrolu, zda link není "mrtvý"
|
||||
// const response = await request.get(link.url);
|
||||
// expect(response.ok(), `Odkaz ${link.name} na adrese ${link.url} vrací chybu!`).toBeTruthy();
|
||||
|
||||
// console.log(`Log: Odkaz "${link.name}" je v pořádku.`);
|
||||
// }
|
||||
// });
|
||||
|
||||
//funkční řešení - otevře web
|
||||
test('externí Fórum -> odkaz má správnou adresu', async () => {
|
||||
const href = await homePage.getMenuItemLinkHref('Fórum'); // Příklad
|
||||
expect(href).toBe('https://forum.arch-linux.cz/');
|
||||
});
|
||||
|
||||
test('navigation to O nás', async ({ page }) => {
|
||||
await homePage.clickMenuItem('O nás');
|
||||
await expect(page).toHaveURL(new RegExp(`.*${homePage.url}/o-nas`));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
test.describe('Carts (Karty) na HomePage', () => {
|
||||
let homePage: HomePage;
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
homePage = new HomePage(page);
|
||||
await homePage.navigate();
|
||||
});
|
||||
|
||||
// Otestuje textace na kartách
|
||||
test('should display all cards correctly', async () => {
|
||||
for (const card of homePageCards) {
|
||||
// Používáme naši POM metodu pro každou kartu
|
||||
await homePage.verifyCardContent(card.title, card.description);
|
||||
}
|
||||
});
|
||||
|
||||
// test('should navigate after clicking on a specific card', async ({ page }) => {
|
||||
// // Příklad pro jednu konkrétní kartu
|
||||
// await homePage.clickCardButton('Lehkost a rychlost');
|
||||
// // Zde by následoval expect na novou URL
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
test.describe('Theme', () => {
|
||||
test.describe('Theme -- dark default to light', () => {
|
||||
let homePage: HomePage;
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
homePage = new HomePage(page);
|
||||
await homePage.navigate();
|
||||
});
|
||||
test('switch theme sun', async ({ page }) => {
|
||||
await homePage.switchThemeFunction()
|
||||
});
|
||||
|
||||
});
|
||||
test.describe('Mock date light', () => {
|
||||
test('vynucený start ve světlém režimu + kontrola režimu', async ({ page }) => {
|
||||
// 1. Nastavíme emulaci systému na light (to je základ)
|
||||
await page.emulateMedia({ colorScheme: 'light' });
|
||||
|
||||
// 2. Mockujeme stav paměti a DOMu
|
||||
await page.addInitScript(() => {
|
||||
// Vnutíme informaci, že chceme light do paměti
|
||||
window.localStorage.setItem('theme', 'light');
|
||||
window.localStorage.setItem('color-theme', 'light'); // Pro jistotu oba běžné názvy
|
||||
|
||||
// Tady je ten trik: Sledujeme, kdyby se web snažil přidat 'dark' a hned to smažeme
|
||||
const observer = new MutationObserver(() => {
|
||||
if (document.documentElement.classList.contains('dark')) {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
});
|
||||
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
|
||||
});
|
||||
|
||||
// 3. Jdeme na web
|
||||
await page.goto('https://endeavouros.cz');
|
||||
|
||||
// 4. OVĚŘENÍ: Teď už musí být světlý
|
||||
const html = page.locator('html');
|
||||
await expect(html).not.toHaveClass(/dark/);
|
||||
|
||||
// Vizuální kontrola - barva pozadí by teď měla být bílá/světlá (rgb 255, 255, 255)
|
||||
// Poznámka: Pokud má web i ve světlém režimu jinou barvu, uprav si rgb hodnotu
|
||||
await expect(page.locator('body')).toHaveCSS('background-color', 'rgb(248, 249, 250)');
|
||||
await expect(page.locator('html')).toHaveAttribute('data-theme', 'light');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import { expect, type Locator, type Page } from '@playwright/test';
|
||||
|
||||
export class EndeavourosPage {
|
||||
readonly page: Page;
|
||||
readonly url: string = "https://endeavouros.cz/endeavouros.php";
|
||||
readonly mainHeading: Locator;
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
this.mainHeading = page.getByText('Minimální systémové požadavky pro EndeavourOS:');
|
||||
}
|
||||
async navigate() {
|
||||
await this.page.goto(this.url);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { expect, type Locator, type Page } from '@playwright/test';
|
||||
import { expectedHalloText, expectedMainHeading,expectedHalloToHaveText2, expectedHalloToHaveText1, expectedSearchPlaceholder } from '../assets/texts/textHelpers';
|
||||
|
||||
|
||||
// TODO:
|
||||
// Footer
|
||||
// Theme
|
||||
|
||||
export class HomePage {
|
||||
readonly page: Page;
|
||||
readonly url: string = "https://endeavouros.cz";
|
||||
|
||||
// Lokátory definujeme jako vlastnosti třídy
|
||||
readonly mainHeading: Locator;
|
||||
readonly halloDescription: Locator;
|
||||
readonly halloDescription2: Locator;
|
||||
readonly menuLinks: Locator;
|
||||
readonly cardContainer: Locator;
|
||||
readonly searchInput: Locator;
|
||||
readonly switchTheme: Locator;
|
||||
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
this.mainHeading = page.getByRole('heading', { name: expectedMainHeading });
|
||||
this.halloDescription = page.getByText(expectedHalloToHaveText1);
|
||||
this.halloDescription2 = page.getByText(expectedHalloToHaveText2);
|
||||
this.menuLinks = page.locator('.menu-item a'); // Předpokládaný selektor pro odkazy v menu
|
||||
this.cardContainer = page.locator('.elementor-widget-container'); // doplnit
|
||||
this.searchInput = page.getByPlaceholder(expectedSearchPlaceholder);
|
||||
this.switchTheme = this.page.locator('#themeToggle');
|
||||
}
|
||||
|
||||
async navigate() {
|
||||
await this.page.goto(this.url);
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
// Otestování, zda je zadaný text viditelný na stránce
|
||||
async checkHalloText(expectedText: string) {
|
||||
const item = this.page.getByText(expectedText);
|
||||
await expect(item).toBeVisible();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// test interní odkazy
|
||||
async clickMenuItem(name: string) {
|
||||
await this.page.getByRole('link', { name: name, exact: true }).click();
|
||||
}
|
||||
|
||||
// test externí odkazy --> nejde složitější řešení
|
||||
async getMenuItemHref(name: string): Promise<string> {
|
||||
const link = this.page.getByRole('link', { name: name, exact: true });
|
||||
const href = await link.getAttribute('href');
|
||||
if (!href) throw new Error(`Odkaz s textem "${name}" nemá definované href!`);
|
||||
return href;
|
||||
}
|
||||
// test externí odkazy
|
||||
async getMenuItemLinkHref(name: string): Promise<string | null> {
|
||||
const link = this.page.getByRole('link', { name: name, exact: true });
|
||||
return await link.getAttribute('href');
|
||||
}
|
||||
|
||||
|
||||
/* Karty */
|
||||
|
||||
|
||||
// Najde kartu podle nadpisu a ověří, že obsahuje očekávaný text
|
||||
async verifyCardContent(title: string, description:string) {
|
||||
// Najdeme konkrétní kartu, která obsahuje daný nadpis (h2, h3...)
|
||||
const card = this.page.locator('.article-grid').filter({ hasText: title }).last();
|
||||
const cardDescription = this.page.locator('.article-grid').filter({ hasText: description }).last();
|
||||
|
||||
|
||||
await expect(card).toBeVisible();
|
||||
await expect(cardDescription).toBeVisible();
|
||||
// Ověříme, že v této kartě je i správný popis
|
||||
await expect(card).toContainText(title);
|
||||
await expect(cardDescription).toContainText(description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Klikne na tlačítko "Více" nebo odkaz v konkrétní kartě
|
||||
*/
|
||||
async clickCardButton(title: string) {
|
||||
const card = this.page.locator('section, div').filter({ hasText: title }).last();
|
||||
await card.getByRole('link').first().click();
|
||||
}
|
||||
|
||||
/*
|
||||
* Test theme
|
||||
*/
|
||||
// Test Theme sun
|
||||
async switchThemeFunction() {
|
||||
const themeButton = this.page.locator('#themeToggle');
|
||||
await themeButton.click();
|
||||
await expect(this.page.locator('html')).toHaveAttribute('data-theme', 'light');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user