Skip to content

Commit 4a0edaa

Browse files
author
fortinbra
committed
feat(e2e): implement functional test suite for calendar, transactions, accounts, and CSV import
- Updated status of Feature 062 to implemented in documentation. - Added comprehensive E2E tests for calendar navigation, transaction management, account management, and CSV import workflows. - Introduced local execution guard to ensure tests run only in local environments. - Created helper methods for generating test data and managing local execution. - Added VS Code tasks for easy execution of the functional test suite locally and in demo environments. - Documented local execution steps and CI exclusion strategy for new tests.
1 parent e99b8c9 commit 4a0edaa

File tree

10 files changed

+1004
-18
lines changed

10 files changed

+1004
-18
lines changed

.vscode/tasks.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "E2E: Functional 062 (Local)",
6+
"type": "shell",
7+
"command": "dotnet",
8+
"args": [
9+
"test",
10+
"c:\\ws\\BudgetExperiment\\tests\\BudgetExperiment.E2E.Tests\\BudgetExperiment.E2E.Tests.csproj",
11+
"--filter",
12+
"Category=Functional"
13+
],
14+
"options": {
15+
"env": {
16+
"RUN_E2E_TESTS": "true",
17+
"BUDGET_APP_URL": "http://localhost:5099"
18+
}
19+
},
20+
"group": "test"
21+
},
22+
{
23+
"label": "E2E: Functional 062 (DemoSafe)",
24+
"type": "shell",
25+
"command": "dotnet",
26+
"args": [
27+
"test",
28+
"c:\\ws\\BudgetExperiment\\tests\\BudgetExperiment.E2E.Tests\\BudgetExperiment.E2E.Tests.csproj",
29+
"--filter",
30+
"Category=Functional&Category=DemoSafe"
31+
],
32+
"options": {
33+
"env": {
34+
"RUN_E2E_TESTS": "true",
35+
"BUDGET_APP_URL": "https://budgetdemo.becauseimclever.com"
36+
}
37+
},
38+
"group": "test"
39+
}
40+
]
41+
}

docs/062-functional-e2e-test-suite.md

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Feature 062: Functional E2E Test Suite
2-
> **Status:** 🗒️ Planning
2+
> **Status:** ✅ Implemented
33
> **Priority:** Medium
44
55
## Overview
@@ -118,10 +118,10 @@ tests/BudgetExperiment.E2E.Tests/
118118
**Objective:** Validate calendar display and navigation
119119

120120
**Tasks:**
121-
- [ ] Create `CalendarTests.cs`
122-
- [ ] Test calendar loads and displays current month
123-
- [ ] Test month navigation
124-
- [ ] Test daily transaction display
121+
- [x] Create `CalendarTests.cs`
122+
- [x] Test calendar loads and displays current month
123+
- [x] Test month navigation
124+
- [x] Test daily transaction display
125125

126126
**Commit:**
127127
- test(e2e): add calendar navigation tests
@@ -131,10 +131,10 @@ tests/BudgetExperiment.E2E.Tests/
131131
**Objective:** Validate starting balance in running balance calculation
132132

133133
**Tasks:**
134-
- [ ] Add starting balance validation tests to `CalendarTests.cs`
135-
- [ ] Verify running balance starts with account starting balance
136-
- [ ] Verify running balance accumulates correctly with transactions
137-
- [ ] Test account switching updates running balance
134+
- [x] Add starting balance validation tests to `CalendarTests.cs`
135+
- [x] Verify running balance starts with account starting balance
136+
- [x] Verify running balance accumulates correctly with transactions
137+
- [x] Test account switching updates running balance
138138

139139
**Commit:**
140140
- test(e2e): validate starting balance in calendar
@@ -144,11 +144,11 @@ tests/BudgetExperiment.E2E.Tests/
144144
**Objective:** Validate transaction management
145145

146146
**Tasks:**
147-
- [ ] Create `TransactionTests.cs`
148-
- [ ] Test create transaction flow
149-
- [ ] Test edit transaction flow
150-
- [ ] Test delete transaction flow
151-
- [ ] Verify calendar updates after changes
147+
- [x] Create `TransactionTests.cs`
148+
- [x] Test create transaction flow
149+
- [x] Test edit transaction flow
150+
- [x] Test delete transaction flow
151+
- [x] Verify calendar updates after changes
152152

