Skip to content

test(e2e): Add Playwright tests for cadastro fundo wizard#1

Open
jlagedo wants to merge 1 commit into
mainfrom
claude/playwright-tests-cadastro-fundo-v2v7o
Open

test(e2e): Add Playwright tests for cadastro fundo wizard#1
jlagedo wants to merge 1 commit into
mainfrom
claude/playwright-tests-cadastro-fundo-v2v7o

Conversation

@jlagedo

@jlagedo jlagedo commented Jan 22, 2026

Copy link
Copy Markdown
Owner
  • 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
Copilot AI review requested due to automatic review settings January 22, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +208 to +213
// 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);

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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(() => {});

Copilot uses AI. Check for mistakes.
// 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(() => {});

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);
});

Copilot uses AI. Check for mistakes.
await this.fillDataInicioAtividade(data.dataInicioAtividade);
// Trigger final blur
await this.dataInicioAtividadeField.blur();
await this.page.waitForTimeout(300);

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
await this.page.waitForTimeout(300);
await this.page.waitForLoadState('networkidle');

Copilot uses AI. Check for mistakes.
Comment on lines +129 to +131
// Wait a bit for validation
await page.waitForTimeout(500);

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// Wait a bit for validation
await page.waitForTimeout(500);

Copilot uses AI. Check for mistakes.
await wizardPage.clickNext();

// Verify we're on Step 2
await expect(wizardPage.stepTitle).toContainText('Classificacao');

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: 'Classificacao' should be 'Classificação' with a tilde. This spelling error appears consistently throughout the test names and assertions.

Copilot uses AI. Check for mistakes.

// 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');

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
expect(errorText).toContain('minimo 10 caracteres');
expect(errorText).toContain('mínimo 10 caracteres');

Copilot uses AI. Check for mistakes.

// Trigger blur to complete form interaction
await step1Page.dataInicioAtividadeField.blur();
await page.waitForTimeout(500);

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
await page.waitForTimeout(500);

Copilot uses AI. Check for mistakes.

// Validation
this.cnpjSpinner = page.locator('.step-field__spinner');
this.cnpjValidMessage = page.locator('.step-field__success').filter({ hasText: 'CNPJ valido e disponivel' });

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: 'disponivel' should be 'disponível' with an accent. The success message filter text should use proper Portuguese spelling.

Suggested change
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' });

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,411 @@
import { type Locator, type Page, expect } from '@playwright/test';

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import expect.

Suggested change
import { type Locator, type Page, expect } from '@playwright/test';
import { type Locator, type Page } from '@playwright/test';

Copilot uses AI. Check for mistakes.
await expect(wizardPage.stepTitle).toContainText('Classificacao');

// 25. Verify all Step 2 data is preserved
const step2Values = await step2Page.getFieldValues();

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable step2Values.

Suggested change
const step2Values = await step2Page.getFieldValues();
await step2Page.getFieldValues();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants