Skip to content

Commit 2473625

Browse files
author
Nikita Filonov
committed
pages graph
1 parent d1eec97 commit 2473625

31 files changed

Lines changed: 4454 additions & 13932 deletions

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "submodules/ui-coverage-scenario-report"]
22
path = submodules/ui-coverage-scenario-report
33
url = https://github.com/Nikita-Filonov/ui-coverage-scenario-report.git
4-
tag = v0.1.0
4+
tag = v0.3.0

README.md

Lines changed: 108 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ top, letting you see exactly what was tested and how.
1414
- **Custom highlight & badge colors:** Easily change the highlight and badge colors used in the iframe for different
1515
action types or UI states. Great for tailoring the report to your team's visual style or accessibility needs.
1616
- **No framework lock-in:** Works with any UI testing framework (Playwright, Selenium, etc.) by simply logging actions
17-
via the `trackCoverage()` method.
17+
via the `trackElement()` method.
1818
- **Element-level statistics:** View detailed statistics by selector: type of action, count of actions, and a timeline
1919
graph of coverage.
2020
- **Global history overview:** Track historical trends of total coverage and action types across time.
2121
- **Per-element timeline:** Dive deep into the history of interactions for each element — when and how it was used.
2222
- **Full element index:** Searchable table of all elements interacted with during tests, even if you're not sure where
2323
they are in the UI.
24+
- **Support for visualizing pages in a graph:** The tool offers a unique capability to build a graph of the pages
25+
involved in tests, as well as the transitions between them.
2426
- **Multi-app support:** Testing multiple domains? No problem. Just list your apps in the config — the report will let
2527
you switch between them.
2628

