Skip to content

Commit 3f1bef2

Browse files
committed
tests
1 parent 182b8de commit 3f1bef2

21 files changed

+4820
-28
lines changed

README.md

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,25 @@ confac-playwright/
4141
│ ├── baseline-data.json # Baseline test data
4242
│ └── seed.ts # Database seeding script
4343
├── helpers/
44+
│ ├── pages/ # Page Object Models
45+
│ │ ├── BasePage.ts # Common page functionality
46+
│ │ ├── ConsultantPage.ts
47+
│ │ ├── ClientPage.ts
48+
│ │ ├── ProjectPage.ts
49+
│ │ └── InvoicePage.ts
50+
│ ├── data/ # Test data generators
51+
│ │ └── test-data-generators.ts
4452
│ ├── MockClient.ts # Mock service client (/prime, /calls)
45-
│ ├── test-fixtures.ts # Playwright fixtures
46-
│ └── *.ts # Page Object Models
53+
│ ├── test-fixtures.ts # Playwright fixtures with page objects
54+
│ ├── Dropdown.ts # React-select dropdown helper
55+
│ └── NotesModal.ts # Notes/comments modal helper
4756
└── tests/
48-
└── *.spec.ts # Test files
57+
├── specs/
58+
│ ├── entities/ # CRUD tests (~78 tests)
59+
│ ├── flows/ # End-to-end flows (~5 tests)
60+
│ ├── claims/ # Permission tests (~15 tests)
61+
│ └── integrations/ # External service tests (~18 tests)
62+
└── *.spec.ts # Legacy test files
4963
```
5064

5165
## Running Tests
@@ -206,32 +220,64 @@ test.describe('Invoice Peppol Integration', () => {
206220
207221
### Page Object Model
208222
223+
Page objects are available as fixtures:
224+
225+
```typescript
226+
import { test, expect } from '../helpers/test-fixtures';
227+
228+
test('create a consultant', async ({ consultantPage, loginAs }) => {
229+
await loginAs('admin');
230+
231+
await consultantPage.gotoCreate();
232+
await consultantPage.fill({
233+
firstName: 'John',
234+
name: 'Doe',
235+
email: 'john.doe@example.com',
236+
type: 'consultant',
237+
});
238+
await consultantPage.save();
239+
await consultantPage.expectSaveSuccess();
240+
});
241+
```
242+
243+
Available page fixtures: `consultantPage`, `clientPage`, `projectPage`, `invoicePage`
244+
245+
### Test Data Generators
246+
247+
Generate realistic test data using Faker.js:
248+
209249
```typescript
210-
// helpers/InvoicePage.ts
211-
export class InvoicePage {
212-
constructor(private page: Page) {}
213-
214-
async goto() {
215-
await this.page.goto('/invoices');
216-
}
217-
218-
async create(data: InvoiceData) {
219-
await this.page.getByTestId('create-invoice').click();
220-
await this.page.getByTestId('client').fill(data.client);
221-
// ...
222-
}
223-
224-
get invoiceList() {
225-
return this.page.getByTestId('invoice-list');
226-
}
227-
}
250+
import {
251+
generateConsultant,
252+
generateClient,
253+
generateBtwResponse,
254+
generateInvoice,
255+
generatePeppolSuccessResponse,
256+
} from '../helpers/data/test-data-generators';
257+
258+
// Generate random consultant data
259+
const consultant = generateConsultant({ type: 'freelancer' });
260+
261+
// Generate BTW lookup response
262+
const btwResponse = generateBtwResponse();
263+
264+
// Generate invoice with custom values
265+
const invoice = generateInvoice('clientId', {
266+
status: 'new',
267+
lines: [generateInvoiceLine({ desc: 'Consultancy', price: 750 })],
268+
});
228269
```
229270
230271
## Scripts Reference
231272
232273
| Script | Description |
233274
|--------|-------------|
234275
| `npm test` | Run all tests |
276+
| `npm run test:e2e` | Run all E2E spec tests |
277+
| `npm run test:entities` | Run entity CRUD tests |
278+
| `npm run test:flows` | Run end-to-end flow tests |
279+
| `npm run test:integrations` | Run integration tests (Peppol, Excel) |
280+
| `npm run test:claims` | Run permission/claims tests |
235281
| `npm run ui` | Interactive UI mode |
236282
| `npm run headed` | Run with visible browser |
237283
| `npm run debug` | Debug mode with inspector |

helpers/data/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Test data generators for Confac E2E tests
3+
* Re-exports all data generation functions
4+
*/
5+
6+
export * from './test-data-generators';

0 commit comments

Comments
 (0)