|
| 1 | +/** |
| 2 | + * Template for a recorded-walkthrough e2e story. |
| 3 | + * |
| 4 | + * How to use: |
| 5 | + * 1. Copy this file to `<yourStory>.test.ts` in this folder (the `.test.ts` suffix is what makes |
| 6 | + * Playwright pick it up; this template is deliberately named so it is ignored). |
| 7 | + * 2. Capture the raw clicks/fills with `npm run test:e2e:codegen` (see tests/README.md). Codegen |
| 8 | + * writes plain Playwright calls to `_recorded.gen.ts` — a starting point for the selectors. |
| 9 | + * 3. Port those actions into the body below, wrapping interactions in `smoothClick`/`smoothFill` |
| 10 | + * and adding `narrate(...)` lines. These are no-ops unless RECORD=1, so the story still runs as |
| 11 | + * a fast regression check with `npm run test:e2e`. |
| 12 | + * |
| 13 | + * Requires the full docker stack running; the `authenticated-*` project loads the seeded session so |
| 14 | + * the app starts logged in. |
| 15 | + */ |
| 16 | +import { expect } from "@playwright/test"; |
| 17 | + |
| 18 | +import { test } from "../support/recordingFixtures"; |
| 19 | +import { |
| 20 | + dragModuleOntoLayout, |
| 21 | + hideDevOverlays, |
| 22 | + installFakeCursor, |
| 23 | + smoothClick, |
| 24 | +} from "../support/walkthroughHelpers"; |
| 25 | + |
| 26 | +test.describe("My module", () => { |
| 27 | + test("does the thing", async ({ page, narrate }) => { |
| 28 | + test.setTimeout(180_000); |
| 29 | + |
| 30 | + // Render a visible cursor and hide dev-only overlays so the recorded video stays clean. |
| 31 | + await installFakeCursor(page); |
| 32 | + await hideDevOverlays(page); |
| 33 | + |
| 34 | + await page.goto("/"); |
| 35 | + await expect(page.getByText("FMU Analysis").first()).toBeVisible(); |
| 36 | + |
| 37 | + await narrate("Describe what this walkthrough will show."); |
| 38 | + |
| 39 | + |
| 40 | + await page.goto('/'); |
| 41 | + await smoothClick(page, page.getByRole("button", { name: "New session" })); |
| 42 | + |
| 43 | + await smoothClick(page, page.getByRole('button', { name: 'New session' })); |
| 44 | + await smoothClick(page, page.getByTestId('add-regular-ensemble-button')); |
| 45 | + await smoothClick(page, page.locator('[id="base-ui-:rbn:"]')); |
| 46 | + await page.locator('[id="base-ui-:rbn:"]').fill('My description'); |
| 47 | + await smoothClick(page, page.getByText('My description').first()); |
| 48 | + await smoothClick(page, page.getByText('iter-0 (100 realizations)')); |
| 49 | + await smoothClick(page, page.getByRole('button', { name: 'Apply' })); |
| 50 | + await smoothClick(page, page.getByRole('button', { name: 'Apply' })); |
| 51 | + |
| 52 | + const dragNarration = narrate( |
| 53 | + "Now we drag the 3D Viewer module from the list onto the dashboard and wait for the relevant data and settings to load.", |
| 54 | + ); |
| 55 | + await dragModuleOntoLayout(page, "3D Viewer"); |
| 56 | + await dragNarration; |
| 57 | + |
| 58 | + await smoothClick(page, page.getByText('3D Viewer')); |
| 59 | + await smoothClick(page, page.getByTestId('module-layout').getByTestId('WebAssetIcon')); |
| 60 | + await expect(page.getByRole('button', { name: 'Add first view' })).toBeVisible(); |
| 61 | + await smoothClick(page, page.getByRole('button', { name: 'Add first view' })); |
| 62 | + await smoothClick(page, page.getByRole('button', { name: 'Add' }).nth(1)); |
| 63 | + await smoothClick(page, page.getByRole('menuitem', { name: 'Layers' })); |
| 64 | + await smoothClick(page, page.getByRole('menuitem', { name: 'Grid Model' })); |
| 65 | + await smoothClick(page, page.getByRole('menuitem', { name: 'Grid Model 3D' })); |
| 66 | + |
| 67 | + }); |
| 68 | +}); |
0 commit comments