153153
**Commit:**
154154
- test(e2e): add transaction CRUD tests
@@ -158,10 +158,10 @@ tests/BudgetExperiment.E2E.Tests/
158158
**Objective:** Validate account management and CSV import
159159

160160
**Tasks:**
161-
- [ ] Create `AccountTests.cs`
162-
- [ ] Create `CsvImportTests.cs`
163-
- [ ] Test account creation and switching
164-
- [ ] Test CSV import end-to-end
161+
- [x] Create `AccountTests.cs`
162+
- [x] Create `CsvImportTests.cs`
163+
- [x] Test account creation and switching
164+
- [x] Test CSV import end-to-end
165165

166166
**Commit:**
167167
- test(e2e): add account and import tests
@@ -174,6 +174,23 @@ tests/BudgetExperiment.E2E.Tests/
174174
- Demo environment with seeded data
175175
- Feature 059 (Performance E2E) for shared fixtures
176176

177+
## Local Execution
178+
179+
- Run in VS Code task runner:
180+
- `E2E: Functional 062 (Local)`
181+
- `E2E: Functional 062 (DemoSafe)`
182+
- Task file: `.vscode/tasks.json`
183+
- Local task sets:
184+
- `RUN_E2E_TESTS=true`
185+
- `BUDGET_APP_URL=http://localhost:5099`
186+
- Local task command:
187+
- `dotnet test c:\ws\BudgetExperiment\tests\BudgetExperiment.E2E.Tests\BudgetExperiment.E2E.Tests.csproj --filter "Category=Functional"`
188+
- DemoSafe task sets:
189+
- `RUN_E2E_TESTS=true`
190+
- `BUDGET_APP_URL=https://budgetdemo.becauseimclever.com`
191+
- DemoSafe task command:
192+
- `dotnet test c:\ws\BudgetExperiment\tests\BudgetExperiment.E2E.Tests\BudgetExperiment.E2E.Tests.csproj --filter "Category=Functional&Category=DemoSafe"`
193+
177194
---
178195

