mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:51:12 -05:00
feat: Implement Playwright testing setup
This commit is contained in:
140
tests/fixtures/test-data.ts
vendored
Normal file
140
tests/fixtures/test-data.ts
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* Test Data Generators
|
||||
*
|
||||
* Factory functions for creating realistic test data.
|
||||
*/
|
||||
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
export interface ParkTestData {
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
park_type: string;
|
||||
status: string;
|
||||
location_country: string;
|
||||
location_city: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
opened_date: string;
|
||||
is_test_data: boolean;
|
||||
}
|
||||
|
||||
export interface RideTestData {
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
category: string;
|
||||
status: string;
|
||||
park_id: string;
|
||||
opened_date: string;
|
||||
is_test_data: boolean;
|
||||
}
|
||||
|
||||
export interface CompanyTestData {
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
company_type: string;
|
||||
person_type: string;
|
||||
founded_date: string;
|
||||
is_test_data: boolean;
|
||||
}
|
||||
|
||||
export interface RideModelTestData {
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
category: string;
|
||||
manufacturer_id: string;
|
||||
is_test_data: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate random park test data
|
||||
*/
|
||||
export function generateParkData(overrides?: Partial<ParkTestData>): ParkTestData {
|
||||
const name = faker.company.name() + ' Park';
|
||||
|
||||
return {
|
||||
name,
|
||||
slug: faker.helpers.slugify(name).toLowerCase(),
|
||||
description: faker.lorem.paragraphs(2),
|
||||
park_type: faker.helpers.arrayElement(['theme_park', 'amusement_park', 'water_park']),
|
||||
status: faker.helpers.arrayElement(['operating', 'closed', 'under_construction']),
|
||||
location_country: faker.location.countryCode(),
|
||||
location_city: faker.location.city(),
|
||||
latitude: parseFloat(faker.location.latitude()),
|
||||
longitude: parseFloat(faker.location.longitude()),
|
||||
opened_date: faker.date.past({ years: 50 }).toISOString().split('T')[0],
|
||||
is_test_data: true,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate random ride test data
|
||||
*/
|
||||
export function generateRideData(parkId: string, overrides?: Partial<RideTestData>): RideTestData {
|
||||
const name = faker.word.adjective() + ' ' + faker.word.noun();
|
||||
|
||||
return {
|
||||
name,
|
||||
slug: faker.helpers.slugify(name).toLowerCase(),
|
||||
description: faker.lorem.paragraphs(2),
|
||||
category: faker.helpers.arrayElement(['roller_coaster', 'flat_ride', 'water_ride', 'dark_ride']),
|
||||
status: faker.helpers.arrayElement(['operating', 'closed', 'sbno']),
|
||||
park_id: parkId,
|
||||
opened_date: faker.date.past({ years: 30 }).toISOString().split('T')[0],
|
||||
is_test_data: true,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate random company test data
|
||||
*/
|
||||
export function generateCompanyData(
|
||||
companyType: 'manufacturer' | 'designer' | 'operator' | 'property_owner',
|
||||
overrides?: Partial<CompanyTestData>
|
||||
): CompanyTestData {
|
||||
const name = faker.company.name();
|
||||
|
||||
return {
|
||||
name,
|
||||
slug: faker.helpers.slugify(name).toLowerCase(),
|
||||
description: faker.lorem.paragraphs(2),
|
||||
company_type: companyType,
|
||||
person_type: faker.helpers.arrayElement(['individual', 'company']),
|
||||
founded_date: faker.date.past({ years: 100 }).toISOString().split('T')[0],
|
||||
is_test_data: true,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate random ride model test data
|
||||
*/
|
||||
export function generateRideModelData(
|
||||
manufacturerId: string,
|
||||
overrides?: Partial<RideModelTestData>
|
||||
): RideModelTestData {
|
||||
const name = faker.word.adjective() + ' Model';
|
||||
|
||||
return {
|
||||
name,
|
||||
slug: faker.helpers.slugify(name).toLowerCase(),
|
||||
description: faker.lorem.paragraphs(2),
|
||||
category: faker.helpers.arrayElement(['roller_coaster', 'flat_ride', 'water_ride']),
|
||||
manufacturer_id: manufacturerId,
|
||||
is_test_data: true,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate unique test identifier
|
||||
*/
|
||||
export function generateTestId(): string {
|
||||
return `test-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user