Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
- run: npx eslint .
- run: npx vite build
- run: npx vitest
- run: npx vite build --config vite.config.demo.js
- run: npx playwright install chromium --with-deps

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be using --only-shell to only install headless

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the default be chrome? Maybe it would make sense for pull request to also test in firefox and webkit(safari)

- run: npx playwright test

- run: bash scripts/generate-json-schema.bash --check
- run: npx typedoc src/index.ts
- name: Install latest mdbook
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/verify-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ jobs:
echo "::error:: Please run `npm run version` before merging to main!"; \
exit 1; \
fi
- uses: actions/setup-node@v6
with:
node-version: latest
- run: npm ci
- run: npx playwright install chromium --with-deps

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be using --only-shell to only install headless

- name: "E2E tests against live demo"
run: npx playwright test
env:
DEMO_URL: https://samply.github.io/lens/demo/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ node_modules
dist
dist-ssr
*.local
test-results/
coverage/
TODO
book/book
docs
Expand Down
1 change: 1 addition & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Development](development/README.md)
- [Git hooks](development/git-hooks.md)
- [Styling](development/styling.md)
- [Testing](development/testing.md)
- [Making a release](development/releasing.md)
- [Components](components/README.md)
- [Catalogue](components/catalogue.md)
Expand Down
52 changes: 52 additions & 0 deletions book/src/development/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Testing

## End-to-end tests

Lens uses [Playwright](https://playwright.dev/) for end-to-end tests. They run against the demo application. The demo app must cover all components so that every component has test coverage.

### Test sections

Tests are organised into numbered sections, one file per area:

| Section | File | Area |
| ------- | ----------------------- | ------------------------------------------ |
| 1–2 | `search-bar.spec.ts` | Search bar interactions and query building |
| 3 | `results.spec.ts` | Search execution and result display |
| 4 | `negotiate.spec.ts` | Request Data (Negotiate) button |
| 5 | `query-explain.spec.ts` | Query Explain button |
| 6 | `catalogue.spec.ts` | Catalogue panel |
| 7 | `language.spec.ts` | Language switching |
| 8 | `toast.spec.ts` | Toast notifications |

Shared Playwright helpers (search bar interactions, button clicks, assertions) live in `tests/e2e/searchbar-helpers.ts`.

### Running the tests locally

Build the demo first, then run Playwright:

```sh
npm run build:demo
npx playwright test
```

### Adding a test

When you add or change a component feature, add a corresponding test in the relevant spec file. Number new tests by appending to the section (e.g. the next search-bar test after `2.9` is `2.10`). If no spec file exists for the component yet, create one, pick the next available section number, and add it to this table.

## Unit tests

Unit tests use [Vitest](https://vitest.dev/) and live next to the source files they test (`*.test.ts`). Run them with:

```sh
npx vitest
```

### Query store defaults

An empty `QueryItem[][]` (no groups, no criteria) maps to a top-level `OR` node with no children:

```json
{ "operand": "OR", "children": [] }
```

If this default ever changes from `OR` to `AND`, the empty-store test in `src/helpers/ast-to-query.test.ts` will catch the regression.
Loading
Loading