diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6ba59bb..f4a0b73a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,3 +33,25 @@ jobs: - name: Validate generated site run: bundle exec htmlproofer ./_site --disable-external --no-enforce-https --allow-missing-href --ignore-urls '/^\/\//' + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 24 + cache: npm + + - name: Install Playwright + run: | + npm ci + npx playwright install --with-deps chromium + + - name: Run Playwright tests + run: npm run test:e2e + + - name: Upload Playwright report + if: failure() + uses: actions/upload-artifact@v5 + with: + name: playwright-report + path: playwright-report/ + retention-days: 14 diff --git a/.gitignore b/.gitignore index f0851f0a..7d1b97e7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ _site vendor .env .vscode +node_modules +playwright-report +test-results # Script output tmp/pending_updates.yml diff --git a/README.md b/README.md index 72c08b37..a9f5e1e5 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,17 @@ Use official sources for event updates: Do not edit files in ```_site``` directly. That directory is generated by Jekyll; update the source files and regenerate the site instead. +## Testing + +The Playwright suite uses HTTP-level checks for page and feed availability, and browser-level checks only for visitor-facing rendering and navigation behavior. After installing the Ruby and Node.js dependencies, install Chromium once and run the suite: + +```shell +npx playwright install chromium +npm run test:e2e +``` + +Playwright starts the local Jekyll server automatically. Set `PLAYWRIGHT_TEST_BASE_URL` to test an already-running or deployed site instead. + ## Eligible Conferences and Workshops Focus is a goal of this project and as a result, only conferences, un-conferences and workshops that are specifically for software testing are listed. That means that if a conference covers software testing, but is not specifically for testers, then it is left out. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..2fde8428 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,58 @@ +{ + "name": "testingconferences.github.io", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "testingconferences.github.io", + "devDependencies": { + "@playwright/test": "1.64.1" + } + }, + "node_modules/@playwright/test": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz", + "integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.64.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz", + "integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.64.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright-core": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", + "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..870735dc --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "testingconferences.github.io", + "private": true, + "scripts": { + "test:e2e": "playwright test", + "test:e2e:report": "playwright show-report" + }, + "devDependencies": { + "@playwright/test": "1.64.1" + } +} diff --git a/playwright.config.js b/playwright.config.js new file mode 100644 index 00000000..7e40420a --- /dev/null +++ b/playwright.config.js @@ -0,0 +1,34 @@ +const { defineConfig, devices } = require('@playwright/test'); + +const baseURL = process.env.PLAYWRIGHT_TEST_BASE_URL || 'http://127.0.0.1:4000'; + +module.exports = defineConfig({ + testDir: './test/playwright', + fullyParallel: true, + forbidOnly: Boolean(process.env.CI), + retries: process.env.CI ? 2 : 0, + workers: process.env.CI ? 1 : undefined, + globalTimeout: 5 * 60 * 1000, + reporter: process.env.CI + ? [['github'], ['html', { open: 'never' }]] + : [['list'], ['html', { open: 'never' }]], + use: { + baseURL, + trace: 'retain-on-failure', + screenshot: 'only-on-failure' + }, + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] } + } + ], + webServer: process.env.PLAYWRIGHT_TEST_BASE_URL + ? undefined + : { + command: 'bundle exec jekyll serve --host 127.0.0.1 --port 4000 --no-watch', + url: baseURL, + reuseExistingServer: !process.env.CI, + timeout: 120 * 1000 + } +}); diff --git a/test/playwright/site-api.spec.js b/test/playwright/site-api.spec.js new file mode 100644 index 00000000..ac8b24b9 --- /dev/null +++ b/test/playwright/site-api.spec.js @@ -0,0 +1,22 @@ +const { test, expect } = require('@playwright/test'); + +test.describe('site endpoints', () => { + test('core pages return HTML successfully', async ({ request }) => { + const paths = ['/', '/past/', '/news/', '/videos/', '/about/', '/subscribe/']; + + for (const path of paths) { + const response = await request.get(path); + + expect(response.ok(), `${path} should return a successful response`).toBe(true); + expect(response.headers()['content-type']).toContain('text/html'); + } + }); + + test('RSS feed returns XML with the site title', async ({ request }) => { + const response = await request.get('/feed.xml'); + + expect(response.ok()).toBe(true); + expect(response.headers()['content-type']).toMatch(/(?:application|text)\/xml/); + await expect(response.text()).resolves.toContain('Software Testing Conferences'); + }); +}); diff --git a/test/playwright/site-ui.spec.js b/test/playwright/site-ui.spec.js new file mode 100644 index 00000000..221eade5 --- /dev/null +++ b/test/playwright/site-ui.spec.js @@ -0,0 +1,28 @@ +const { test, expect } = require('@playwright/test'); + +test.describe('visitor experience', () => { + test('upcoming conferences show their essential details', async ({ page }) => { + await page.goto('/'); + + await expect(page).toHaveTitle('Software Testing Conferences'); + + const conferences = page.locator('.post-list > li'); + expect(await conferences.count()).toBeGreaterThan(0); + + const firstConference = conferences.first(); + await expect(firstConference.getByRole('heading').getByRole('link')).toBeVisible(); + await expect(firstConference.getByRole('img', { name: 'Dates' })).toBeVisible(); + await expect(firstConference.getByRole('img', { name: 'Location' })).toBeVisible(); + }); + + test('primary navigation opens the archive and marks it active', async ({ page }) => { + await page.goto('/'); + + await expect(page.getByRole('link', { name: 'Upcoming', exact: true })).toHaveClass(/active/); + await page.getByRole('link', { name: 'Past', exact: true }).click(); + + await expect(page).toHaveURL(/\/past\/$/); + await expect(page).toHaveTitle('Past Software Testing Conferences'); + await expect(page.getByRole('link', { name: 'Past', exact: true })).toHaveClass(/active/); + }); +});