initial
This commit is contained in:
8
web/tests/e2e/hero.spec.ts
Normal file
8
web/tests/e2e/hero.spec.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('hero renders and CTA works', async ({ page }) => {
|
||||
await page.goto('http://localhost:3000');
|
||||
await expect(page.getByRole('heading', { name: /Electricians in Corpus Christi/i })).toBeVisible();
|
||||
const cta = page.getByRole('link', { name: /Get My Free Quote/i }).first();
|
||||
await expect(cta).toBeVisible();
|
||||
});
|
||||
5
web/tests/playwright.config.ts
Normal file
5
web/tests/playwright.config.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { defineConfig } from '@playwright/test';
|
||||
export default defineConfig({
|
||||
webServer: { command: 'npm run dev', port: 3000, cwd: 'web', reuseExistingServer: !process.env.CI },
|
||||
testDir: './e2e'
|
||||
});
|
||||
26
web/tests/unit/contact-schema.test.ts
Normal file
26
web/tests/unit/contact-schema.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { z } from 'zod';
|
||||
|
||||
const schema = z.object({
|
||||
name: z.string().min(2),
|
||||
phone: z.string().min(7),
|
||||
email: z.string().email(),
|
||||
address: z.string().optional(),
|
||||
projectType: z.string().min(2),
|
||||
urgency: z.string().min(2),
|
||||
description: z.string().min(10)
|
||||
});
|
||||
|
||||
describe('contact schema', () => {
|
||||
it('accepts valid payload', () => {
|
||||
const out = schema.safeParse({
|
||||
name: 'Jane',
|
||||
phone: '361-555-0000',
|
||||
email: 'j@x.com',
|
||||
projectType: 'Residential',
|
||||
urgency: 'Now',
|
||||
description: 'Lights out in kitchen'
|
||||
});
|
||||
expect(out.success).toBe(true);
|
||||
});
|
||||
});
|
||||
7
web/tests/unit/utils.test.ts
Normal file
7
web/tests/unit/utils.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { formatPhone } from '@/lib/utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
describe('formatPhone', () => {
|
||||
it('formats a raw phone string', () => {
|
||||
expect(formatPhone('+1 (361) 885-0315')).toBe('(361) 885-0315');
|
||||
});
|
||||
});
|
||||
1
web/tests/vitest.config.ts
Normal file
1
web/tests/vitest.config.ts
Normal file
@@ -0,0 +1 @@
|
||||
import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { environment: 'node' } });
|
||||
Reference in New Issue
Block a user