Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
WEBSITE_URL=
WEBSITE_URL=

TEST_USER_NAME=
TEST_USER_EMAIL=
TEST_USER_PASSWORD=

TEST_ADMIN_EMAIL=
TEST_ADMIN_PASSWORD=

TEST_LAWYER_EMAIL=
TEST_LAWYER_PASSWORD=

TEST_CLIENT_EMAIL=
TEST_CLIENT_PASSWORD=
11 changes: 11 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ jobs:
runs-on: ubuntu-latest
env:
WEBSITE_URL: ${{ secrets.WEBSITE_URL }}
TEST_USER_NAME: ${{ secrets.TEST_USER_NAME }}
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }}
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
TEST_ADMIN_EMAIL: ${{ secrets.TEST_ADMIN_EMAIL }}
TEST_ADMIN_PASSWORD: ${{ secrets.TEST_ADMIN_PASSWORD }}
TEST_LAWYER_EMAIL: ${{ secrets.TEST_LAWYER_EMAIL }}
TEST_LAWYER_PASSWORD: ${{ secrets.TEST_LAWYER_PASSWORD }}
TEST_CLIENT_EMAIL: ${{ secrets.TEST_CLIENT_EMAIL }}
TEST_CLIENT_PASSWORD: ${{ secrets.TEST_CLIENT_PASSWORD }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -19,6 +28,8 @@ jobs:
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run auth setup
run: npx playwright test tests/auth.setup.ts --project=setup
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
Expand Down
82 changes: 82 additions & 0 deletions fixtures/billing-data.builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import crypto from 'crypto';
import { BillingData } from '../types/BillingData';

export class BillingDataBuilder {
private data: Partial<BillingData> = {};

constructor() {
this.withDefaults();
}

// Defaults
private withDefaults(): this {
const uniqueId = this.generateUniqueId();
this.data = {
amount: this.generateRandomAmount(),
description: `Legal consultation services ${uniqueId}`,
dueDate: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString().split('T')[0],
status: 'unpaid'
};
return this;
}

// Setters
withCaseName(caseName: string): this {
this.data.caseName = caseName;
return this;
}

withAmount(amount: string): this {
this.data.amount = amount;
return this;
}

withRandomAmount(min = 1000, max = 9999): this {
this.data.amount = this.generateRandomAmount(min, max);
return this;
}

withStatus(status: 'unpaid' | 'paid' | 'overdue'): this {
this.data.status = status;
return this;
}

withDescription(description: string): this {
this.data.description = description;
return this;
}

withDueDate(dueDate: string): this {
this.data.dueDate = dueDate;
return this;
}

private generateUniqueId(): string {
const timestamp = Date.now();
const random = crypto.randomUUID().slice(0, 8);
return `${timestamp}-${random}`;
}

private generateRandomAmount(min = 1000, max = 9999): string {
return Math.floor(Math.random() * (max - min + 1) + min).toString();
}

build(): BillingData {
const { caseName, amount, description } = this.data;
if (!caseName) throw new Error('caseName is required');
if (!amount) throw new Error('amount is required');
if (!description) throw new Error('description is required');

return this.data as BillingData;
}

static create(overrides?: Partial<BillingData>): BillingData {
const builder = new BillingDataBuilder();
if (overrides) Object.assign(builder.data, overrides);
return builder.build();
}
}

export function generateBillingData(overrides?: Partial<BillingData>): BillingData {
return BillingDataBuilder.create(overrides);
}
71 changes: 71 additions & 0 deletions fixtures/cases-data.builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import crypto from 'crypto';
import { CaseData } from '../types/CaseData';

export class CaseDataBuilder {
private data: Partial<CaseData> = {};

constructor() {
this.withDefaults();
}

// Defaults
private withDefaults(): this {
const uniqueId = this.generateUniqueId();
this.data = {
title: `Case ${uniqueId}`,
description: `Case description ${uniqueId}`,
status: 'open'
};
return this;
}

// Setters
withClient(client: string): this {
this.data.client = client;
return this;
}

withLawyer(lawyer: string): this {
this.data.lawyer = lawyer;
return this;
}

withTitle(title: string): this {
this.data.title = title;
return this;
}

withDescription(description: string): this {
this.data.description = description;
return this;
}

withStatus(status: 'open' | 'closed' | 'pending'): this {
this.data.status = status;
return this;
}

private generateUniqueId(): string {
const timestamp = Date.now();
const random = crypto.randomUUID().slice(0, 6);
return `${timestamp}-${random}`;
}

build(): CaseData {
const { title, description } = this.data;
if (!title) throw new Error('title is required');
if (!description) throw new Error('description is required');

return this.data as CaseData;
}

static create(overrides?: Partial<CaseData>): CaseData {
const builder = new CaseDataBuilder();
if (overrides) Object.assign(builder.data, overrides);
return builder.build();
}
}

export function generateCaseData(overrides?: Partial<CaseData>): CaseData {
return CaseDataBuilder.create(overrides);
}
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"license": "ISC",
"description": "",
"devDependencies": {
"@playwright/test": "^1.55.0",
"@playwright/test": "^1.56.1",
"@types/node": "^24.3.0"
},
"dependencies": {
"dotenv": "^17.2.1"
"dotenv": "^17.2.3"
}
}
Loading