test(e2e): Add Playwright tests for cadastro fundo wizard#1
Conversation
jlagedo
commented
Jan 22, 2026
- Add page objects for wizard navigation (WizardPage, IdentificacaoStepPage, ClassificacaoStepPage)
- Add data persistence tests for Step 1 to Step 2 navigation
- Add navigation tests for step transitions and sidebar
- Add validation tests for CNPJ, required fields, and dates
- Update baseURL to localhost:4200 (Angular UI)
- Add seed test for initial wizard navigation
- Add page objects for wizard navigation (WizardPage, IdentificacaoStepPage, ClassificacaoStepPage) - Add data persistence tests for Step 1 to Step 2 navigation - Add navigation tests for step transitions and sidebar - Add validation tests for CNPJ, required fields, and dates - Update baseURL to localhost:4200 (Angular UI) - Add seed test for initial wizard navigation
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive Playwright end-to-end tests for a fund registration wizard ("cadastro fundo wizard"). The tests cover form validation, navigation, and data persistence across multiple wizard steps.
Changes:
- Added page object models (WizardPage, IdentificacaoStepPage, ClassificacaoStepPage) for wizard interactions
- Added validation tests for CNPJ, required fields, dates, and form auto-fill behavior
- Added navigation tests for step transitions, sidebar navigation, and progress tracking
- Added data persistence tests to verify form data is preserved across step navigation
- Updated baseURL from localhost:5071 to localhost:4200 for Angular UI testing
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/core-ledger-e2e/playwright.config.ts | Updated baseURL to point to Angular UI on port 4200 |
| apps/core-ledger-e2e/tests/page-objects/wizard.page.ts | Implements page object pattern with three classes for wizard interactions |
| apps/core-ledger-e2e/tests/wizard-validation.spec.ts | Tests form validation including CNPJ, required fields, dates, and auto-fill |
| apps/core-ledger-e2e/tests/wizard-navigation.spec.ts | Tests step navigation, sidebar interaction, and progress tracking |
| apps/core-ledger-e2e/tests/data-persistence/step-1-to-2-persistence.spec.ts | Tests data preservation during forward and backward navigation |
| apps/core-ledger-e2e/tests/seed.spec.ts | Seed test for initial wizard navigation setup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Wait for spinner to appear (if it will) | ||
| await this.page.waitForTimeout(500); | ||
| // Wait for spinner to disappear | ||
| await this.cnpjSpinner.waitFor({ state: 'hidden', timeout: 10000 }).catch(() => {}); | ||
| // Additional wait for validation result to render | ||
| await this.page.waitForTimeout(500); |
There was a problem hiding this comment.
The hardcoded timeout of 500ms used throughout this file may cause flaky tests. Consider using Playwright's built-in wait mechanisms like waitForSelector or expect with timeout options instead of arbitrary waits.
| // Wait for spinner to appear (if it will) | |
| await this.page.waitForTimeout(500); | |
| // Wait for spinner to disappear | |
| await this.cnpjSpinner.waitFor({ state: 'hidden', timeout: 10000 }).catch(() => {}); | |
| // Additional wait for validation result to render | |
| await this.page.waitForTimeout(500); | |
| // Wait for spinner to appear (if it will), but don't fail if it never shows up | |
| try { | |
| await this.cnpjSpinner.waitFor({ state: 'visible', timeout: 2000 }); | |
| } catch { | |
| // Spinner did not appear within 2s; continue to wait for completion state. | |
| } | |
| // Wait for spinner to disappear | |
| await this.cnpjSpinner.waitFor({ state: 'hidden', timeout: 10000 }).catch(() => {}); | |
| // Wait for validation result (either success or error message) to render | |
| await Promise.race([ | |
| this.cnpjValidMessage.waitFor({ state: 'visible', timeout: 10000 }), | |
| this.cnpjErrorMessage.waitFor({ state: 'visible', timeout: 10000 }), | |
| ]).catch(() => {}); |
| // Wait for spinner to appear (if it will) | ||
| await this.page.waitForTimeout(500); | ||
| // Wait for spinner to disappear | ||
| await this.cnpjSpinner.waitFor({ state: 'hidden', timeout: 10000 }).catch(() => {}); |
There was a problem hiding this comment.
The error handling in waitForCnpjValidation silently catches all exceptions with an empty catch block. This can hide real issues during test execution. Consider logging the error or only catching specific expected exceptions.
| await this.cnpjSpinner.waitFor({ state: 'hidden', timeout: 10000 }).catch(() => {}); | |
| await this.cnpjSpinner | |
| .waitFor({ state: 'hidden', timeout: 10000 }) | |
| .catch((error) => { | |
| console.error('Error while waiting for CNPJ spinner to be hidden:', error); | |
| }); |
| await this.fillDataInicioAtividade(data.dataInicioAtividade); | ||
| // Trigger final blur | ||
| await this.dataInicioAtividadeField.blur(); | ||
| await this.page.waitForTimeout(300); |
There was a problem hiding this comment.
Multiple methods use hardcoded timeouts (300ms, 500ms) throughout this class. This makes tests less reliable and harder to maintain. Consider replacing these with deterministic waits that check for actual state changes or UI conditions.
| await this.page.waitForTimeout(300); | |
| await this.page.waitForLoadState('networkidle'); |
| // Wait a bit for validation | ||
| await page.waitForTimeout(500); | ||
|
|
There was a problem hiding this comment.
Hardcoded timeout of 500ms is used here. Consider using Playwright's auto-waiting mechanisms or more explicit state checks instead of arbitrary time-based waits.
| // Wait a bit for validation | |
| await page.waitForTimeout(500); |
| await wizardPage.clickNext(); | ||
|
|
||
| // Verify we're on Step 2 | ||
| await expect(wizardPage.stepTitle).toContainText('Classificacao'); |
There was a problem hiding this comment.
Spelling error: 'Classificacao' should be 'Classificação' with a tilde. This spelling error appears consistently throughout the test names and assertions.
|
|
||
| // Should show error for minimum length | ||
| const errorText = await page.locator('.step-field:has(#razaoSocial) .step-field__error').textContent(); | ||
| expect(errorText).toContain('minimo 10 caracteres'); |
There was a problem hiding this comment.
Spelling error: 'minimo' should be 'mínimo' with an accent. The error message text being tested should use proper Portuguese spelling with the accented character.
| expect(errorText).toContain('minimo 10 caracteres'); | |
| expect(errorText).toContain('mínimo 10 caracteres'); |
|
|
||
| // Trigger blur to complete form interaction | ||
| await step1Page.dataInicioAtividadeField.blur(); | ||
| await page.waitForTimeout(500); |
There was a problem hiding this comment.
Multiple hardcoded timeouts (300ms, 500ms) are used in this test file. These arbitrary waits make tests less reliable and slower. Consider using Playwright's auto-waiting mechanisms or explicit state checks instead.
| await page.waitForTimeout(500); |
|
|
||
| // Validation | ||
| this.cnpjSpinner = page.locator('.step-field__spinner'); | ||
| this.cnpjValidMessage = page.locator('.step-field__success').filter({ hasText: 'CNPJ valido e disponivel' }); |
There was a problem hiding this comment.
Spelling error: 'disponivel' should be 'disponível' with an accent. The success message filter text should use proper Portuguese spelling.
| this.cnpjValidMessage = page.locator('.step-field__success').filter({ hasText: 'CNPJ valido e disponivel' }); | |
| this.cnpjValidMessage = page.locator('.step-field__success').filter({ hasText: 'CNPJ válido e disponível' }); |
| @@ -0,0 +1,411 @@ | |||
| import { type Locator, type Page, expect } from '@playwright/test'; | |||
There was a problem hiding this comment.
Unused import expect.
| import { type Locator, type Page, expect } from '@playwright/test'; | |
| import { type Locator, type Page } from '@playwright/test'; |
| await expect(wizardPage.stepTitle).toContainText('Classificacao'); | ||
|
|
||
| // 25. Verify all Step 2 data is preserved | ||
| const step2Values = await step2Page.getFieldValues(); |
There was a problem hiding this comment.
Unused variable step2Values.
| const step2Values = await step2Page.getFieldValues(); | |
| await step2Page.getFieldValues(); |