diff --git a/tests/ValidateServices.js b/tests/ValidateServices.js index b047c08..c4443a3 100644 --- a/tests/ValidateServices.js +++ b/tests/ValidateServices.js @@ -5,6 +5,9 @@ import path from 'path'; const serviceSchema = JSON.parse(fs.readFileSync('./src/content/schema-categories.json', 'utf-8')); +/** + * @param {string} filePath + */ function validateFile(filePath) { const ajv = new Ajv(); const data = JSON.parse(fs.readFileSync(filePath, 'utf-8')); @@ -15,6 +18,9 @@ function validateFile(filePath) { } } +/** + * @param {string} directory + */ function scanDirectory(directory) { const files = fs.readdirSync(directory); for (const file of files) { @@ -30,7 +36,7 @@ function scanDirectory(directory) { export function validateServices() { try { - scanDirectory('./src/content/'); + scanDirectory('./src/content/services'); console.log('All services validated successfully!'); } catch (error) { console.error(`Error validating services: ${error}`); diff --git a/tests/e2e/category.test.ts b/tests/e2e/category.test.ts new file mode 100644 index 0000000..a37a2ff --- /dev/null +++ b/tests/e2e/category.test.ts @@ -0,0 +1,21 @@ +// tests/e2e/category.test.ts +import { test, expect } from '@playwright/test'; + +test('category page renders correctly', async ({ page }) => { + const categoryId = 'pmu'; + await page.goto(`/${categoryId}`); + + // Assert category title + const categoryTitle = await page.locator('h1').textContent(); + expect(categoryTitle).toBeDefined(); + + // Assert category description + const categoryDescription = await page.locator('p').first().textContent(); + expect(categoryDescription).toBeDefined(); + + // Assert services list + // const servicesList = page.locator('ul > li'); + // await expect(servicesList).toBeGreaterThan(0); + + // Add more assertions as needed +}); diff --git a/tests/e2e/general.test.ts b/tests/e2e/general.test.ts new file mode 100644 index 0000000..8e8b0b4 --- /dev/null +++ b/tests/e2e/general.test.ts @@ -0,0 +1,6 @@ +import { expect, test } from '@playwright/test'; + +test('index page has expected h1', async ({ page }) => { + await page.goto('/'); + await expect(page.getByRole('heading', { name: 'Kosmeticky Salon' })).toBeVisible(); +}); diff --git a/tests/e2e/service.test.ts b/tests/e2e/service.test.ts new file mode 100644 index 0000000..27f6d47 --- /dev/null +++ b/tests/e2e/service.test.ts @@ -0,0 +1,22 @@ +// tests/e2e/service.test.ts +import { test, expect } from '@playwright/test'; + +test('service page renders correctly', async ({ page }) => { + const categoryId = 'pmu'; + const serviceId = 'pmu-linky'; + await page.goto(`/${categoryId}/${serviceId}`); + + // Assert service title + const serviceTitle = await page.locator('h1').textContent(); + expect(serviceTitle).toBeDefined(); + + // Assert service description + const serviceDescription = await page.locator('p').first().textContent(); + expect(serviceDescription).toBeDefined(); + + // Assert service content + const serviceContent = await page.locator('article').textContent(); + expect(serviceContent).toBeDefined(); + + // Add more assertions as needed +});