179196
## Related Features
@@ -188,3 +205,6 @@ tests/BudgetExperiment.E2E.Tests/
188205
| Date | Author | Description |
189206
|------|--------|-------------|
190207
| 2026-02-01 | AI | Created feature doc, consolidated Feature 041 scenarios |
208+
| 2026-02-14 | AI | Implemented functional Playwright suite: Calendar, Transaction, Account, CSV Import tests + local-run guidance |
209+
| 2026-02-14 | AI | Added VS Code local task for one-click Feature 062 functional suite execution |
210+
| 2026-02-14 | AI | Added VS Code DemoSafe task for shared-environment functional validation |
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Feature 068: Playwright Local Critical User Flows
2+
> **Status:** 🗒️ Planning
3+
> **Priority:** High
4+
> **Estimated Effort:** Small (< 1 sprint)
5+
> **Dependencies:** Feature 062 (Functional E2E Test Suite)
6+
7+
## Overview
8+
9+
Define and implement a focused Playwright E2E coverage baseline for the most critical day-to-day user journeys in the local development environment. This feature intentionally limits scope to three flows: adding transactions, adding accounts, and adding categories.
10+
11+
Tests are designed to run against the local API-hosted client during development and debugging, while remaining excluded from GitHub Actions until the suite is stabilized.
12+
13+
## Problem Statement
14+
15+
### Current State
16+
17+
- E2E direction exists, but core create flows are not guaranteed by a single minimal, high-signal local suite.
18+
- Developers can introduce regressions in critical create workflows without immediate local Playwright feedback.
19+
- CI execution scope for E2E is intentionally conservative and should not be expanded yet.
20+
21+
### Target State
22+
23+
- A small Playwright suite validates the three core creation workflows end-to-end.
24+
- Tests are easy to run locally against the standard development host.
25+
- GitHub Actions does not execute this new local-critical suite yet.
26+
27+
---
28+
29+
## User Stories
30+
31+
### Core Local E2E Coverage
32+
33+
#### US-068-001: Add Transaction Flow
34+
**As a** developer
35+
**I want to** validate the transaction creation flow end-to-end with Playwright locally
36+
**So that** transaction input regressions are caught early
37+
38+
**Acceptance Criteria:**
39+
- [ ] Playwright test creates a transaction through the UI on local environment
40+
- [ ] Saved transaction appears in the expected list/calendar context
41+
- [ ] Test asserts success feedback and persisted visible result
42+
43+
#### US-068-002: Add Account Flow
44+
**As a** developer
45+
**I want to** validate account creation end-to-end with Playwright locally
46+
**So that** account setup regressions are caught before merge
47+
48+
**Acceptance Criteria:**
49+
- [ ] Playwright test creates an account through the UI on local environment
50+
- [ ] New account is selectable/visible in account UI
51+
- [ ] Test asserts resulting state reflects the created account
52+
53+
#### US-068-003: Add Category Flow
54+
**As a** developer
55+
**I want to** validate category creation end-to-end with Playwright locally
56+
**So that** category-management regressions are detected quickly
57+
58+
**Acceptance Criteria:**
59+
- [ ] Playwright test creates a category through the UI on local environment
60+
- [ ] New category appears in category management UI and is usable in relevant forms
61+
- [ ] Test asserts created category can be selected where applicable
62+
63+
#### US-068-004: Local-Only Execution Scope
64+
**As a** maintainer
65+
**I want to** keep this suite local-only for now
66+
**So that** CI runtime and flakiness risk stay controlled while scenarios mature
67+
68+
**Acceptance Criteria:**
69+
- [ ] Local command/documentation exists for running the critical Playwright suite
70+
- [ ] GitHub Actions workflows do not run this new suite
71+
- [ ] CI exclusion approach is explicit and documented (e.g., path/suite filter or separate non-invoked workflow)
72+
73+
---
74+
75+
## Technical Design
76+
77+
### Test Architecture
78+
79+
Target structure in `tests/BudgetExperiment.E2E.Tests`:
80+
81+
- `Tests/FunctionalTests/TransactionCreateTests.cs`
82+
- `Tests/FunctionalTests/AccountCreateTests.cs`
83+
- `Tests/FunctionalTests/CategoryCreateTests.cs`
84+
85+
Common conventions:
86+
- Use resilient selectors (role/label/test-id based where available)
87+
- Use unique test data suffixes to avoid collisions
88+
- Keep each test independent and cleanup-safe when practical
89+
90+
### Local Environment Execution
91+
92+
Per repository workflow, run only the API project locally (the API hosts the Blazor client):
93+
94+
```powershell
95+
dotnet run --project c:\ws\BudgetExperiment\src\BudgetExperiment.Api\BudgetExperiment.Api.csproj
96+
```
97+
98+
Then execute the focused Playwright E2E tests for these critical flows.
99+
100+
### CI Exclusion Strategy (Initial)
101+
102+
For this feature phase, keep execution local-only by one of the following:
103+
- Ensure existing GitHub Action test filters do not include these specific tests, or
104+
- Place them under a naming/category convention that current CI selection excludes.
105+
106+
No change is required to enable CI execution in this feature. A future feature can promote these tests into CI once stability is proven.
107+
108+
---
109+
110+
## Implementation Plan
111+
112+
### Phase 1: Add Focused Local Critical Flow Tests
113+
114+
**Objective:** Introduce the three high-value create-flow Playwright tests.
115+
116+
**Tasks:**
117+
- [ ] Add transaction create E2E test
118+
- [ ] Add account create E2E test
119+
- [ ] Add category create E2E test
120+
- [ ] Verify all three pass locally against API-hosted client
121+
122+
**Commit:**
123+
- `test(e2e): add local critical create-flow playwright tests`
124+
125+
### Phase 2: Ensure CI Exclusion and Document Local Run Path
126+
127+
**Objective:** Keep suite local-only and make intent explicit.
128+
129+
**Tasks:**
130+
- [ ] Verify GitHub Actions does not execute this critical local suite
131+
- [ ] Document local run commands and prerequisites
132+
- [ ] Document CI exclusion rationale in test docs/workflow notes
133+
134+
**Commit:**
135+
- `docs(ci): document local-only execution for critical playwright flows`
136+
137+
---
138+
139+
## Testing Strategy
140+
141+
### E2E Scenarios (Playwright)
142+
143+
- [ ] Create transaction and verify visibility in primary transaction/calendar UI
144+
- [ ] Create account and verify it appears/selects in account controls
145+
- [ ] Create category and verify it appears in category UI and transaction category picker
146+
147+
### Manual Verification Checklist
148+
149+
- [ ] Start API locally and confirm client is served
150+
- [ ] Run focused Playwright critical-flow tests locally
151+
- [ ] Confirm tests are not included in current GitHub Actions execution
152+
153+
---
154+
155+
## Risks and Mitigations
156+
157+
- **Risk:** UI selector instability causes flaky tests.
158+
**Mitigation:** Prefer semantic selectors and add stable test IDs only where needed.
159+
- **Risk:** Local data collisions across repeated runs.
160+
**Mitigation:** Use unique test data identifiers and isolate scenarios.
161+
- **Risk:** Future drift between local and CI expectations.
162+
**Mitigation:** Keep CI exclusion explicitly documented and revisit in a follow-up feature.
163+
164+
---
165+
166+
## Related Features
167+
168+
- Feature 062: Functional E2E Test Suite
169+
- Feature 059: Performance E2E tests
170+
171+
---
172+
173+
## Changelog
174+
175+
| Date | Author | Description |
176+
|------|--------|-------------|
177+
| 2026-02-14 | AI | Created feature doc for local-only Playwright critical create-flow coverage |
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// <copyright file="LocalExecutionGuard.cs" company="BecauseImClever">
2+
// Copyright (c) BecauseImClever. All rights reserved.
3+
// </copyright>
4+
5+
namespace BudgetExperiment.E2E.Tests.Helpers;
6+
7+
/// <summary>
8+
/// Guard utilities for environment-sensitive E2E tests.
9+
/// </summary>
10+
public static class LocalExecutionGuard
11+
{
12+
/// <summary>
13+
/// Skips the current test when the target base URL is not local.
14+
/// </summary>
15+
/// <param name="baseUrl">Current test base URL.</param>
16+
public static bool IsLocalBaseUrl(string baseUrl)
17+
{
18+
if (!Uri.TryCreate(baseUrl, UriKind.Absolute, out var uri))
19+
{
20+
return false;
21+
}
22+
23+
return uri.Host.Equals("localhost", StringComparison.OrdinalIgnoreCase)
24+
|| uri.Host.Equals("127.0.0.1", StringComparison.OrdinalIgnoreCase)
25+
|| uri.Host.Equals("::1", StringComparison.OrdinalIgnoreCase);
26+
}
27+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// <copyright file="TestDataHelper.cs" company="BecauseImClever">
2+
// Copyright (c) BecauseImClever. All rights reserved.
3+
// </copyright>
4+
5+
namespace BudgetExperiment.E2E.Tests.Helpers;
6+
7+
/// <summary>
8+
/// Helper methods for generating deterministic E2E test data.
9+
/// </summary>
10+
public static class TestDataHelper
11+
{
12+
/// <summary>
13+
/// Creates a unique, readable name for test-created entities.
14+
/// </summary>
15+
/// <param name="prefix">Name prefix (for example: Account, Txn).</param>
16+
/// <returns>A unique name safe for UI assertions.</returns>
17+
public static string CreateUniqueName(string prefix)
18+
{
19+
return $"E2E-{prefix}-{DateTime.UtcNow:yyyyMMddHHmmss}-{Guid.NewGuid():N}"[..48];
20+
}
21+
22+
/// <summary>
23+
/// Finds a sample CSV file from the repository's sample data folder.
24+
/// </summary>
25+
/// <returns>Absolute path to sample data CSV.</returns>
26+
public static string GetSampleCsvPath()
27+
{
28+
var current = new DirectoryInfo(AppContext.BaseDirectory);
29+
while (current != null)
30+
{
31+
var candidate = Path.Combine(current.FullName, "sample data", "boa.csv");
32+
if (File.Exists(candidate))
33+
{
34+
return candidate;
35+
}
36+
37+
current = current.Parent;
38+
}
39+
40+
throw new FileNotFoundException("Could not locate sample CSV file at sample data/boa.csv from test execution directory.");
41+
}
42+
}

0 commit comments

Comments
 (0)