feat: add coolify deployment and meta tracking
This commit is contained in:
20
tests/deploy.test.ts
Normal file
20
tests/deploy.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
describe('Coolify and Nixpacks deployment config', () => {
|
||||
it('defines a production start script that binds to all interfaces and PORT', () => {
|
||||
const packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
|
||||
|
||||
expect(packageJson.scripts.start).toContain('astro preview');
|
||||
expect(packageJson.scripts.start).toContain('--host 0.0.0.0');
|
||||
expect(packageJson.scripts.start).toContain('${PORT:-4321}');
|
||||
});
|
||||
|
||||
it('pins Nixpacks install, build, and start commands for Coolify', () => {
|
||||
const nixpacks = readFileSync('nixpacks.toml', 'utf8');
|
||||
|
||||
expect(nixpacks).toContain('npm ci');
|
||||
expect(nixpacks).toContain('npm run build');
|
||||
expect(nixpacks).toContain('npm run start');
|
||||
});
|
||||
});
|
||||
63
tests/meta.test.ts
Normal file
63
tests/meta.test.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildMetaCapiPayload, contactEventParams, pageViewEventParams } from '../src/lib/meta';
|
||||
|
||||
describe('Meta tracking helpers', () => {
|
||||
it('builds rich Contact event params for vehicle inquiries', () => {
|
||||
expect(
|
||||
contactEventParams({
|
||||
channel: 'whatsapp',
|
||||
make: 'BMW',
|
||||
model: '320d',
|
||||
slug: 'bmw-320d-2018-vilnius',
|
||||
price: 12500,
|
||||
}),
|
||||
).toEqual({
|
||||
content_category: 'Vehicle',
|
||||
content_name: 'BMW 320d',
|
||||
content_ids: ['bmw-320d-2018-vilnius'],
|
||||
contact_channel: 'whatsapp',
|
||||
currency: 'EUR',
|
||||
value: 12500,
|
||||
});
|
||||
});
|
||||
|
||||
it('builds PageView params with content context', () => {
|
||||
expect(pageViewEventParams('/automobiliai/bmw-320d-2018-vilnius')).toEqual({
|
||||
content_category: 'VehicleListing',
|
||||
page_path: '/automobiliai/bmw-320d-2018-vilnius',
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps generic contact page inquiries separate from vehicle listing contacts', () => {
|
||||
expect(contactEventParams({ channel: 'phone' })).toEqual({
|
||||
content_category: 'SiteContact',
|
||||
contact_channel: 'phone',
|
||||
});
|
||||
});
|
||||
|
||||
it('builds a CAPI-ready browser payload with dedupe event id', () => {
|
||||
const payload = buildMetaCapiPayload({
|
||||
eventName: 'Contact',
|
||||
eventId: 'contact-123',
|
||||
eventSourceUrl: 'https://auto.juozas.lt/automobiliai/bmw-320d-2018-vilnius',
|
||||
userAgent: 'Mozilla/5.0',
|
||||
fbp: 'fb.1.123',
|
||||
fbc: 'fb.1.456',
|
||||
customData: { content_name: 'BMW 320d' },
|
||||
});
|
||||
|
||||
expect(payload).toMatchObject({
|
||||
event_name: 'Contact',
|
||||
event_id: 'contact-123',
|
||||
action_source: 'website',
|
||||
event_source_url: 'https://auto.juozas.lt/automobiliai/bmw-320d-2018-vilnius',
|
||||
user_data: {
|
||||
client_user_agent: 'Mozilla/5.0',
|
||||
fbp: 'fb.1.123',
|
||||
fbc: 'fb.1.456',
|
||||
},
|
||||
custom_data: { content_name: 'BMW 320d' },
|
||||
});
|
||||
expect(payload.event_time).toBeTypeOf('number');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user