From 410bfa5b2b4c301d72da11b534743acb8f48c366 Mon Sep 17 00:00:00 2001 From: Marshal Date: Wed, 22 Jul 2026 12:19:51 +0000 Subject: [PATCH] changes --- .../modules/contracts/contracts.controller.ts | 5 ++++- .../cypress/e2e/flows/export_one_time.cy.ts | 17 ++++++++--------- e2e/freight/cypress/fixtures/seed-export.sql | 12 ++++++++++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/apps/edr-freight-api/src/modules/contracts/contracts.controller.ts b/apps/edr-freight-api/src/modules/contracts/contracts.controller.ts index 6ca4473cd..0fe16be56 100644 --- a/apps/edr-freight-api/src/modules/contracts/contracts.controller.ts +++ b/apps/edr-freight-api/src/modules/contracts/contracts.controller.ts @@ -196,7 +196,10 @@ export class ContractsController { @CurrentUser() user: TCurrentUser, ) { // Staff see every contract; customers are force-scoped to their own company. - if (hasFreightPermission(user, FREIGHT_PERMS.bookings.view)) { + if ( + hasFreightPermission(user, FREIGHT_PERMS.bookings.view) || + hasFreightPermission(user, FREIGHT_PERMS.contracts.view) + ) { return this.contractsService.findAll(filter); } const userId = user?.id; diff --git a/e2e/freight/cypress/e2e/flows/export_one_time.cy.ts b/e2e/freight/cypress/e2e/flows/export_one_time.cy.ts index a1cc00c57..8e7c6334d 100644 --- a/e2e/freight/cypress/e2e/flows/export_one_time.cy.ts +++ b/e2e/freight/cypress/e2e/flows/export_one_time.cy.ts @@ -147,17 +147,16 @@ function fillNth(label: RegExp, index: number, value: string) { }); } -/** Open the Shipment day picker and choose the train's departure day. */ +/** + * Choose the train's departure day on the Schedule card's INLINE calendar + * (cargo-aware: days only unlock once the cargo details above are valid). + */ function pickShipmentDay() { - cy.contains("label", /^Shipment day/) - .invoke("attr", "for") - .then((id) => { - cy.get(`[id="${id}"]`).click({ force: true }); - }); + cy.contains(/available day/, { timeout: 30000 }).should("exist"); + // Day cells are plain buttons in a div grid; only bookable days are enabled + // (out-of-month duplicates stay disabled). const day = String(SHIPMENT_DAY.getDate()); - cy.get(".mantine-Popover-dropdown button:not([data-disabled]):not([disabled])", { - timeout: 15000, - }) + cy.get("button:not(:disabled)", { timeout: 15000 }) .contains(new RegExp(`^${day}$`)) .click({ force: true }); } diff --git a/e2e/freight/cypress/fixtures/seed-export.sql b/e2e/freight/cypress/fixtures/seed-export.sql index 023125106..574f43f26 100644 --- a/e2e/freight/cypress/fixtures/seed-export.sql +++ b/e2e/freight/cypress/fixtures/seed-export.sql @@ -8,6 +8,18 @@ -- 3. LIVE export rates for Mojo → Djibouti Port: container (per container) -- and bulk (per ton) — booking pricing hard-blocks without them +-- 0. Approved exporter profile — picking "Export" in the wizard opens the +-- "Set up your exporter profile" modal unless the company already has an +-- active exporter profile (seed-company.sql only creates the importer). +INSERT INTO freight.company_profiles (id, company_id, type, status, reference) +SELECT gen_random_uuid(), c.id, 'exporter', 'active', 'EXP-E2E-0001' +FROM freight.companies c +WHERE c.tin = '0102030405' + AND NOT EXISTS ( + SELECT 1 FROM freight.company_profiles p + WHERE p.company_id = c.id AND p.type = 'exporter' + ); + -- 1a. Cargo type group + commodity. INSERT INTO freight.cargo_types (id, code, cargo_type_name, is_active) SELECT gen_random_uuid(), 'E2E_GRAINS', 'E2E Grains', true