mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
d152f9d02b
* fix(shared-view): render each leg of multi-leg flights correctly The read-only shared view showed the overall trip start/end airports and the first leg's flight number on every leg of a multi-leg flight. The Day Plan already expands legs (each carries __leg), but the renderer ignored it and read flat top-level metadata; the Bookings tab had the same bug. - Day Plan: use __leg for per-leg airline/flight number/route, plus dep-arr time - Bookings tab: list each leg via getFlightLegs() - unique React keys for multi-leg rows Closes #1219 * feat(pdf): add legs to pdf export * fix(demo): skip first-run admin seed in demo mode When DEMO_MODE is on, the demo seeder creates its own admin (admin@trek.app, username "admin") right after the generic seeds run. The first-run admin bootstrap was grabbing username "admin" first, so the demo seeder hit the UNIQUE(username) constraint and aborted before the demo user was ever created - which surfaced as a 500 "Demo user not found" on demo-login. Skip the generic admin bootstrap when demo mode owns the admin account. * fix(docker): ship the encryption-key migration script in the image The production image only copied server/dist, so the documented rotation command `node --import tsx scripts/migrate-encryption.ts` failed inside the container with a module-not-found error - the raw .ts was never present. The script runs via tsx straight from source and only pulls node builtins plus better-sqlite3 (both prod deps), so copying the single file into /app/server/scripts is enough to make the rotation work again. * fix(vacay): keep the mode toolbar above the mobile bottom nav The floating Vacation/Company toolbar was pinned at bottom-3 with z-30, so on mobile it landed in the same band as the fixed bottom nav (z-60) and got hidden behind it - and could scroll out of reach entirely. Pin it above the nav with the shared --bottom-nav-h variable (0px on desktop, so nothing changes there) and reserve matching space below the calendar grid so it never gets swallowed. * fix(dashboard): show the correct reservation date regardless of timezone The upcoming-reservations widget built the date with new Date(reservation_time) .toISOString(), which reinterprets the stored naive local time as UTC and can roll the displayed day forward in non-UTC timezones (e.g. a 23:30 reservation showing the next day). Read the date and time straight from the stored string parts via splitReservationDateTime, and format the time with the shared formatTime helper so it also honours the user's 12h/24h preference. * fix(atlas): cursor-following tooltips and removing countries from search Two related Atlas fixes: - Country tooltips were bound with sticky:false, which anchors them at the feature's bounds centre. For countries with overseas territories (e.g. France) that centre sits far out in the ocean, so the tooltip popped up nowhere near the area being hovered. Make them sticky so they track the cursor. - Selecting an already-visited country from the search bar always opened the "Mark / Bucket" dialog, with no way to remove it. Tiny countries like Vatican City or Singapore are hard to hit on the map, so search was the only way in. Mirror the map-click behaviour: a manually-marked country opens the Remove confirmation, a trip/place-backed one opens its detail. * fix(oidc): keep dots in generated usernames The OIDC username sanitizer stripped dots because they were missing from the allowed character class, so a name claim like "first.last" became "firstlast". Dots are valid usernames (the profile validator already allows ^[a-zA-Z0-9_.-]+$), so add the dot to the sanitizer. * fix(collab): show poll option labels in the UI The poll API formatted each option as { label, voters }, but the React poll component renders opt.text - so every option button came out blank. Emit text alongside label (kept for any other consumer) so options render again. * feat(backup): make the upload size limit configurable The restore upload was capped at a hard-coded 500 MB, so instances whose backup archive (uploads/ included) grew past that got a 413 "File too large" with no way to raise it. Add a BACKUP_UPLOAD_LIMIT_MB env var (default 500, invalid values warn and fall back), documented in .env.example. * feat(costs): create an expense from a booking, fix editing total-only items Replace the inline price + budget-category fields in the Transport and Reservation booking modals with a "Create expense" flow: the modal saves the booking, then opens the full Costs editor prefilled (name + category mapped from the booking type) and linked to the reservation. A booking with a linked expense shows it inline with edit / remove. Also fix the Costs editor so an expense with a recorded total but no payers (transport-derived or pre-rework items) opens with its amount, lets you set the currency, and saves - it previously showed 0 everywhere and could not be saved. Legacy / localized categories now map to the fixed keys, and changing a booking's type keeps its linked expense category in sync (unless it was manually set). - shared: reservation_id on budget create, typeToCostCategory helper, i18n keys - server: createBudgetItem stores reservation_id; keep total_price for payerless items; a booking update no longer wipes its linked expense and syncs the category on type change - client: shared BookingCostsSection, exported ExpenseModal with prefill and an editable total, page-level save-then-open wiring * test(reservations): align syncBudgetOnUpdate unit tests with no-wipe + type-sync The service now leaves a linked expense alone when no budget entry is on the payload (only an explicit total_price 0 deletes it) and syncs the category on a booking type change. Update the unit tests accordingly - the old "price cleared" case passed entry: undefined, which is now a no-op and left a mocked return queued that leaked into the next test. * fix(planner): keep a reservation on its day when edited (#1237) Editing a booking forced its day_id to the globally selected day, which is null when editing from the Book tab - so the booking lost its day and vanished from the Plan. Preserve the reservation own day_id on edit instead. * fix(planner): derive a booking day from its date when none is set (#1237) The client always sends day_id on a reservation update, so the server only derived it from reservation_time when the field was absent. A non-transport booking saved without a selected day (Book tab) therefore got day_id null and vanished from the Plan, even though its date matched a day. Derive the day from reservation_time whenever day_id is null, mirroring create. * fix(planner): let a booking's day follow its date when edited (#1237) Preserving the old day_id on edit left a re-dated booking on its previous start day while end_day_id followed the new date, so it spanned both. Stop sending day_id from the edit modal entirely - the server derives both ends from the booking's date (and keeps the current day when there is no date), so a re-dated booking moves cleanly to the matching day. * fix(atlas): keep the continent breakdown in sync on mark/unmark (#1225) The optimistic mark/unmark updates bumped the country total but never the per-continent counts, so the continent column froze until a full reload. Move the country to continent map into @trek/shared (single source for server and client) and adjust the matching continent count at every optimistic site: the country confirm flow plus the choose / region mark and region unmark handlers. * feat(admin): let admins set a default currency for new users Adds a currency picker to Admin > User Defaults. Stored as the default_currency user-default, so users who have not picked their own currency inherit it in Costs. * fix(atlas): give every sub-national region a distinct code (#1217) geoBoundaries fills shapeISO with the bare country code for some countries (every Spanish region got "ESP", every Chinese "CHN", also Chile/Oman), so marking one region lit up the whole country. build-atlas-geo.mjs now keeps shapeISO only when it is a real "XX-..." subdivision code and otherwise synthesizes a unique per-country id from the region name. Regenerated admin1.geojson.gz: Spain/China/ Chile/Oman now carry distinct region codes (countries with real codes, e.g. Germany, are unchanged). * fix(dashboard): never crash on a malformed reservation date A reservation with an invalid date blanked the whole My Trips page: the old Upcoming widget did new Date(value).toISOString(), which throws "Invalid time value" (fixed in #1222 by reading the string parts). Also guard splitDate so a bad date renders a dash instead of "Invalid Date" or throwing. * fix(airtrail): gate airtrail update behind a user setting, on airtrail update: rebuild payload from fresh data to prevent any data loss * fix(airtrail): add back missing tests * fix(costs): rework the cost panel UX wise and apply prettier on the shared package * chore(prettier) prettier this file * fix(airtrail): don't use cabin class as seat on import When an AirTrail flight has a cabin class but no seat number, the mapper fell back to the class for metadata.seat, so reservations showed e.g. "economy" as the seat. Use only the seat number; leave the seat blank otherwise. The class is still surfaced separately in the import picker. Closes #1246 * fix(airtrail): import scheduled flight times instead of actual AirTrail exposes both scheduled (departureScheduled/arrivalScheduled) and actual (departure/arrival) times. TREK read the actual times, so a delayed or early flight imported the wrong time for planning. Read the scheduled times on import and on poll-sync (both go through mapFlightToReservation); when a flight has no scheduled time, leave the clock blank (date preserved) rather than fabricating 00:00 or falling back to actual. The change-detection hash now tracks the scheduled values, so existing linked reservations re-sync once on the next poll. The opt-in writeback mirrors the read, pushing TREK edits to the scheduled fields so they round-trip. * fix(planner): hydrate per-assignment times when editing a place from the pool Times live per day-assignment, not on the pool place, so reopening a place from the Places panel / inspector showed empty Start/End fields (#1247). The editor now resolves a place's lone assignment when no day is in context and hydrates the fields from it; ambiguous (0 or 2+ days) edits hide the fields instead of showing non-persisting inputs. * fix(mcp): make write tools return client-valid, hydrated entities Audit of all write tools under server/src/mcp/tools (issue #1244 anchor). S1 (broken): - create_budget_item / create_budget_item_with_members now default the split to all trip members when member_ids omitted, so the entry passes the client save-gate instead of being member-less (#1244). - create_transport / update_transport backfill lat/lng/timezone for code-only flight endpoints (NOT NULL columns) and return a clean error for unresolvable endpoints instead of crashing. S2 (under-hydration): set_budget_item_members, create_journey, create_journey_entry, create_packing_bag, bulk_import_packing and update_vacay_plan now return the hydrated shape the matching read/REST route returns; bulk_import widened to accept bag/weight_grams/checked. S3 (parity): check_in_end added to accommodation tools; atlas mark_region_visited echoes the client shape; update_journey_entry/ update_journey_preferences, set_bag_members, set_packing_category_assignees, apply_packing_template return hydrated payloads; set_vacay_color echoes the color. Auth: save_packing_template now requires admin, matching the REST gate. Also refactors server/src/config.ts (JWT-secret handling). Adds getBudgetItem hydrated getter, exports EndpointInput, and MCP regression tests (incl. new tools-transports and tools-journey suites). * fix(mcp): fix ICS/maps/accommodation bugs, add settlement & template tools Bugs: - export_trip_ics: include flights that store times per-endpoint (local_date/local_time) instead of a top-level reservation_time - resolve_maps_url: follow redirects for cid=/share links and fall back to parsing the page body, all SSRF-guarded - link_hotel_accommodation: normalize accommodation_id (TEXT column) to an integer in the reservation read paths so it no longer returns "14.0" Gaps: - packing: save_packing_template returns the new template id; add list_packing_templates (read) and delete_packing_template (admin) - budget: update_budget_item accepts payers/member_ids; clarify create/ update/members descriptions to ask which members share the expense and who paid - budget: add settlement tools — get_settlement_summary, list_settlements, create/update/delete_settlement (budget_edit, mirrors REST + WS events) * chore: bump nodemailer * chore: bump multer --------- Co-authored-by: Maurice <mauriceboe@icloud.com>
338 lines
12 KiB
TypeScript
338 lines
12 KiB
TypeScript
// FE-COMP-TRIPPDF-001 to FE-COMP-TRIPPDF-010
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { http, HttpResponse } from 'msw'
|
|
import { downloadTripPDF } from './TripPDF'
|
|
import { server } from '../../../tests/helpers/msw/server'
|
|
|
|
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
|
|
const minimalArgs = {
|
|
trip: { id: 1, title: 'My Trip', description: null, cover_image: null } as any,
|
|
days: [{ id: 1, day_number: 1, title: null, date: '2025-06-01' }] as any[],
|
|
places: [],
|
|
assignments: {},
|
|
categories: [],
|
|
dayNotes: [],
|
|
reservations: [],
|
|
t: (key: string, params?: any) => {
|
|
if (params?.n !== undefined) return `Day ${params.n}`
|
|
return key
|
|
},
|
|
locale: 'en-US',
|
|
}
|
|
|
|
function getOverlay(): HTMLElement | null {
|
|
return document.getElementById('pdf-preview-overlay')
|
|
}
|
|
|
|
function getIframe(): HTMLIFrameElement | null {
|
|
return document.querySelector('#pdf-preview-overlay iframe')
|
|
}
|
|
|
|
// ── Setup ─────────────────────────────────────────────────────────────────────
|
|
|
|
beforeEach(() => {
|
|
// Stub window.location.origin
|
|
Object.defineProperty(window, 'location', {
|
|
value: { origin: 'http://localhost:3000', pathname: '/', href: 'http://localhost:3000/', search: '' },
|
|
writable: true,
|
|
configurable: true,
|
|
})
|
|
|
|
// Default MSW handlers for this test suite
|
|
server.use(
|
|
http.get('/api/trips/:id/accommodations', () =>
|
|
HttpResponse.json({ accommodations: [] })
|
|
),
|
|
http.get('/api/maps/place-photo/:placeId', () =>
|
|
HttpResponse.json({ photoUrl: null })
|
|
),
|
|
)
|
|
})
|
|
|
|
afterEach(() => {
|
|
// Clean up any overlay left by the function under test
|
|
document.getElementById('pdf-preview-overlay')?.remove()
|
|
vi.restoreAllMocks()
|
|
})
|
|
|
|
// ── Shared rich fixtures ──────────────────────────────────────────────────────
|
|
|
|
const dayWithPlaces = { id: 10, day_number: 1, title: 'Rome Day', date: '2025-06-01' } as any
|
|
const placeWithDetails = {
|
|
id: 100,
|
|
name: 'Colosseum',
|
|
description: 'Ancient amphitheater',
|
|
address: 'Piazza del Colosseo, Rome',
|
|
category_id: 5,
|
|
price: '15',
|
|
image_url: null,
|
|
google_place_id: null,
|
|
place_time: '10:00',
|
|
notes: 'Book tickets in advance',
|
|
} as any
|
|
const assignmentForDay = { id: 200, day_id: 10, place_id: 100, order_index: 0, place: placeWithDetails }
|
|
const categoryForPlace = { id: 5, name: 'Landmark', icon: 'landmark', color: '#e11d48' } as any
|
|
const dayNote = { id: 300, day_id: 10, text: 'Remember sunscreen', time: '08:00', icon: 'Info', sort_order: 1 } as any
|
|
const transportReservation = {
|
|
id: 400,
|
|
title: 'Flight to Rome',
|
|
type: 'flight',
|
|
day_id: 10,
|
|
reservation_time: '2025-06-01T14:30:00',
|
|
confirmation_number: 'ABC123',
|
|
metadata: JSON.stringify({ airline: 'Air Italia', flight_number: 'AI123', departure_airport: 'CDG', arrival_airport: 'FCO' }),
|
|
} as any
|
|
|
|
const multiLegFlight = {
|
|
id: 401,
|
|
title: 'Flight to Tokyo',
|
|
type: 'flight',
|
|
day_id: 10,
|
|
reservation_time: '2025-06-01T08:00:00',
|
|
confirmation_number: 'XYZ789',
|
|
metadata: JSON.stringify({
|
|
legs: [
|
|
{ from: 'FRA', to: 'BER', airline: 'Lufthansa', flight_number: 'LH1' },
|
|
{ from: 'BER', to: 'HND', airline: 'Lufthansa', flight_number: 'LH2' },
|
|
],
|
|
departure_airport: 'FRA', arrival_airport: 'HND', airline: 'Lufthansa', flight_number: 'LH1',
|
|
}),
|
|
} as any
|
|
|
|
const richArgs = {
|
|
trip: { id: 10, title: 'Italy Trip', description: 'Summer adventure', cover_image: '/uploads/cover.jpg' } as any,
|
|
days: [dayWithPlaces],
|
|
places: [placeWithDetails],
|
|
assignments: { '10': [assignmentForDay] } as any,
|
|
categories: [categoryForPlace],
|
|
dayNotes: [dayNote],
|
|
reservations: [transportReservation],
|
|
t: (key: string, params?: any) => {
|
|
if (params?.n !== undefined) return `Day ${params.n}`
|
|
return key
|
|
},
|
|
locale: 'en-US',
|
|
}
|
|
|
|
// ── Tests ─────────────────────────────────────────────────────────────────────
|
|
|
|
describe('downloadTripPDF', () => {
|
|
it('FE-COMP-TRIPPDF-001: resolves without throwing', async () => {
|
|
await expect(downloadTripPDF(minimalArgs)).resolves.not.toThrow()
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-002: appends an overlay div to document.body', async () => {
|
|
await downloadTripPDF(minimalArgs)
|
|
expect(document.getElementById('pdf-preview-overlay')).not.toBeNull()
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-003: overlay contains an iframe with srcdoc', async () => {
|
|
await downloadTripPDF(minimalArgs)
|
|
const iframe = getIframe()
|
|
expect(iframe).not.toBeNull()
|
|
expect(iframe!.srcdoc).toBeTruthy()
|
|
expect(iframe!.srcdoc.length).toBeGreaterThan(0)
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-004: HTML contains the trip title', async () => {
|
|
await downloadTripPDF(minimalArgs)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('My Trip')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-005: HTML contains a day section for each day', async () => {
|
|
const args = {
|
|
...minimalArgs,
|
|
days: [{ id: 1, day_number: 1, title: 'Day One', date: '2025-06-01' }] as any[],
|
|
}
|
|
await downloadTripPDF(args)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('Day One')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-006: escHtml prevents XSS in trip title', async () => {
|
|
const args = {
|
|
...minimalArgs,
|
|
trip: { id: 1, title: '<script>alert(1)</script>', description: null, cover_image: null } as any,
|
|
}
|
|
await downloadTripPDF(args)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).not.toContain('<script>alert(1)</script>')
|
|
expect(iframe!.srcdoc).toContain('<script>')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-007: close button removes the overlay from the DOM', async () => {
|
|
await downloadTripPDF(minimalArgs)
|
|
const closeBtn = document.getElementById('pdf-close-btn') as HTMLButtonElement
|
|
expect(closeBtn).not.toBeNull()
|
|
closeBtn.click()
|
|
expect(document.getElementById('pdf-preview-overlay')).toBeNull()
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-008: clicking backdrop outside the card removes the overlay', async () => {
|
|
await downloadTripPDF(minimalArgs)
|
|
const overlay = getOverlay()!
|
|
overlay.click()
|
|
expect(document.getElementById('pdf-preview-overlay')).toBeNull()
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-009: works with no days (empty itinerary)', async () => {
|
|
const args = { ...minimalArgs, days: [] }
|
|
await expect(downloadTripPDF(args)).resolves.not.toThrow()
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('<!DOCTYPE html>')
|
|
// No day sections — should not contain day-section class
|
|
expect(iframe!.srcdoc).not.toContain('class="day-section')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-010: calls accommodationsApi.list with the trip id', async () => {
|
|
const { accommodationsApi } = await import('../../api/client')
|
|
const spy = vi.spyOn(accommodationsApi, 'list')
|
|
await downloadTripPDF(minimalArgs)
|
|
expect(spy).toHaveBeenCalledWith(1)
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-011: renders place cards with name, address and category badge', async () => {
|
|
await downloadTripPDF(richArgs)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('Colosseum')
|
|
expect(iframe!.srcdoc).toContain('Piazza del Colosseo, Rome')
|
|
expect(iframe!.srcdoc).toContain('Landmark')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-012: renders note cards in day body', async () => {
|
|
await downloadTripPDF(richArgs)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('Remember sunscreen')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-013: renders transport reservation cards', async () => {
|
|
await downloadTripPDF(richArgs)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('Flight to Rome')
|
|
expect(iframe!.srcdoc).toContain('ABC123')
|
|
// Single-leg flight keeps its full-route subtitle.
|
|
expect(iframe!.srcdoc).toContain('Air Italia · AI123 · CDG → FCO')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-013b: renders every flight number for a multi-leg flight', async () => {
|
|
await downloadTripPDF({ ...richArgs, reservations: [multiLegFlight] })
|
|
const iframe = getIframe()
|
|
// One subtitle line per leg, each with its own flight number and segment route.
|
|
expect(iframe!.srcdoc).toContain('Lufthansa · LH1 · FRA → BER')
|
|
expect(iframe!.srcdoc).toContain('Lufthansa · LH2 · BER → HND')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-014: renders cover image when trip has cover_image', async () => {
|
|
await downloadTripPDF(richArgs)
|
|
const iframe = getIframe()
|
|
// Cover image rendered as background-image on .cover-bg
|
|
expect(iframe!.srcdoc).toContain('cover.jpg')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-015: renders accommodation section when accommodations exist', async () => {
|
|
server.use(
|
|
http.get('/api/trips/:id/accommodations', () =>
|
|
HttpResponse.json({
|
|
accommodations: [{
|
|
id: 1,
|
|
start_day_id: 10,
|
|
end_day_id: 10,
|
|
place_name: 'Hotel Roma',
|
|
place_address: 'Via Roma 1',
|
|
check_in: '15:00',
|
|
check_out: '11:00',
|
|
notes: 'Breakfast included',
|
|
confirmation: 'CONF999',
|
|
}],
|
|
})
|
|
),
|
|
)
|
|
await downloadTripPDF(richArgs)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('Hotel Roma')
|
|
expect(iframe!.srcdoc).toContain('CONF999')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-016: renders place description and price chip', async () => {
|
|
await downloadTripPDF(richArgs)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('Ancient amphitheater')
|
|
// Price chip: 15 EUR
|
|
expect(iframe!.srcdoc).toContain('15')
|
|
expect(iframe!.srcdoc).toContain('EUR')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-017: renders trip description on cover', async () => {
|
|
await downloadTripPDF(richArgs)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('Summer adventure')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-018: renders place with direct image URL', async () => {
|
|
const argsWithImg = {
|
|
...richArgs,
|
|
assignments: {
|
|
'10': [{
|
|
...assignmentForDay,
|
|
place: { ...placeWithDetails, image_url: '/uploads/colosseum.jpg' },
|
|
}],
|
|
} as any,
|
|
}
|
|
await downloadTripPDF(argsWithImg)
|
|
const iframe = getIframe()
|
|
expect(iframe!.srcdoc).toContain('colosseum.jpg')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-018b: renders a persisted place-photo proxy image_url as an <img>, not the category icon (#1130)', async () => {
|
|
const args = {
|
|
...richArgs,
|
|
assignments: {
|
|
'10': [{
|
|
...assignmentForDay,
|
|
place: { ...placeWithDetails, image_url: '/api/maps/place-photo/ChIJabc/bytes' },
|
|
}],
|
|
} as any,
|
|
}
|
|
await downloadTripPDF(args)
|
|
const iframe = getIframe()
|
|
// The proxy path (no file extension) must still embed as an absolute <img>.
|
|
expect(iframe!.srcdoc).toContain('http://localhost:3000/api/maps/place-photo/ChIJabc/bytes')
|
|
expect(iframe!.srcdoc).toContain('class="place-thumb"')
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-019: fetches google place photos for places with google_place_id', async () => {
|
|
let photoCalled = false
|
|
server.use(
|
|
http.get('/api/maps/place-photo/:placeId', () => {
|
|
photoCalled = true
|
|
return HttpResponse.json({ photoUrl: 'https://example.com/photo.jpg' })
|
|
}),
|
|
)
|
|
const argsWithGooglePlace = {
|
|
...richArgs,
|
|
assignments: {
|
|
'10': [{
|
|
...assignmentForDay,
|
|
place: { ...placeWithDetails, image_url: null, google_place_id: 'ChIJrTLr-GyuEmsRBfy61i59si0' },
|
|
}],
|
|
} as any,
|
|
}
|
|
await downloadTripPDF(argsWithGooglePlace)
|
|
expect(photoCalled).toBe(true)
|
|
})
|
|
|
|
it('FE-COMP-TRIPPDF-020: renders empty day message when no items assigned', async () => {
|
|
const args = {
|
|
...minimalArgs,
|
|
days: [{ id: 99, day_number: 2, title: 'Free Day', date: '2025-06-02' }] as any[],
|
|
assignments: {},
|
|
}
|
|
await downloadTripPDF(args)
|
|
const iframe = getIframe()
|
|
// The empty-day div should appear (contains the translation key for empty day)
|
|
expect(iframe!.srcdoc).toContain('dayplan.emptyDay')
|
|
})
|
|
})
|