@patricio0312rev/skillset 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/bin/cli.js +37 -0
- package/package.json +55 -0
- package/src/commands/init.js +301 -0
- package/src/index.js +168 -0
- package/src/lib/config.js +200 -0
- package/src/lib/generator.js +166 -0
- package/src/utils/display.js +95 -0
- package/src/utils/readme.js +196 -0
- package/src/utils/tool-specific.js +233 -0
- package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
- package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
- package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
- package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
- package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
- package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
- package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
- package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
- package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
- package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
- package/templates/architecture/adr-writer/ SKILL.md +250 -0
- package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
- package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
- package/templates/architecture/migration-planner/ SKILL.md +376 -0
- package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
- package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
- package/templates/architecture/rfc-generator/ SKILL.md +362 -0
- package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
- package/templates/architecture/system-design-generator/ SKILL.md +339 -0
- package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
- package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
- package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
- package/templates/backend/auth-module-builder/ SKILL.md +99 -0
- package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
- package/templates/backend/caching-strategist/ SKILL.md +190 -0
- package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
- package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
- package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
- package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
- package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
- package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
- package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
- package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
- package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
- package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
- package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
- package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
- package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
- package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
- package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
- package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
- package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
- package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
- package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
- package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
- package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
- package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
- package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
- package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
- package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
- package/templates/foundation/changelog-writer/ SKILL.md +431 -0
- package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
- package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
- package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
- package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
- package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
- package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
- package/templates/foundation/explaining-code/SKILL.md +13 -0
- package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
- package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
- package/templates/foundation/project-scaffolder/references/templates.md +126 -0
- package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
- package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
- package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
- package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
- package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
- package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
- package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
- package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
- package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
- package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
- package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
- package/templates/frontend/table-builder/ SKILL.md +350 -0
- package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
- package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
- package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
- package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
- package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
- package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
- package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
- package/templates/performance/observability-setup/ SKILL.md +232 -0
- package/templates/performance/postmortem-writer/ SKILL.md +203 -0
- package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
- package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
- package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
- package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
- package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
- package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
- package/templates/security/secrets-scanner/ SKILL.md +462 -0
- package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
- package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
- package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
- package/templates/security/threat-model-generator/ SKILL.md +394 -0
- package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
- package/templates/testing/coverage-strategist/ SKILL.md +436 -0
- package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
- package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
- package/templates/testing/integration-test-builder/ SKILL.md +525 -0
- package/templates/testing/mocking-assistant/ SKILL.md +383 -0
- package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
- package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
- package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
- package/templates/testing/unit-test-generator/ SKILL.md +548 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: e2e-test-builder
|
|
3
|
+
description: Builds end-to-end browser tests for critical user flows using Playwright or Cypress. Includes selector strategies, test data management, page objects, and visual regression testing. Use for "E2E testing", "browser tests", "Playwright", or "Cypress tests".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# E2E Test Builder
|
|
7
|
+
|
|
8
|
+
Build reliable end-to-end tests for critical user flows.
|
|
9
|
+
|
|
10
|
+
## Playwright Test Setup
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// playwright.config.ts
|
|
14
|
+
import { defineConfig } from "@playwright/test";
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
testDir: "./e2e",
|
|
18
|
+
fullyParallel: true,
|
|
19
|
+
forbidOnly: !!process.env.CI,
|
|
20
|
+
retries: process.env.CI ? 2 : 0,
|
|
21
|
+
workers: process.env.CI ? 1 : undefined,
|
|
22
|
+
reporter: "html",
|
|
23
|
+
use: {
|
|
24
|
+
baseURL: "http://localhost:3000",
|
|
25
|
+
trace: "on-first-retry",
|
|
26
|
+
screenshot: "only-on-failure",
|
|
27
|
+
},
|
|
28
|
+
projects: [
|
|
29
|
+
{
|
|
30
|
+
name: "chromium",
|
|
31
|
+
use: { ...devices["Desktop Chrome"] },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "firefox",
|
|
35
|
+
use: { ...devices["Desktop Firefox"] },
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "webkit",
|
|
39
|
+
use: { ...devices["Desktop Safari"] },
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "Mobile Chrome",
|
|
43
|
+
use: { ...devices["Pixel 5"] },
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
webServer: {
|
|
47
|
+
command: "npm run dev",
|
|
48
|
+
url: "http://localhost:3000",
|
|
49
|
+
reuseExistingServer: !process.env.CI,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Critical Flow Tests
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// e2e/checkout-flow.spec.ts
|
|
58
|
+
import { test, expect } from "@playwright/test";
|
|
59
|
+
|
|
60
|
+
test.describe("Checkout Flow", () => {
|
|
61
|
+
test.beforeEach(async ({ page }) => {
|
|
62
|
+
// Navigate to home page
|
|
63
|
+
await page.goto("/");
|
|
64
|
+
|
|
65
|
+
// Login
|
|
66
|
+
await page.getByRole("button", { name: "Login" }).click();
|
|
67
|
+
await page.getByLabel("Email").fill("test@example.com");
|
|
68
|
+
await page.getByLabel("Password").fill("password123");
|
|
69
|
+
await page.getByRole("button", { name: "Sign In" }).click();
|
|
70
|
+
|
|
71
|
+
// Wait for dashboard
|
|
72
|
+
await expect(page).toHaveURL("/dashboard");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("should complete checkout successfully", async ({ page }) => {
|
|
76
|
+
// 1. Browse products
|
|
77
|
+
await page.getByRole("link", { name: "Products" }).click();
|
|
78
|
+
await expect(page).toHaveURL("/products");
|
|
79
|
+
|
|
80
|
+
// 2. Add product to cart
|
|
81
|
+
await page.getByRole("button", { name: "Add to Cart" }).first().click();
|
|
82
|
+
await expect(page.getByText("Added to cart")).toBeVisible();
|
|
83
|
+
|
|
84
|
+
// 3. Go to cart
|
|
85
|
+
await page.getByRole("link", { name: "Cart" }).click();
|
|
86
|
+
await expect(page).toHaveURL("/cart");
|
|
87
|
+
await expect(
|
|
88
|
+
page.getByRole("heading", { name: "Shopping Cart" })
|
|
89
|
+
).toBeVisible();
|
|
90
|
+
|
|
91
|
+
// 4. Proceed to checkout
|
|
92
|
+
await page.getByRole("button", { name: "Checkout" }).click();
|
|
93
|
+
await expect(page).toHaveURL("/checkout");
|
|
94
|
+
|
|
95
|
+
// 5. Fill shipping information
|
|
96
|
+
await page.getByLabel("Full Name").fill("John Doe");
|
|
97
|
+
await page.getByLabel("Address").fill("123 Main St");
|
|
98
|
+
await page.getByLabel("City").fill("New York");
|
|
99
|
+
await page.getByLabel("ZIP Code").fill("10001");
|
|
100
|
+
|
|
101
|
+
// 6. Fill payment information
|
|
102
|
+
await page.getByLabel("Card Number").fill("4242424242424242");
|
|
103
|
+
await page.getByLabel("Expiry Date").fill("12/25");
|
|
104
|
+
await page.getByLabel("CVC").fill("123");
|
|
105
|
+
|
|
106
|
+
// 7. Place order
|
|
107
|
+
await page.getByRole("button", { name: "Place Order" }).click();
|
|
108
|
+
|
|
109
|
+
// 8. Verify success
|
|
110
|
+
await expect(page).toHaveURL(/\/order\/\d+/);
|
|
111
|
+
await expect(page.getByText("Order confirmed!")).toBeVisible();
|
|
112
|
+
await expect(page.getByText(/Order #\d+/)).toBeVisible();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("should show validation errors for empty fields", async ({ page }) => {
|
|
116
|
+
// Navigate to checkout
|
|
117
|
+
await page.goto("/checkout");
|
|
118
|
+
|
|
119
|
+
// Try to submit without filling fields
|
|
120
|
+
await page.getByRole("button", { name: "Place Order" }).click();
|
|
121
|
+
|
|
122
|
+
// Verify validation errors
|
|
123
|
+
await expect(page.getByText("Name is required")).toBeVisible();
|
|
124
|
+
await expect(page.getByText("Address is required")).toBeVisible();
|
|
125
|
+
await expect(page.getByText("Card number is required")).toBeVisible();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("should handle payment failure", async ({ page }) => {
|
|
129
|
+
// Add product and go to checkout
|
|
130
|
+
await page.goto("/products");
|
|
131
|
+
await page.getByRole("button", { name: "Add to Cart" }).first().click();
|
|
132
|
+
await page.goto("/checkout");
|
|
133
|
+
|
|
134
|
+
// Fill with failing card number
|
|
135
|
+
await page.getByLabel("Card Number").fill("4000000000000002");
|
|
136
|
+
await page.getByLabel("Expiry Date").fill("12/25");
|
|
137
|
+
await page.getByLabel("CVC").fill("123");
|
|
138
|
+
|
|
139
|
+
// Submit
|
|
140
|
+
await page.getByRole("button", { name: "Place Order" }).click();
|
|
141
|
+
|
|
142
|
+
// Verify error message
|
|
143
|
+
await expect(page.getByText("Payment failed")).toBeVisible();
|
|
144
|
+
await expect(page.getByText("Please try a different card")).toBeVisible();
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Page Object Pattern
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// e2e/pages/LoginPage.ts
|
|
153
|
+
export class LoginPage {
|
|
154
|
+
constructor(private page: Page) {}
|
|
155
|
+
|
|
156
|
+
async goto() {
|
|
157
|
+
await this.page.goto("/login");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async login(email: string, password: string) {
|
|
161
|
+
await this.page.getByLabel("Email").fill(email);
|
|
162
|
+
await this.page.getByLabel("Password").fill(password);
|
|
163
|
+
await this.page.getByRole("button", { name: "Sign In" }).click();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async expectLoginSuccess() {
|
|
167
|
+
await expect(this.page).toHaveURL("/dashboard");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async expectLoginError(message: string) {
|
|
171
|
+
await expect(this.page.getByText(message)).toBeVisible();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// e2e/pages/ProductPage.ts
|
|
176
|
+
export class ProductPage {
|
|
177
|
+
constructor(private page: Page) {}
|
|
178
|
+
|
|
179
|
+
async goto() {
|
|
180
|
+
await this.page.goto("/products");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async addToCart(productName: string) {
|
|
184
|
+
const product = this.page.locator(`[data-product="${productName}"]`);
|
|
185
|
+
await product.getByRole("button", { name: "Add to Cart" }).click();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async expectProductVisible(productName: string) {
|
|
189
|
+
await expect(
|
|
190
|
+
this.page.getByRole("heading", { name: productName })
|
|
191
|
+
).toBeVisible();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Usage in tests
|
|
196
|
+
test("should login and add product", async ({ page }) => {
|
|
197
|
+
const loginPage = new LoginPage(page);
|
|
198
|
+
const productPage = new ProductPage(page);
|
|
199
|
+
|
|
200
|
+
await loginPage.goto();
|
|
201
|
+
await loginPage.login("test@example.com", "password123");
|
|
202
|
+
await loginPage.expectLoginSuccess();
|
|
203
|
+
|
|
204
|
+
await productPage.goto();
|
|
205
|
+
await productPage.addToCart("MacBook Pro");
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Selector Strategy
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
// Preferred selector priority:
|
|
213
|
+
// 1. Role-based (most resilient)
|
|
214
|
+
await page.getByRole("button", { name: "Submit" });
|
|
215
|
+
await page.getByRole("link", { name: "Products" });
|
|
216
|
+
await page.getByRole("textbox", { name: "Email" });
|
|
217
|
+
|
|
218
|
+
// 2. Label-based (semantic)
|
|
219
|
+
await page.getByLabel("Email address");
|
|
220
|
+
await page.getByLabel("Password");
|
|
221
|
+
|
|
222
|
+
// 3. Test ID (for complex cases)
|
|
223
|
+
await page.getByTestId("user-menu");
|
|
224
|
+
await page.getByTestId("product-card-123");
|
|
225
|
+
|
|
226
|
+
// 4. Text content (for unique text)
|
|
227
|
+
await page.getByText("Welcome back!");
|
|
228
|
+
await page.getByText(/Order #\d+/);
|
|
229
|
+
|
|
230
|
+
// ❌ Avoid: CSS selectors (brittle)
|
|
231
|
+
// await page.locator('.btn.btn-primary');
|
|
232
|
+
// await page.locator('#submit-button');
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Test Data Management
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
// e2e/fixtures/test-data.ts
|
|
239
|
+
export const testData = {
|
|
240
|
+
users: {
|
|
241
|
+
admin: {
|
|
242
|
+
email: "admin@example.com",
|
|
243
|
+
password: "admin123",
|
|
244
|
+
},
|
|
245
|
+
customer: {
|
|
246
|
+
email: "customer@example.com",
|
|
247
|
+
password: "customer123",
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
products: {
|
|
251
|
+
laptop: {
|
|
252
|
+
name: "MacBook Pro",
|
|
253
|
+
price: 2499.99,
|
|
254
|
+
},
|
|
255
|
+
phone: {
|
|
256
|
+
name: "iPhone 15",
|
|
257
|
+
price: 999.99,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
cards: {
|
|
261
|
+
valid: "4242424242424242",
|
|
262
|
+
declined: "4000000000000002",
|
|
263
|
+
insufficientFunds: "4000000000009995",
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// e2e/setup/seed-test-data.ts
|
|
268
|
+
export async function seedTestData() {
|
|
269
|
+
const prisma = new PrismaClient();
|
|
270
|
+
|
|
271
|
+
// Create test users
|
|
272
|
+
await prisma.user.upsert({
|
|
273
|
+
where: { email: testData.users.customer.email },
|
|
274
|
+
create: {
|
|
275
|
+
email: testData.users.customer.email,
|
|
276
|
+
password: await hash(testData.users.customer.password),
|
|
277
|
+
},
|
|
278
|
+
update: {},
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Create test products
|
|
282
|
+
await prisma.product.upsert({
|
|
283
|
+
where: { name: testData.products.laptop.name },
|
|
284
|
+
create: testData.products.laptop,
|
|
285
|
+
update: {},
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
await prisma.$disconnect();
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Visual Regression Testing
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
// e2e/visual/homepage.spec.ts
|
|
296
|
+
test("homepage should match screenshot", async ({ page }) => {
|
|
297
|
+
await page.goto("/");
|
|
298
|
+
|
|
299
|
+
// Take full page screenshot
|
|
300
|
+
await expect(page).toHaveScreenshot("homepage.png", {
|
|
301
|
+
fullPage: true,
|
|
302
|
+
maxDiffPixels: 100, // Allow minor differences
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
test("product card should match screenshot", async ({ page }) => {
|
|
307
|
+
await page.goto("/products");
|
|
308
|
+
|
|
309
|
+
const productCard = page.locator('[data-testid="product-card"]').first();
|
|
310
|
+
|
|
311
|
+
// Take element screenshot
|
|
312
|
+
await expect(productCard).toHaveScreenshot("product-card.png");
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Mobile Testing
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
// e2e/mobile/checkout-mobile.spec.ts
|
|
320
|
+
test.use({ viewport: { width: 375, height: 667 } }); // iPhone SE
|
|
321
|
+
|
|
322
|
+
test("should complete mobile checkout", async ({ page }) => {
|
|
323
|
+
await page.goto("/");
|
|
324
|
+
|
|
325
|
+
// Open mobile menu
|
|
326
|
+
await page.getByRole("button", { name: "Menu" }).click();
|
|
327
|
+
await page.getByRole("link", { name: "Products" }).click();
|
|
328
|
+
|
|
329
|
+
// Add to cart
|
|
330
|
+
await page.getByRole("button", { name: "Add to Cart" }).first().click();
|
|
331
|
+
|
|
332
|
+
// Continue with checkout
|
|
333
|
+
// ...
|
|
334
|
+
});
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Network Mocking
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
// e2e/mocked/payment-api.spec.ts
|
|
341
|
+
test("should handle payment API timeout", async ({ page }) => {
|
|
342
|
+
// Mock slow payment API
|
|
343
|
+
await page.route("**/api/payment", async (route) => {
|
|
344
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
345
|
+
await route.fulfill({
|
|
346
|
+
status: 200,
|
|
347
|
+
body: JSON.stringify({ success: true }),
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// Proceed with checkout
|
|
352
|
+
await page.goto("/checkout");
|
|
353
|
+
// ... fill form ...
|
|
354
|
+
await page.getByRole("button", { name: "Place Order" }).click();
|
|
355
|
+
|
|
356
|
+
// Should show loading state
|
|
357
|
+
await expect(page.getByText("Processing payment...")).toBeVisible();
|
|
358
|
+
});
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Best Practices
|
|
362
|
+
|
|
363
|
+
1. **Test user flows**: Not individual components
|
|
364
|
+
2. **Use role-based selectors**: More resilient
|
|
365
|
+
3. **Page objects**: Reusable and maintainable
|
|
366
|
+
4. **Wait for elements**: Don't use fixed sleeps
|
|
367
|
+
5. **Test critical paths**: Login, checkout, signup
|
|
368
|
+
6. **Manage test data**: Isolated per test
|
|
369
|
+
7. **Visual regression**: Key pages only
|
|
370
|
+
|
|
371
|
+
## Output Checklist
|
|
372
|
+
|
|
373
|
+
- [ ] Playwright/Cypress configured
|
|
374
|
+
- [ ] Critical flows identified
|
|
375
|
+
- [ ] Page objects created
|
|
376
|
+
- [ ] Selector strategy defined (role-based)
|
|
377
|
+
- [ ] Test data management
|
|
378
|
+
- [ ] Setup/teardown hooks
|
|
379
|
+
- [ ] Authentication flow tested
|
|
380
|
+
- [ ] Error states tested
|
|
381
|
+
- [ ] Mobile viewport tests
|
|
382
|
+
- [ ] CI integration configured
|