Skip to content

Commit d4d5bc6

Browse files
authored
Merge pull request #89 from tidepool-org/develop
Tests are not completing (passing and failing) as they had been prior to the merge. Merging to main.
2 parents 3471de4 + b68b895 commit d4d5bc6

269 files changed

Lines changed: 23592 additions & 6472 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 311 additions & 71 deletions
Large diffs are not rendered by default.

.eslintrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

.gitignore

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ tests_output
55
.vscode
66
vrt/diff
77
vrt/latest
8+
build/
9+
dist/
810
# ui
911
screens
10-
test_evidence
12+
test_evidence
13+
14+
# Playwright
15+
/test-results/
16+
/test-output/
17+
/playwright-report/
18+
/blob-report/
19+
/playwright/.cache/
20+
tests/.auth/
21+
22+
playwright-browserstack-sdk*
23+
log/
24+
playwright/.auth/
25+
26+
.obs*/
27+
local.log

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v23.6.0

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
test-results/
2+
node_modules/
3+
dist/
4+
build/
5+
coverage/
6+
playwright/.auth/
7+
playwright-report/
8+
tests_output/

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "all",
8+
"arrowParens": "avoid",
9+
"endOfLine": "auto"
10+
}

CLAUDE.md

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Playwright-based UI testing suite for Tidepool's web application, supporting both local testing and BrowserStack cloud testing. The project tests clinician and patient user flows across multiple environments (qa1-qa5, production).
8+
9+
## Essential Commands
10+
11+
### Testing Commands
12+
13+
- `npm test` - Run all tests (uses TARGET_ENV from .env file)
14+
- `npm run test:smoke` - Run only smoke tests
15+
- `npm run test:critical` - Run only critical tests
16+
- `npm run test:api` - Run only API tests
17+
- `npm run test:ui` - Run only UI tests
18+
- `npm run test:patient` - Run only patient tests
19+
- `npm run test:clinician` - Run only clinician tests
20+
- `npm run test:regression` - Run only regression tests
21+
- `npm run debug` - Debug tests with Playwright's debug mode
22+
- `npx playwright test tests/specific-test.spec.ts` - Run a single test file
23+
24+
**Advanced Tag Filtering:**
25+
- Combine tags with AND logic: `npx playwright test --grep "(?=.*@smoke)(?=.*@ui)"`
26+
- Combine tags with OR logic: `npx playwright test --grep "@smoke|@critical"`
27+
- Change environment: Set `TARGET_ENV` in your .env file or export it before running tests
28+
29+
### Code Quality Commands
30+
31+
- `npm run check` - Run both linting and TypeScript checking
32+
- `npm run lint` - Run ESLint on TypeScript files
33+
- `npm run lint:fix` - Run ESLint with auto-fix
34+
- `npm run typecheck` - Run TypeScript compiler check
35+
- `npm run build` - Compile TypeScript files
36+
- `npm run format` - Format code with Prettier
37+
38+
### Report Generation and Integration
39+
40+
- `npm run merge-reports` - Merge XML test reports from different test suites
41+
- `npm run upload-to-xray` - Upload test results to Xray (requires credentials)
42+
43+
## Architecture Overview
44+
45+
### Page Object Model Structure
46+
47+
The codebase follows the Page Object Model (POM) pattern with a clear separation:
48+
49+
- **`page-objects/`** - Contains all page object classes
50+
- `LoginPage.ts` - Handles authentication flow
51+
- `clinician/` - Clinician-specific pages and components
52+
- `patient/` - Patient-specific pages and components
53+
- `components/` - Reusable UI components shared across pages
54+
55+
### Test Organization
56+
57+
- **`tests/fixtures/base.ts`** - Custom Playwright fixtures with enhanced logging, timing, and exception handling
58+
- **`tests/global-setup.ts`** - Pre-authenticates users and stores session state
59+
- **`tests/clinician/`** - Tests for clinician user flows
60+
- **`tests/patient/`** - Tests for patient user flows
61+
62+
### Environment Management
63+
64+
- **`utilities/env.ts`** - Centralized environment configuration using Zod validation
65+
- **`.env` file** - Local environment configuration (set TARGET_ENV and credentials)
66+
- Supports environments: qa1, qa2, qa3, qa4, qa5, prd, int
67+
- Environment variables validated at startup via Zod schema
68+
- CircleCI uses pipeline parameters to set environment variables
69+
70+
### Key Configuration Files
71+
72+
- **`playwright.config.ts`** - Playwright configuration with dual project setup (local + BrowserStack), includes JSON and Xray reporters
73+
- **`tsconfig.json`** - TypeScript configuration with path mapping for imports
74+
- **`eslint.config.mjs`** - ESLint configuration using Airbnb Extended rules, includes test automation exceptions
75+
- **`.circleci/config.yml`** - CI/CD pipeline with dynamic environment and tag support
76+
77+
### Test Result Reporting
78+
79+
- **JSON Reporter**: Generates `test-results/last-run.json` with rich test data
80+
- **Xray Integration**: `utilities/xray-json-reporter.ts` uploads test results with intelligent evidence handling
81+
- Videos only for failed tests (saves storage)
82+
- Screenshots and JSON responses for all tests
83+
- Configurable project key via `XRAY_PROJECT_KEY` (default: SAND)
84+
- Step-level evidence properly mapped to test steps
85+
- **HTML Reports**: Interactive reports in `playwright-report/`
86+
- **CircleCI Integration**: Automated test result submission to Xray with configurable project key
87+
88+
## Project-Specific Patterns
89+
90+
### Authentication Strategy
91+
92+
- Global setup pre-authenticates both patient and clinician users
93+
- Session state stored in `tests/.auth/` directory
94+
- Separate projects for patient vs clinician test isolation
95+
96+
### Path Aliases
97+
98+
Use these import aliases defined in tsconfig.json:
99+
100+
- `@pom/*` - Page objects (e.g., `@pom/LoginPage`)
101+
- `@components/*` - UI components
102+
- `@fixtures/*` - Test fixtures
103+
104+
### Custom Test Fixtures
105+
106+
The project includes enhanced fixtures in `tests/fixtures/base.ts`:
107+
108+
- `timeLogger` - Logs test start/end times
109+
- `stepTimer` - Times individual test steps
110+
- `exceptionLogger` - Captures and reports frontend exceptions
111+
112+
### BrowserStack Integration
113+
114+
Tests automatically detect BrowserStack environment variables and switch between local Chrome and cloud testing. BrowserStack projects are conditionally added based on credential availability.
115+
116+
### Test Data Management
117+
118+
- Patient/clinician credentials managed via environment variables
119+
- Dynamic test data generation (e.g., timestamps) to avoid test conflicts
120+
- Environment-specific URL mapping
121+
122+
### Test Tagging System
123+
124+
- **`tests/fixtures/test-tags.ts`** - Comprehensive tag system with validation
125+
- **Required Categories**: User Types (@patient, @clinician), Test Types (@api, @ui, @smoke), Priorities (@critical, @high, @medium, @low)
126+
- **Tag Filtering**:
127+
- Space-separated tags = AND logic (test must have ALL tags): `TEST_TAGS='@smoke @ui'`
128+
- Comma-separated tags = OR logic (test must have ANY tag): `TEST_TAGS='@smoke,@critical'`
129+
- **Dynamic Execution**: Use `TEST_TAGS` environment variable for selective test runs
130+
- **Implementation**: Uses Playwright's `--grep` flag with regex patterns to filter tests by tag metadata
131+
132+
## Development Notes
133+
134+
### Adding New Tests
135+
136+
1. Create test files in appropriate directory (`tests/clinician/`, `tests/patient/`, `tests/claimed/`, `tests/personal/`)
137+
2. Import custom fixtures: `import { expect, test } from '@fixtures/base'`
138+
3. Use page objects with path aliases: `import LoginPage from '@pom/LoginPage'`
139+
4. Follow the Given-When-Then pattern with `test.step()` blocks
140+
5. Add test tags using `createValidatedTags()` from `@fixtures/test-tags`
141+
6. Use project-specific imports for specialized fixtures (e.g., `network-helpers`, `patient-helpers`)
142+
143+
### Creating Page Objects
144+
145+
1. Extend the pattern established in existing page objects
146+
2. Use semantic locators (`getByRole`, `getByText`) over CSS selectors
147+
3. Include JSDoc comments for public methods
148+
4. Add `name` property for step decorator context
149+
150+
### Environment Setup
151+
152+
Required environment variables:
153+
154+
- `PERSONAL_USERNAME` / `PERSONAL_PASSWORD` - Personal patient account
155+
- `CLAIMED_USERNAME` / `CLAIMED_PASSWORD` - Claimed patient account
156+
- `SHARED_USERNAME` / `SHARED_PASSWORD` - Shared patient account
157+
- `CLINICIAN_USERNAME` / `CLINICIAN_PASSWORD` - Clinician account
158+
- `TARGET_ENV` (qa1, qa2, qa3, qa4, qa5, prd, int)
159+
- Optional: `BROWSERSTACK_USERNAME` / `BROWSERSTACK_ACCESS_KEY` (for BrowserStack cloud testing)
160+
161+
**Xray Integration (Optional):**
162+
- `XRAY_CLIENT_ID` / `XRAY_CLIENT_SECRET` - Required for automatic Xray upload after test runs
163+
- `XRAY_PROJECT_KEY` - Jira project key (default: SAND)
164+
- `TEST_EXECUTION_KEY` - Link to existing Xray execution, or 'none' to auto-create
165+
166+
**Note:** If `XRAY_CLIENT_ID` and `XRAY_CLIENT_SECRET` are not provided, the Xray reporter will silently skip upload and only generate local JSON reports.
167+
168+
### Project Structure Understanding
169+
170+
The test suite is organized by user authentication state:
171+
172+
- **`tests/personal/`** - Tests for personal (individual) patient accounts
173+
- **`tests/claimed/`** - Tests for claimed patient accounts (connected to clinicians)
174+
- **`tests/clinician/`** - Tests for clinician user flows
175+
Each directory has separate authentication setup and isolated test execution.

0 commit comments

Comments
 (0)