-
Notifications
You must be signed in to change notification settings - Fork 16
Next js tests #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next js tests #271
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| #!/bin/sh | ||
| . "$(dirname "$0")/_/husky.sh" | ||
|
|
||
| set -e # die on error | ||
|
|
||
| pnpm run lint | ||
| REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) | ||
|
|
||
| if command -v pnpm >/dev/null 2>&1; then | ||
| cd "$REPO_ROOT" | ||
| pnpm run lint | ||
| else | ||
| echo "pnpm not found. Skipping lint." >&2 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,90 +1,65 @@ | ||
| # Open Elements Website | ||
|
|
||
| This repo contains the website of Open Elements. | ||
| The website is still work in progress. | ||
| In future the website will be available at https://www.open-elements.de and https://www.open-elements.com. | ||
| This repository contains the Open Elements website. | ||
|
|
||
| Netlify status of English page: | ||
| ## Architecture (2026) | ||
|
|
||
| [](https://app.netlify.com/sites/open-elements-en/deploys) | ||
| The project is now a Next.js application with App Router, Tailwind CSS, and `next-intl` for i18n. Legacy Hugo content and templates are still kept in the repo for migration and historical content. | ||
|
|
||
| Netlify status of German page: | ||
| ### Runtime layers | ||
|
|
||
| [](https://app.netlify.com/sites/open-elements-de/deploys) | ||
| - **Next.js App (primary)** | ||
| - App Router pages and layouts in `src/app`. | ||
| - UI components in `src/components`. | ||
| - Shared utilities in `src/lib`, data in `src/data`, types in `src/types`. | ||
| - Styling via Tailwind CSS and `src/app/globals.css`. | ||
|
|
||
| - **Internationalization** | ||
| - `next-intl` routing and helpers in `src/i18n`. | ||
| - Translation messages in `locales`. | ||
|
|
||
| ## Building the website | ||
| - **Legacy Hugo content (migrating)** | ||
| - Markdown content in `content`. | ||
| - Hugo templates in `src/layouts`. | ||
| - Hugo configuration in `config.toml`. | ||
| - Built static artifacts live in `public` (do not edit manually). | ||
|
|
||
| Since the page is based on Hugo and React we use `npm-run-all` to execute several dev executions in parallel. | ||
| Therefore you need to install `npm-run-all` as a dev dependency: | ||
| - **Web components** | ||
| - Custom elements live in `react-src` and are bundled via `react-src/build.mjs` into `public/js`. | ||
|
|
||
| ``` | ||
| npm install --save-dev npm-run-all | ||
| ``` | ||
|
|
||
|
|
||
| The project is based on [Hugo](https://gohugo.io/) and you need to [install Hugo](https://gohugo.io/installation/) to build the website. | ||
| Once Hugo is installed you can host the website on localhost by executing to following command from the root folder of the repository: | ||
|
|
||
| ``` | ||
| hugo serve | ||
| ``` | ||
| - **E2E tests** | ||
| - Playwright specs in `tests/e2e`. | ||
|
|
||
| While the process is running the English (default) version of the website can be reached at http://localhost:1313/ and the German can be reached at http://localhost:1314/. | ||
| ## Development | ||
|
|
||
| ## Adding Tailwind CSS | ||
| ### Requirements | ||
|
|
||
| ### 1-Install Tailwind CSS | ||
| - Node.js 22 | ||
| - pnpm 10 | ||
|
|
||
| Install tailwindcss via npm, and create your tailwind.config.js file in the root folder. | ||
| ### Install dependencies | ||
|
|
||
| ``` | ||
| npm install -D tailwindcss | ||
| npx tailwindcss init | ||
| pnpm install | ||
| ``` | ||
|
|
||
| ### 2-Configure your template paths | ||
|
|
||
| Add the paths to all of your template files in your tailwind.config.js file. | ||
| ### Run locally | ||
|
|
||
| ``` | ||
| content: [ | ||
| "content/**/*.md", "layouts/**/*.html" | ||
| ], | ||
| pnpm run dev | ||
| ``` | ||
|
|
||
| ### 3-Add the Tailwind directives to your CSS | ||
| Create 'input.css' file in the root folder and add the @tailwind directives for each of Tailwind’s layers to your input CSS file. | ||
|
|
||
| ``` | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
| ``` | ||
| The app is available at http://localhost:3000. | ||
|
|
||
| ### 4-Code snippet for Package.json | ||
|
|
||
| Add the following code in 'Package.json' | ||
| ### Build & start | ||
|
|
||
| ``` | ||
| "scripts": { | ||
| "dev:css": "npx tailwindcss -i input.css -o assets/css/style.css -w", | ||
| "dev:hugo": "hugo server", | ||
| "dev": "run-p dev:*", | ||
| "build:css": "NODE_ENV=production npx tailwindcss -i input.css -o assets/css/style.css -m", | ||
| "build:hugo": "hugo", | ||
| "build": "run-s build:*" | ||
| }, | ||
| pnpm run build | ||
| pnpm run start | ||
| ``` | ||
|
|
||
| ### 5-Dev environment | ||
| For development run the following command in terminal. | ||
| ``` | ||
| npm run dev | ||
| ``` | ||
| ### E2E tests | ||
|
|
||
| ### 6-Production | ||
| For production ready css, run the following command in terminal. | ||
| ``` | ||
| npm run build | ||
| pnpm run test:e2e | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,56 +10,48 @@ test.describe('Accessibility', () => { | |||||
| for (const locale of locales) { | ||||||
| test(`home page has proper heading hierarchy for ${locale}`, async ({ page }) => { | ||||||
| await page.goto(localePath(locale)); | ||||||
|
|
||||||
| // Should have exactly one h1 | ||||||
|
|
||||||
| const h1Count = await page.locator('h1').count(); | ||||||
| expect(h1Count).toBe(1); | ||||||
|
|
||||||
| // H1 should have text content | ||||||
|
|
||||||
| const h1Text = await page.locator('h1').first().textContent(); | ||||||
| expect(h1Text?.trim().length).toBeGreaterThan(0); | ||||||
| }); | ||||||
|
|
||||||
| test(`navigation has proper ARIA landmarks for ${locale}`, async ({ page }) => { | ||||||
| await page.goto(localePath(locale)); | ||||||
|
|
||||||
| // Should have navigation landmark | ||||||
|
|
||||||
| const nav = page.locator('nav, [role="navigation"]'); | ||||||
| await expect(nav).toBeVisible(); | ||||||
|
|
||||||
| // Should have main landmark | ||||||
|
|
||||||
| const main = page.locator('main, [role="main"]'); | ||||||
| await expect(main).toBeVisible(); | ||||||
| }); | ||||||
|
|
||||||
| test(`all images have alt text for ${locale}`, async ({ page }) => { | ||||||
| await page.goto(localePath(locale)); | ||||||
|
|
||||||
| // Get all images | ||||||
|
|
||||||
| const images = page.locator('img'); | ||||||
| const count = await images.count(); | ||||||
|
|
||||||
| // Check each image has alt attribute | ||||||
|
|
||||||
| for (let i = 0; i < count; i++) { | ||||||
| const img = images.nth(i); | ||||||
| const alt = await img.getAttribute('alt'); | ||||||
| // Alt can be empty string for decorative images, but must exist | ||||||
|
|
||||||
|
||||||
| // Alt can be an empty string for decorative images, but the alt attribute must exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pre-commit hook now allows commits to proceed when pnpm is not found, only printing a warning. This means linting can be bypassed in environments without pnpm installed. Consider whether this is the desired behavior, or if the hook should fail with
exit 1when pnpm is unavailable to ensure consistent code quality checks across all environments.