@bugzy-ai/bugzy 1.6.0 → 1.8.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.
@@ -584,6 +584,96 @@ export default defineConfig({
584
584
  });
585
585
  ```
586
586
 
587
+ ## Test Cleanup Strategy
588
+
589
+ **Design Principle**: Each test cleans up what IT creates. No pre-cleanup needed.
590
+
591
+ ### Why Post-Test Cleanup (Not Pre-Test)
592
+
593
+ Pre-test cleanup adds complexity:
594
+ - Extra login/logout cycles before each test
595
+ - Longer timeouts (5 min vs 3 min)
596
+ - Test code cluttered with cleanup steps
597
+ - Test failures can leave cleanup incomplete
598
+
599
+ Post-test cleanup via fixtures is better:
600
+ - Runs AFTER test completes (pass or fail)
601
+ - Automatic - no manual steps in test code
602
+ - Cleaner test flow focused on main scenario
603
+ - Guaranteed execution
604
+
605
+ ### Cleanup Fixture Pattern
606
+
607
+ ```typescript
608
+ // Import from cleanup fixture instead of pages fixture
609
+ import { test, expect } from '../../fixtures/cleanup.fixture';
610
+
611
+ test('create absence', async ({
612
+ page,
613
+ loginPage,
614
+ navigationPage,
615
+ myAbsencesPage,
616
+ withAbsenceCleanup // Triggers cleanup after test
617
+ }) => {
618
+ // Reference fixture to satisfy TypeScript
619
+ void withAbsenceCleanup;
620
+
621
+ // Main test flow - no pre-cleanup needed
622
+ await test.step('Login as employee', async () => {
623
+ await loginPage.navigateToLogin();
624
+ await loginPage.login(email, password);
625
+ // ...
626
+ });
627
+
628
+ await test.step('Create absence with privacy="Yes"', async () => {
629
+ // CRITICAL: Use privacy="Yes" so admin can see and delete during cleanup
630
+ await myAbsencesPage.createAbsence({ privacy: 'Yes', ... });
631
+ });
632
+
633
+ // Cleanup runs automatically after test (pass or fail)
634
+ });
635
+ ```
636
+
637
+ ### When to Use Cleanup Fixtures
638
+
639
+ | Scenario | Use Cleanup Fixture? |
640
+ |----------|---------------------|
641
+ | Test creates data (absences, users, etc.) | Yes - use `cleanup.fixture.ts` |
642
+ | Read-only test (verify UI, check dropdown options) | No - use `pages.fixture.ts` |
643
+ | Test modifies then deletes own data | Optional - cleanup acts as safety net |
644
+
645
+ ### Creating Custom Cleanup Fixtures
646
+
647
+ ```typescript
648
+ // tests/fixtures/cleanup.fixture.ts
649
+ export const test = pagesTest.extend<CleanupFixtures>({
650
+ withAbsenceCleanup: [
651
+ async ({ page }, use) => {
652
+ // Run the test first
653
+ await use();
654
+
655
+ // POST-TEST CLEANUP: Clean up what the test created
656
+ await cleanupTestAbsences({ page, ... });
657
+ },
658
+ { auto: false }, // Must be explicitly requested
659
+ ],
660
+ });
661
+ ```
662
+
663
+ Key implementation details:
664
+ - `await use()` runs the test
665
+ - Cleanup code runs AFTER `use()` returns
666
+ - `{ auto: false }` means test must include fixture in parameters
667
+ - Cleanup should handle errors gracefully (non-blocking)
668
+
669
+ ### Privacy Setting for Admin Cleanup
670
+
671
+ **CRITICAL**: When admin cleans up absences created by employee tests:
672
+ - Absences with `privacy="Yes"` are visible to admin
673
+ - Absences with `privacy="No"` are hidden from admin
674
+
675
+ **Rule**: Tests MUST create absences with `privacy="Yes"` to enable admin cleanup.
676
+
587
677
  ## Production-Ready Checklist
588
678
 
589
679
  **Configuration:**
@@ -607,6 +697,7 @@ export default defineConfig({
607
697
  - [ ] Framework validated with ONE working test before scaling
608
698
  - [ ] Smoke tests tagged with @smoke for CI/CD
609
699
  - [ ] All tests use `test.step()` for video-navigable execution (3-7 steps per test)
700
+ - [ ] Tests that create data use cleanup fixtures (post-test cleanup, no pre-cleanup)
610
701
 
611
702
  **Test Independence Validation:**
612
703
  - [ ] Each test can run in isolation: `npx playwright test <single-test>`
@@ -624,9 +715,10 @@ export default defineConfig({
624
715
 
625
716
  ---
626
717
 
627
- **Remember**: The five critical pillars are:
718
+ **Remember**: The six critical pillars are:
628
719
  1. **Two-Phase Approach** - Separate WHAT to test from HOW to automate
629
720
  2. **Test One First** - Validate framework with ONE working test before scaling
630
721
  3. **Page Object Model** - Isolate UI changes from test logic
631
722
  4. **Role-based selectors** - Resist breakage with semantic HTML
632
723
  5. **Authentication state reuse** - Maximize speed and reliability
724
+ 6. **Post-test cleanup** - Each test cleans up what IT creates via fixtures