@@ -39,6 +41,7 @@ top, letting you see exactly what was tested and how.
3941
- [Selenium](#selenium)
4042
- [Advanced Example](#advanced-example)
4143
- [Coverage Report Generation](#coverage-report-generation)
44+
- [Tracker Method Overview](#tracker-method-overview)
4245
- [Configuration](#configuration)
4346
- [.env](#configuration-via-env)
4447
- [YAML](#configuration-via-yaml)
@@ -67,6 +70,10 @@ If you have any questions or need assistance, feel free to ask [@Nikita Filonov]
6770

6871
![History](./docs/screenshots/history.png "History")
6972

73+
### Pages
74+
75+
![Pages](./docs/screenshots/pages.png "Pages")
76+
7077
### Scenarios
7178

7279
![Scenarios](./docs/screenshots/scenarios.png "Scenarios")
@@ -155,7 +162,7 @@ That’s it. No other setup required. Without this script, the coverage report w
155162

156163
Below are examples of how to use the tool with popular UI automation
157164
frameworks: `Playwright`, `Puppeteer`, `Selenium`. In both cases, coverage data is automatically saved to
158-
the `./coverage-results` folder after each call to `await tracker.trackCoverage(...)`.
165+
the `./coverage-results` folder after each call to `await tracker.trackElement(...)`.
159166

160167
### Playwright
161168

@@ -186,7 +193,7 @@ const tracker = new UICoverageTracker({ app: 'my-ui-app' });
186193
await usernameInput.fill('user@example.com');
187194

188195
// Track this interaction with the tracker
189-
await tracker.trackCoverage({
196+
await tracker.trackElement({
190197
selector: '#username-input',
191198
selectorType: SelectorType.CSS,
192199
actionType: ActionType.FILL
@@ -196,7 +203,7 @@ const tracker = new UICoverageTracker({ app: 'my-ui-app' });
196203
await loginButton.click();
197204

198205
// Track the click action with the tracker
199-
await tracker.trackCoverage({
206+
await tracker.trackElement({
200207
selector: '//button[@id="login-button"]',
201208
selectorType: SelectorType.XPATH,
202209
actionType: ActionType.CLICK
@@ -214,7 +221,7 @@ const tracker = new UICoverageTracker({ app: 'my-ui-app' });
214221
Quick summary:
215222

216223
- Call `tracker.startScenario(...)` to begin a new scenario.
217-
- Use `await tracker.trackCoverage(...)` after each user interaction.
224+
- Use `await tracker.trackElement(...)` after each user interaction.
218225
- Provide the selector, action type, and selector type.
219226
- The tool automatically stores tracking data as JSON files.
220227
- Once the scenario is complete, call `await tracker.endScenario()` to finalize and save it.
@@ -236,7 +243,7 @@ const tracker = new UICoverageTracker({ app: 'my-ui-app' });
236243
tracker.startScenario({ url: 'http://tms.com/test-cases/1', name: 'Successful login' });
237244

238245
await page.type('#username-input', 'user@example.com');
239-
await tracker.trackCoverage({
246+
await tracker.trackElement({
240247
selector: '#username-input',
241248
selectorType: SelectorType.CSS,
242249
actionType: ActionType.FILL
@@ -245,7 +252,7 @@ const tracker = new UICoverageTracker({ app: 'my-ui-app' });
245252
const loginButton = await page.$x('//button[@id="login-button"]');
246253
if (loginButton[0]) {
247254
await loginButton[0].click();
248-
await tracker.trackCoverage({
255+
await tracker.trackElement({
249256
selector: '//button[@id="login-button"]',
250257
selectorType: SelectorType.XPATH,
251258
actionType: ActionType.CLICK
@@ -276,7 +283,7 @@ const tracker = new UICoverageTracker({ app: 'my-ui-app' });
276283
const usernameInput = await driver.findElement(By.css('#username-input'));
277284
await usernameInput.sendKeys('user@example.com');
278285

279-
await tracker.trackCoverage({
286+
await tracker.trackElement({
280287
selector: '#username-input',
281288
actionType: ActionType.FILL,
282289
selectorType: SelectorType.CSS
@@ -285,7 +292,7 @@ const tracker = new UICoverageTracker({ app: 'my-ui-app' });
285292
const loginButton = await driver.findElement(By.xpath('//button[@id="login-button"]'));
286293
await loginButton.click();
287294

288-
await tracker.trackCoverage({
295+
await tracker.trackElement({
289296
selector: '//button[@id="login-button"]',
290297
actionType: ActionType.CLICK,
291298
selectorType: SelectorType.XPATH
@@ -374,6 +381,13 @@ import {
374381
export class LoginPage {
375382
// Store the Playwright Page and coverage tracker
376383
constructor(private page: Page, private tracker: UICoverageTracker) {
384+
// Track that the test has opened this page.
385+
// Useful for identifying which pages were actually visited during test execution.
386+
this.tracker.trackPage({
387+
url: '/auth/login', // Logical or real URL of the page
388+
page: 'LoginPage', // Human-readable name of the page
389+
priority: 0 // Used to indicate order on the pages graph
390+
});
377391
}
378392

379393
// Method that performs the UI interaction and logs it for coverage
@@ -382,11 +396,15 @@ export class LoginPage {
382396
await this.page.click('#login');
383397

384398
// Log the interaction to the coverage tracker
385-
this.tracker.trackCoverage({
399+
await this.tracker.trackElement({
386400
selector: '#login', // The CSS selector used
387401
actionType: ActionType.Click, // Action type (click, type, etc.)
388402
selectorType: SelectorType.CSS // How the selector was defined
389403
});
404+
405+
// Track the navigation that follows this interaction.
406+
// Helps build a picture of the flow between pages.
407+
await this.tracker.trackTransition({ fromPage: 'LoginPage', toPage: 'DashboardPage' });
390408
}
391409
}
392410

@@ -414,7 +432,10 @@ test('Should login via the login button', async ({ page, tracker }) => {
414432
});
415433
```
416434

417-
The test stays clean and focused — and thanks to the fixture, the tracker lifecycle is fully automated.
435+
The test stays clean and focused — and thanks to the fixture, the tracker lifecycle is fully automated. This makes
436+
interaction tracking an integral part of your UI logic and encourages traceable, observable behavior within
437+
your components and flows. By logging page visits, element interactions, and navigation transitions, your test coverage
438+
becomes more transparent, measurable, and auditable.
418439

419440
#### Why This Approach Works
420441

@@ -426,7 +447,7 @@ The test stays clean and focused — and thanks to the fixture, the tracker life
426447

427448
### Coverage Report Generation
428449

429-
After every call to `await tracker.trackCoverage(...)`, the tool automatically stores coverage data in
450+
After every call to `await tracker.trackElement(...)`, the tool automatically stores coverage data in
430451
the `./coverage-results/` directory as JSON files. You don’t need to manually manage the folder — it’s created and
431452
populated automatically.
432453

@@ -438,7 +459,7 @@ populated automatically.
438459
```
439460

440461
When you call `tracker.startScenario(...)`, a new scenario automatically begins. All subsequent actions, such as
441-
`await tracker.trackCoverage(...)`, will be logged within the context of this scenario. To finalize and save the
462+
`await tracker.trackElement(...)`, will be logged within the context of this scenario. To finalize and save the
442463
scenario, you need to call `await tracker.endScenario()`. This method ends the scenario and saves it to a JSON file.
443464

444465
```
@@ -470,6 +491,79 @@ This will generate:
470491
where your config files (`.env`, `ui-coverage-scenario.config.yaml`, etc.) are located. Running it from another
471492
directory may result in missing data or an empty report.
472493

494+
### Tracker Method Overview
495+
496+
#### 🔹 `startScenario`
497+
498+
**Signature:** `await startScenario({ url, name }})`
499+
500+
**What it does:** Begins a new UI coverage scenario. This groups all tracked interactions under a single logical test
501+
case.
502+
503+
**When to use:** Call this at the beginning of each test, typically in a fixture or setup block.
504+
505+
**Parameters:**
506+
507+
- `url`: (Optional) External reference to a test case or issue (e.g., link to TMS or ticket)
508+
- `name`: A unique name for the scenario — for example, use `testInfo.title` in `playwright` to tie it to the test title
509+
510+
#### 🔹 `endScenario`
511+
512+
**Signature:** `endScenario()`
513+
514+
**What it does:** Closes the current scenario and finalizes the coverage data collected for that test case.
515+
516+
**When to use:** Call this at the **end of each test**, usually in teardown logic or after `yield` in a fixture.
517+
518+
#### 🔹 `trackPage`
519+
520+
**Signature:** `await trackPage({ url, page, priority })`
521+
522+
**What it does:** Marks that a particular page was opened during the test. Useful for identifying what screens were
523+
visited and when.
524+
525+
**When to use:** Call once in the constructor of each Page Object, or at the point where the test navigates to that
526+
page.
527+
528+
**Parameters:**
529+
530+
- `url`: Logical or actual route (e.g. `/auth/login`)
531+
- `page`: Readable identifier like `"LoginPage"`
532+
- `priority`: Optional number to order or weigh pages in reports
533+
534+
#### 🔹 `trackElement`
535+
536+
**Signature:** `await trackElement({ selector, actionType, selectorType })`
537+
538+
**What it does:** Tracks interaction with a specific UI element (e.g., click, fill, select).
539+
540+
**When to use:** Call it immediately after performing the user action — so that the test log reflects actual UI
541+
behavior.
542+
543+
**Parameters:**
544+
545+
- `selector`: The selector used in the action (e.g. `#login`)
546+
- `actionType`: The type of action (`CLICK`, `FILL`, etc.)
547+
- `selectorType`: Type of selector (`CSS`, `XPATH`)
548+
549+
#### 🔹 `trackTransition`
550+
551+
**Signature:** `trackTransition({ fromPage, toPage })`
552+
553+
**What it does:** Marks a transition between two logical pages or views.
554+
555+
**When to use:** After an action that leads to navigation (e.g., after login button click that brings you to dashboard).
556+
557+
**Parameters:**
558+
559+
- `fromPage`: Page before the transition
560+
- `toPage`: Page after the transition
561+
562+
#### Why it matters
563+
564+
These methods work together to give a complete picture of what pages, elements, and flows are covered by your tests —
565+
which can be visualized or analyzed later.
566+
473567
## Configuration
474568

475569
You can configure the UI Coverage Tool using a single file: either a YAML, JSON, or `.env` file. By default, the
@@ -630,7 +724,7 @@ npx ui-coverage-scenario-tool print-config
630724

631725
- Ensure that `startScenario()` is called before the test.
632726
- Ensure that `endScenario()` is called after the test.
633-
- Ensure that `trackCoverage()` is called during your test.
727+
- Ensure that `trackPage()`, `trackElement()`, `trackTransition()` is called during your test.
634728
- Make sure you run `npx ui-coverage-scenario-tool save-report` from the root directory.
635729
- Make sure to setup configuration correctly.
636730
- Check that the `coverage-results` directory contains `.json` files.

0 commit comments

Comments
 (0)