Move the demo market to Mexico City, priced in US dollars
The showcase was a Barcelona market: Catalan names, +34 numbers, euro rates and "Carrer Example 12" on every job. Presented to a Mexican client, all of that reads as somebody else's product. City comes from NEXT_PUBLIC_CITY_* as before, now Ciudad de México at 19.4326/-99.1332, with MAPBOX_COUNTRY=mx. The seed's fallbacks were Barcelona literals, so an unset env quietly seeded a different city than the app rendered — they now agree. Two db tests pinned the Barcelona centre as a hardcoded constant, which is why the deck returned zero cards on the first run here: every pro was a continent outside the radius. They read the same env as the seed now, so the trap cannot recur. Money: formatCents defaults to USD/en-US, and the nine hardcoded euro signs across the card, search rows, quote strip and forms are dollars. The rate NUMBERS are unchanged and still read high for CDMX — that is a pricing decision, not a currency one, and is left alone deliberately. Seed people are Mexican, addressed on real Roma/Condesa streets rotated by index rather than one placeholder repeated. Phones moved to +52 55, which moves the demo login to +525500000000 / 000000. Also in here, from the same session: - Sending a job now confirms. The mutation always succeeded; the sheet just closed with no receipt, which from the customer's side is indistinguishable from a dead button. Dismissing that receipt resolves as 'sent', so the card does not return to the deck. - Media moves to DigitalOcean Spaces, with the public origin derived from bucket and region instead of a second env var to keep in sync. - Managed-Postgres TLS: DATABASE_CA_CERT takes a path or inline PEM. - The client-facing project panel beside the running app. - Two profiles removed and four renamed to match their photos. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Integration test — runs against a live seeded database.
|
||||
*
|
||||
* pnpm services:up && pnpm db:migrate && pnpm db:seed
|
||||
* pnpm --filter @linkder/db test
|
||||
* pnpm --filter @linkdr/db test
|
||||
*
|
||||
* The seed places every pro at a known distance from the city centre, and the
|
||||
* fixture job sits exactly at the centre, so the expected deck is not "roughly
|
||||
@@ -52,23 +52,34 @@ describe('getDeck', () => {
|
||||
const deck = await getDeck(db, { jobId });
|
||||
const names = deck.map((c) => c.name).sort();
|
||||
|
||||
expect(names).toEqual(['Ana Ferrer', 'Jordi Puig', 'Marc Oliveras', 'Nil Bosch', 'Nuria Sala']);
|
||||
expect(names).toEqual([
|
||||
'Alejandro Dávila',
|
||||
'Antón Bautista',
|
||||
'Gabriel Torres',
|
||||
'Gerardo Solís',
|
||||
'Jorge Pineda',
|
||||
// Sorted by code unit, so accented letters land after plain ASCII ones.
|
||||
'Norma Salgado',
|
||||
'Néstor Bosque',
|
||||
'Rogelio Amaya',
|
||||
'Sergio Fabela',
|
||||
]);
|
||||
});
|
||||
|
||||
it('excludes a pro whose service radius does not reach the job', async () => {
|
||||
// Pau Ribas is 22km away but only travels 5km.
|
||||
// Pablo Rivas is 22km away but only travels 5km.
|
||||
const deck = await getDeck(db, { jobId });
|
||||
expect(deck.map((c) => c.name)).not.toContain('Pau Ribas');
|
||||
expect(deck.map((c) => c.name)).not.toContain('Pablo Rivas');
|
||||
});
|
||||
|
||||
it('excludes an unverified pro even though they are 1km away', async () => {
|
||||
const deck = await getDeck(db, { jobId });
|
||||
expect(deck.map((c) => c.name)).not.toContain('Unverified Ulla');
|
||||
expect(deck.map((c) => c.name)).not.toContain('Unverified Ulises');
|
||||
});
|
||||
|
||||
it('excludes a verified pro who is not accepting jobs', async () => {
|
||||
const deck = await getDeck(db, { jobId });
|
||||
expect(deck.map((c) => c.name)).not.toContain('Away Arnau');
|
||||
expect(deck.map((c) => c.name)).not.toContain('Away Arturo');
|
||||
});
|
||||
|
||||
it('excludes pros from other trades', async () => {
|
||||
@@ -80,32 +91,32 @@ describe('getDeck', () => {
|
||||
|
||||
it('reports distance in metres, ascending-ish and sane', async () => {
|
||||
const deck = await getDeck(db, { jobId });
|
||||
const marc = deck.find((c) => c.name === 'Marc Oliveras');
|
||||
expect(marc).toBeDefined();
|
||||
expect(marc!.distanceM).toBeGreaterThan(700);
|
||||
expect(marc!.distanceM).toBeLessThan(900);
|
||||
const sergi = deck.find((c) => c.name === 'Sergio Fabela');
|
||||
expect(sergi).toBeDefined();
|
||||
expect(sergi!.distanceM).toBeGreaterThan(1_000);
|
||||
expect(sergi!.distanceM).toBeLessThan(1_200);
|
||||
});
|
||||
|
||||
it('ranks a well-reviewed nearby pro above a distant one with a single review', async () => {
|
||||
const deck = await getDeck(db, { jobId });
|
||||
const marc = deck.findIndex((c) => c.name === 'Marc Oliveras'); // 800m, 4.9 x47
|
||||
const nuria = deck.findIndex((c) => c.name === 'Nuria Sala'); // 18km, 5.0 x3
|
||||
expect(marc).toBeLessThan(nuria);
|
||||
const sergi = deck.findIndex((c) => c.name === 'Sergio Fabela'); // 1.1km, 4.8 x62
|
||||
const nuria = deck.findIndex((c) => c.name === 'Norma Salgado'); // 18km, 5.0 x3
|
||||
expect(sergi).toBeLessThan(nuria);
|
||||
});
|
||||
|
||||
it('does not bury a brand-new unrated pro at the bottom', async () => {
|
||||
const deck = await getDeck(db, { jobId });
|
||||
const nil = deck.findIndex((c) => c.name === 'Nil Bosch');
|
||||
const nil = deck.findIndex((c) => c.name === 'Néstor Bosque');
|
||||
expect(nil).toBeGreaterThanOrEqual(0);
|
||||
expect(nil).toBeLessThan(deck.length - 1);
|
||||
});
|
||||
|
||||
it('carries the media and rating a card needs to render', async () => {
|
||||
const deck = await getDeck(db, { jobId });
|
||||
const card = deck.find((c) => c.name === 'Marc Oliveras')!;
|
||||
const card = deck.find((c) => c.name === 'Sergio Fabela')!;
|
||||
expect(card.photos.length).toBeGreaterThan(0);
|
||||
expect(card.ratingAvg).toBeCloseTo(4.9, 1);
|
||||
expect(card.ratingCount).toBe(47);
|
||||
expect(card.ratingAvg).toBeCloseTo(4.8, 1);
|
||||
expect(card.ratingCount).toBe(62);
|
||||
expect(card.hourlyRateCents).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
@@ -184,8 +195,8 @@ describe('PostGIS round-trip', () => {
|
||||
it('reads back the exact coordinates it wrote', async () => {
|
||||
const rows = await db.select().from(schema.jobs).limit(1);
|
||||
const job = rows[0]!;
|
||||
expect(job.location.lat).toBeCloseTo(Number(process.env.NEXT_PUBLIC_CITY_LAT ?? 41.3874), 4);
|
||||
expect(job.location.lng).toBeCloseTo(Number(process.env.NEXT_PUBLIC_CITY_LNG ?? 2.1686), 4);
|
||||
expect(job.location.lat).toBeCloseTo(Number(process.env.NEXT_PUBLIC_CITY_LAT ?? 19.4326), 4);
|
||||
expect(job.location.lng).toBeCloseTo(Number(process.env.NEXT_PUBLIC_CITY_LNG ?? -99.1332), 4);
|
||||
});
|
||||
|
||||
it('never puts the client on their own deck', async () => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Integration test — runs against a live seeded database.
|
||||
*
|
||||
* pnpm services:up && pnpm db:migrate && pnpm db:seed
|
||||
* pnpm --filter @linkder/db test
|
||||
* pnpm --filter @linkdr/db test
|
||||
*
|
||||
* Search is a second door onto the same supply as the deck, so the test that
|
||||
* matters most is the parity one: a pro who can be found here must be a pro who
|
||||
@@ -19,7 +19,10 @@ const { searchPros } = await import('../src/queries/search');
|
||||
const { getShowcaseDeck } = await import('../src/queries/deck');
|
||||
|
||||
/** The seed places every pro relative to this point. */
|
||||
const CENTRE = { lat: 41.3874, lng: 2.1686 };
|
||||
const CENTRE = {
|
||||
lat: Number(process.env.NEXT_PUBLIC_CITY_LAT ?? 19.4326),
|
||||
lng: Number(process.env.NEXT_PUBLIC_CITY_LNG ?? -99.1332),
|
||||
};
|
||||
|
||||
let plumberId: string;
|
||||
|
||||
@@ -31,17 +34,17 @@ beforeAll(async () => {
|
||||
plumberId = plumber.id;
|
||||
|
||||
// Seeded skills are empty, so text search has nothing to match until we give
|
||||
// one pro something to find. Marc Oliveras is 800 m from the centre.
|
||||
// one pro something to find. Sergio Fabela is 1.1 km from the centre.
|
||||
await db.execute(sql`
|
||||
UPDATE pro_profiles SET skills = ARRAY['Underfloor heating', 'Emergency callouts']
|
||||
WHERE user_id = (SELECT id FROM users WHERE name = 'Marc Oliveras')
|
||||
WHERE user_id = (SELECT id FROM users WHERE name = 'Sergio Fabela')
|
||||
`);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await db.execute(sql`
|
||||
UPDATE pro_profiles SET skills = '{}'::text[]
|
||||
WHERE user_id = (SELECT id FROM users WHERE name = 'Marc Oliveras')
|
||||
WHERE user_id = (SELECT id FROM users WHERE name = 'Sergio Fabela')
|
||||
`);
|
||||
await closePool();
|
||||
});
|
||||
@@ -66,17 +69,17 @@ describe('searchPros', () => {
|
||||
|
||||
it('excludes the unverified, the away and the too-far', async () => {
|
||||
const names = (await searchPros(db, { ...CENTRE, limit: 50 })).map((p) => p.name);
|
||||
expect(names).not.toContain('Unverified Ulla');
|
||||
expect(names).not.toContain('Away Arnau');
|
||||
expect(names).not.toContain('Pau Ribas'); // 22 km out, 5 km radius
|
||||
expect(names).not.toContain('Unverified Ulises');
|
||||
expect(names).not.toContain('Away Arturo');
|
||||
expect(names).not.toContain('Pablo Rivas'); // 22 km out, 5 km radius
|
||||
});
|
||||
|
||||
it('matches a skill', async () => {
|
||||
const names = (await searchPros(db, { ...CENTRE, q: 'underfloor', limit: 50 })).map(
|
||||
(p) => p.name,
|
||||
);
|
||||
expect(names).toContain('Marc Oliveras');
|
||||
expect(names).not.toContain('Laia Mestre'); // an electrician with no such skill
|
||||
expect(names).toContain('Sergio Fabela');
|
||||
expect(names).not.toContain('Martino Gómez'); // an electrician with no such skill
|
||||
});
|
||||
|
||||
it('matches a trade name', async () => {
|
||||
@@ -86,8 +89,8 @@ describe('searchPros', () => {
|
||||
});
|
||||
|
||||
it('matches a pro by name', async () => {
|
||||
const names = (await searchPros(db, { ...CENTRE, q: 'oliveras', limit: 50 })).map((p) => p.name);
|
||||
expect(names).toEqual(['Marc Oliveras']);
|
||||
const names = (await searchPros(db, { ...CENTRE, q: 'fabela', limit: 50 })).map((p) => p.name);
|
||||
expect(names).toEqual(['Sergio Fabela']);
|
||||
});
|
||||
|
||||
it('treats wildcards as literal characters', async () => {
|
||||
@@ -105,7 +108,7 @@ describe('searchPros', () => {
|
||||
it("honours the searcher's own distance limit", async () => {
|
||||
const near = await searchPros(db, { ...CENTRE, maxDistanceM: 3_000, limit: 50 });
|
||||
expect(near.every((p) => p.distanceM <= 3_000)).toBe(true);
|
||||
expect(near.map((p) => p.name)).not.toContain('Marta Vidal'); // 9.1 km out
|
||||
expect(near.map((p) => p.name)).not.toContain('Marta Villanueva'); // 9.1 km out
|
||||
});
|
||||
|
||||
it('sorts by distance, price and rating', async () => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Integration test — runs against a live seeded database.
|
||||
*
|
||||
* pnpm services:up && pnpm db:migrate && pnpm db:seed
|
||||
* pnpm --filter @linkder/db test
|
||||
* pnpm --filter @linkdr/db test
|
||||
*
|
||||
* getShowcaseDeck feeds the entry screen, which is the one deck an anonymous
|
||||
* visitor sees. Its whole promise is the word "verified": nobody may appear in
|
||||
@@ -19,7 +19,10 @@ const { closePool, db } = await import('../src/client');
|
||||
const { getShowcaseDeck } = await import('../src/queries/deck');
|
||||
|
||||
/** The seed places the fixture job, and every distance, relative to this point. */
|
||||
const CENTRE = { lat: 41.3874, lng: 2.1686 };
|
||||
const CENTRE = {
|
||||
lat: Number(process.env.NEXT_PUBLIC_CITY_LAT ?? 19.4326),
|
||||
lng: Number(process.env.NEXT_PUBLIC_CITY_LNG ?? -99.1332),
|
||||
};
|
||||
|
||||
let names: (string | null)[];
|
||||
|
||||
@@ -38,23 +41,23 @@ describe('getShowcaseDeck', () => {
|
||||
});
|
||||
|
||||
it('excludes a pro who will not travel this far', () => {
|
||||
// Pau Ribas is seeded 22 km out with a 5 km service radius.
|
||||
expect(names).not.toContain('Pau Ribas');
|
||||
// Pablo Rivas is seeded 22 km out with a 5 km service radius.
|
||||
expect(names).not.toContain('Pablo Rivas');
|
||||
});
|
||||
|
||||
it('excludes a pro whose verification has not passed', () => {
|
||||
// Unverified Ulla is 1 km away — close enough to prove distance is not
|
||||
// Unverified Ulises is 1 km away — close enough to prove distance is not
|
||||
// what is keeping her out.
|
||||
expect(names).not.toContain('Unverified Ulla');
|
||||
expect(names).not.toContain('Unverified Ulises');
|
||||
});
|
||||
|
||||
it('excludes a verified pro who is not accepting work', () => {
|
||||
// Away Arnau is verified and nearby, but on holiday mode.
|
||||
expect(names).not.toContain('Away Arnau');
|
||||
// Away Arturo is verified and nearby, but on holiday mode.
|
||||
expect(names).not.toContain('Away Arturo');
|
||||
});
|
||||
|
||||
it('includes the nearest eligible pro', () => {
|
||||
expect(names).toContain('Marc Oliveras');
|
||||
expect(names).toContain('Sergio Fabela');
|
||||
});
|
||||
|
||||
it('honours the limit', async () => {
|
||||
@@ -63,13 +66,13 @@ describe('getShowcaseDeck', () => {
|
||||
});
|
||||
|
||||
it('honours the searcher own range, not just the pro one', async () => {
|
||||
// Marta Vidal is seeded 9.1 km out with a 30 km radius: she would travel
|
||||
// Marta Villanueva is seeded 9.1 km out with a 30 km radius: she would travel
|
||||
// here happily, but someone who said "within 3 km" did not ask for her.
|
||||
const near = await getShowcaseDeck(db, { ...CENTRE, maxDistanceM: 3_000, limit: 100 });
|
||||
const nearNames = near.map((c) => c.name);
|
||||
|
||||
expect(nearNames).not.toContain('Marta Vidal');
|
||||
expect(nearNames).toContain('Marc Oliveras'); // 800 m away
|
||||
expect(nearNames).not.toContain('Marta Villanueva');
|
||||
expect(nearNames).toContain('Sergio Fabela'); // 1.1 km away
|
||||
expect(near.every((c) => c.distanceM <= 3_000)).toBe(true);
|
||||
});
|
||||
|
||||
@@ -97,11 +100,11 @@ describe('getShowcaseDeck', () => {
|
||||
const cards = await getShowcaseDeck(db, { ...CENTRE, categoryId: plumber.id, limit: 100 });
|
||||
const filtered = cards.map((c) => c.name);
|
||||
|
||||
// Pau Ribas is a plumber — he is kept out by radius, not by trade, so this
|
||||
// Pablo Rivas is a plumber — he is kept out by radius, not by trade, so this
|
||||
// proves the category filter did not replace the eligibility rules.
|
||||
expect(filtered).not.toContain('Pau Ribas');
|
||||
expect(filtered).not.toContain('Unverified Ulla');
|
||||
expect(filtered).not.toContain('Away Arnau');
|
||||
expect(filtered).not.toContain('Pablo Rivas');
|
||||
expect(filtered).not.toContain('Unverified Ulises');
|
||||
expect(filtered).not.toContain('Away Arturo');
|
||||
});
|
||||
|
||||
it('never returns a card with a distance beyond that pro’s own radius', async () => {
|
||||
|
||||
Reference in New Issue
Block a user