Skip to content

Commit 091ac82

Browse files
committed
chore: few fixes on the documentation
1 parent 0b9d5d2 commit 091ac82

3 files changed

Lines changed: 36 additions & 33 deletions

File tree

docs/dev/explanations/web-architecture.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Built with [tsup](https://tsup.egoist.dev/) for fast TypeScript compilation. Out
3636

3737
The vanilla DiracX web interface:
3838

39-
- **Framework**: [Next.js 15](https://nextjs.org/) with App Router
39+
- **Framework**: [Next.js](https://nextjs.org/) with App Router
4040
- **Output**: Static export (`output: "export"`)
4141
- **Authentication**: [@axa-fr/react-oidc](https://github.com/AxaFrance/oidc-client)
4242
- **Testing**: [Cypress](https://www.cypress.io/) for end-to-end tests
@@ -77,7 +77,6 @@ DiracX Web uses [Next.js folder-based routing](https://nextjs.org/docs/app/build
7777

7878
- **Application state**: Managed via React Context (`ApplicationProvider`).
7979
- **Session storage**: Each application instance writes its state to `<appId>_State` for share/import functionality.
80-
- **URL encoding**: Dashboard layout is encoded in the URL for sharing.
8180

8281
## Design system
8382

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,61 @@
11
# Web Testing
22

3-
DiracX Web uses a layered testing approach to ensure reliability at different levels of the application.
3+
DiracX Web uses a layered testing strategy where each layer builds on the previous one:
4+
5+
1. **Storybook** illustrates shared and public components that extensions can import
6+
2. **Jest tests** verify that those stories render correctly and stay up to date
7+
3. **E2E tests** ensure essential user interactions work end-to-end
48

59
## Testing layers
610

7-
### Component tests (Jest + React Testing Library)
11+
### Storybook (visual documentation and component showcase)
812

9-
Unit and integration tests for individual React components. These tests run in a simulated DOM environment (jsdom) and verify that components render correctly, handle user interactions, and manage state properly.
13+
[Storybook](https://storybook.js.org/) is the foundation of the testing strategy. Each shared or public component that extensions can import should have a corresponding story. Stories serve as living documentation, showing how components look and behave with different props, states, and edge cases.
1014

1115
```bash
12-
npm run test:diracx-web-components
16+
npm run doc:diracx-web-components
1317
```
1418

15-
Tests live alongside their components in `packages/diracx-web-components/test/`.
19+
Stories live in `packages/diracx-web-components/stories/`.
1620

17-
**When to use**: Testing component rendering, props handling, user interactions, hooks, and context behavior.
21+
**What to document**: All reusable components exported by `diracx-web-components` — default states, loading/error/empty states, and key variations.
1822

19-
### End-to-end tests (Cypress)
23+
### Component tests (Jest + React Testing Library)
2024

21-
Full application tests that run in a real browser against a running DiracX backend. These tests simulate real user workflows including authentication, navigation, and data operations.
25+
Jest tests import and render the Storybook stories using `composeStories()` from `@storybook/react`. This ensures that the stories themselves are valid and that the components they illustrate work correctly. If a story breaks, the corresponding Jest test will catch it.
2226

2327
```bash
24-
export DIRACX_URL=<diracx-backend-url>
25-
npm run --prefix packages/diracx-web test
28+
npm run test:diracx-web-components
2629
```
2730

28-
Tests live in `packages/diracx-web/cypress/`.
31+
Tests live in `packages/diracx-web-components/test/`.
2932

30-
**When to use**: Testing complete user flows, authentication, API integration, and cross-component interactions.
33+
**What to test**: That stories render without errors, that key elements are present in the DOM, and that basic interactions (clicks, form inputs) produce the expected results.
3134

32-
### Visual documentation (Storybook)
35+
### End-to-end tests (Cypress)
3336

34-
While not a testing tool per se, [Storybook](https://storybook.js.org/) serves as a visual verification layer. Each component story acts as a living example that can be visually inspected and interacted with.
37+
E2E tests run in a real browser against a running DiracX backend. They verify that essential user workflows work correctly across the full stack — authentication, navigation, data display, and user actions.
3538

3639
```bash
37-
npm run doc:diracx-web-components
40+
export DIRACX_URL=<diracx-backend-url>
41+
npm run --prefix packages/diracx-web test
3842
```
3943

40-
Stories live in `packages/diracx-web-components/stories/`.
44+
Tests live in `packages/diracx-web/test/e2e/`.
4145

42-
**When to use**: Documenting component variations, verifying visual appearance, and enabling manual exploratory testing.
46+
**What to test**: Critical user flows such as logging in, filtering and sorting data, performing actions on jobs, and verifying that interactive features (e.g., clicking a pie chart slice updates the search bar and table) work end-to-end.
4347

44-
## What to test at each level
48+
## How the layers connect
4549

46-
| Level | Scope | Speed | Examples |
47-
|-------|-------|-------|----------|
48-
| Component (Jest) | Single component or hook | Fast | Button renders correctly, form validates input |
49-
| E2E (Cypress) | Full user workflow | Slow | User logs in, submits a job, views results |
50-
| Visual (Storybook) | Component appearance | Manual | Theme variations, responsive layouts |
50+
| Layer | Purpose | Speed | Depends on |
51+
|-------|---------|-------|------------|
52+
| Storybook | Document components for extension developers | Manual | Mocks only |
53+
| Jest | Verify stories render and behave correctly | Fast | Storybook stories |
54+
| Cypress | Verify essential user workflows | Slow | Running backend |
5155

5256
## Guidelines
5357

54-
- Write component tests for all new components and hooks
55-
- Add Storybook stories for reusable UI components
56-
- Add E2E tests for critical user workflows
58+
- Add Storybook stories for all shared/public components exported by `diracx-web-components`
59+
- Write Jest tests that render the stories via `composeStories()` to keep stories and tests in sync
60+
- Add E2E tests for critical user workflows and cross-component interactions
5761
- Use [Jest coverage reports](https://jestjs.io/docs/code-coverage) to identify untested code

docs/dev/tutorials/web-extensions.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ You can either create a new repository or start from this one to build your Dira
121121
The output is set to `export` to have a static application.
122122
Images are left unoptimized because it's not well-supported with a static export.
123123

124-
5. **Add the nginx config** located in the [`config/nginx`](config/nginx/) directory.
124+
5. **Add the nginx config** located in the [`config/nginx`](https://github.com/DIRACGrid/diracx-web/tree/main/packages/extensions/config/nginx) directory.
125125
This adjustment ensures that Nginx can correctly handle requests for .html files and fall back appropriately, preventing the `404: Not Found` errors encountered when accessing routes like `/auth`. (see [#57](https://github.com/DIRACGrid/diracx-web/pull/57))
126126

127127
6. **Organize your pages** in the `src/app` app directory.
128128
The `<DiracXWebProviders>` context is needed by most of the components of `diracx-web-components`, so you should include it in the layouts of your application. Use `<OIDCSecure>` to require authentication on a route. You can also override some default values of certain contexts like `<ApplicationProvider>` for the application list.
129129
Finally, some components have some personalization options (i.e. the logo URL for the dashboard), check the [Storybook documentation](https://diracgrid.github.io/diracx-web/) to see the props of each component.
130-
Check [the app directory](src/app/) in this example to have a reference.
130+
Check [the app directory](https://github.com/DIRACGrid/diracx-web/tree/main/packages/extensions/src/app) in this example to have a reference.
131131

132132
### Architecture
133133

@@ -177,12 +177,12 @@ Having a directory dedicated to your extension components will help you keep you
177177

178178
To add new apps to your extension, you can create new components in your extension directory.
179179

180-
[`testApp`](src/gubbins/components/TestApp/testApp.tsx) provides an example of a basic app component and the [Storybook documentation](https://diracgrid.github.io/diracx-web/) showcases all the components you can use from the library in an interactive interface.
180+
[`testApp`](https://github.com/DIRACGrid/diracx-web/blob/main/packages/extensions/src/gubbins/components/TestApp/testApp.tsx) provides an example of a basic app component and the [Storybook documentation](https://diracgrid.github.io/diracx-web/) showcases all the components you can use from the library in an interactive interface.
181181

182182
It is then pretty easy to add them to DiracX Web by extending the `applicationList` (the list of apps available in DiracX-Web) from `diracx-web-components/components`.
183183

184184
Context providers are used to manage and share global state across the application. You can use the `ApplicationProvider` from `diracx-web-components/contexts` to pass the list of applications to the components that need it.
185-
It is used in this example in the [(Dashboard) directory's layout.tsx](<src/app/(dashboard)/layout.tsx>) file.
185+
It is used in this example in the [(Dashboard) directory's layout.tsx](https://github.com/DIRACGrid/diracx-web/blob/main/packages/extensions/src/app/(dashboard)/layout.tsx) file.
186186

187187
If you need more info on Contexts, you can check the [React documentation](https://reactjs.org/docs/context.html).
188188

@@ -205,7 +205,7 @@ const newApplicationList = [...applicationList, newApp];
205205
<ApplicationProvider appList={newApplicationList}>...</ApplicationProvider>;
206206
```
207207

208-
In this example, the new App list is defined in a [separate file](src/gubbins/applicationList.ts)
208+
In this example, the new App list is defined in a [separate file](https://github.com/DIRACGrid/diracx-web/blob/main/packages/extensions/src/gubbins/applicationList.ts)
209209

210210
Feel free to explore and adjust the code to fit your requirements.
211211

0 commit comments

Comments
 (0)