Loading Events…
} {events.error &&{events.error.message}
} - {subscriptions.error &&Subscriber counts could not be loaded.
} {events.data?.length === 0 &&No Events yet.
} {!!events.data?.length &&| {label} | )}||
|---|---|---|
| {label} | )}||
| {item.name} | {item.description || "No description"} | -{subscriptions.error ? "—" : subscriptions.isPending ? "…" : counts.get(item.id) ?? 0} |
Loading Event…
} {events.error &&{events.error.message}
} {!events.isPending && !events.error && !event &&Event not found.
} @@ -109,7 +100,6 @@ export function EventPage() {{detail.data.enrichment.rule}
Read only. Edit this rule through the Factorize API or MCP.
} -Loading subscription…
} {subscription.error &&{subscription.error.message}
} {subscription.data === null &&Event subscription not found.
} diff --git a/packages/app/src/features/events/routes.tsx b/packages/app/src/features/events/routes.tsx index a2d4f07f..8640a3e1 100644 --- a/packages/app/src/features/events/routes.tsx +++ b/packages/app/src/features/events/routes.tsx @@ -16,7 +16,7 @@ export function eventRoutes(root: AnyRootRoute) { createRoute({ getParentRoute: () => root, path: "/events", beforeLoad: guard, loader: loadEvents, component: lazyRouteComponent(() => import("./events"), "EventsPage") }), createRoute({ getParentRoute: () => root, path: "/events/subscriptions", beforeLoad: guard, - component: lazyRouteComponent(() => import("./events"), "SubscriptionsPage") }), + loader: () => { throw redirect({ to: "/events" }); } }), createRoute({ getParentRoute: () => root, path: "/events/subscriptions/$subscriptionId", beforeLoad: guard, component: lazyRouteComponent(() => import("./events"), "SubscriptionPage") }), createRoute({ getParentRoute: () => root, path: "/events/$eventId", beforeLoad: guard, loader: loadEvents, diff --git a/packages/app/test/functional/critical.spec.mjs b/packages/app/test/functional/critical.spec.mjs index fc73eeef..3eea3247 100644 --- a/packages/app/test/functional/critical.spec.mjs +++ b/packages/app/test/functional/critical.spec.mjs @@ -24,7 +24,11 @@ test("navigates Events, subscriptions and exact client connections through acces { grantId: "primary", clientName: "Order assistant", clientId: "same-app", appName: "Registered app", expiresAt: null, authorizationDate: timestamp }, { grantId: "secondary", clientName: "Other connection", clientId: "same-app", appName: "Registered app", expiresAt: null, authorizationDate: timestamp }, ] })); - await page.route("**/api/v1/event-subscriptions", route => route.fulfill({ json: deleted ? [other] : [required, expired, other] })); + let subscriptionListRequests = 0; + await page.route("**/api/v1/event-subscriptions", route => { + subscriptionListRequests++; + return route.fulfill({ json: deleted ? [other] : [required, expired, other] }); + }); await page.route(`**/api/v1/event-subscriptions/${requiredId}`, route => route.fulfill({ json: required })); const triggerId = "30000000-0000-4000-8000-000000000001"; const enrichment = {rule:"input.ready",extraDataUrls:[{name:"checks",method:"GET",path:"/status"}]}; @@ -71,9 +75,9 @@ test("navigates Events, subscriptions and exact client connections through acces const nav = page.getByRole("navigation", { name: "Event navigation" }); const events = page.getByRole("table", { name: "Events", exact: true }); await expect(page.getByRole("heading", { name: "Events", exact: true })).toBeVisible(); - await expect(nav.getByRole("link", { name: "Events", exact: true })).toHaveAttribute("aria-current", "page"); - await expect(events.getByRole("columnheader")).toHaveText(["Name", "Description", "Subscribers"]); - await expect(events.getByRole("row", { name: /orders.created/ }).getByRole("cell").last()).toHaveText("1"); + await expect(nav).toHaveCount(0); + await expect(page.getByRole("main").getByRole("link", { name: "Subscriptions" })).toHaveCount(0); + await expect(events.getByRole("columnheader")).toHaveText(["Name", "Description"]); await expect(page.getByRole("button", { name: "Delete", exact: true })).toHaveCount(0); await expect(page.getByRole("button", { name: "Create Event" })).toHaveCount(0); await expect(page.getByRole("main").locator("form")).toHaveCount(0); @@ -85,6 +89,10 @@ test("navigates Events, subscriptions and exact client connections through acces await expect(page.getByRole("heading", { name: "orders.created", exact: true })).toBeVisible(); await expect(page.getByRole("navigation", { name: "Dashboard navigation" }).getByRole("link", { name: "Events" })).toBeVisible(); await expect(page.getByRole("heading", { name: "Payload schema" })).toHaveCount(0); + await expect(nav).toHaveCount(0); + await expect(page.getByRole("heading", { name: "Subscriptions" })).toHaveCount(0); + await expect(page.getByRole("table", { name: "Event subscriptions" })).toHaveCount(0); + await expect(page.getByRole("link", { name: "Back to Events" })).toHaveAttribute("href", "/events"); await expect(page.getByRole("link",{name:"Order signal"})).toHaveAttribute("href","/triggers/" + triggerId); await expect(page.getByRole("heading",{name:"Match logic"})).toBeVisible(); await expect(page.getByRole("status").filter({ hasText: "Evaluation is paused because an integration used by this Event was deleted." })).toBeVisible(); @@ -106,14 +114,15 @@ test("navigates Events, subscriptions and exact client connections through acces await expect(eventOccurrences.getByRole("row")).toHaveCount(11); expect(historyRequests.event).toEqual([null, "event-page-two"]); expect(fullPayloadRequests).toEqual([]); + expect(subscriptionListRequests).toBe(0); + await page.goto(origin + "/clients/primary"); const subscriptions = page.getByRole("table", { name: "Event subscriptions" }); - await expect(subscriptions.getByRole("columnheader")).toHaveText(["Client", "Event", "Status", "Acknowledgment mode", "Expires", "Cooldown ends"]); - await expect(subscriptions.getByRole("row")).toHaveCount(3); + await expect(subscriptions.getByRole("columnheader")).toHaveText(["Event", "Status", "Acknowledgment mode", "Expires", "Cooldown ends"]); + await expect(subscriptions.getByRole("row")).toHaveCount(2); await expect(subscriptions.getByRole("cell", { name: "Required" })).toBeVisible(); - await expect(subscriptions.getByRole("cell", { name: "Expired" })).toBeVisible(); + await expect(subscriptions.getByRole("cell", { name: "Expired" })).toHaveCount(0); const endTime = subscriptions.locator(`time[datetime="${cooldownEnd}"]`); - await expect(endTime).toHaveCount(1); - await expect(subscriptions.locator(`time[datetime="${legacyCooldownEnd}"]`)).toHaveCount(1); + await expect(endTime).toBeVisible(); await subscriptions.getByRole("link", { name: /aaaaaaaa/ }).click(); await expect(page).toHaveURL(origin + "/events/subscriptions/" + requiredId); await expect(page.getByText(requiredId, { exact: true })).toBeVisible(); @@ -135,25 +144,18 @@ test("navigates Events, subscriptions and exact client connections through acces expect(historyRequests.subscription).toEqual([null, "subscription-page-two"]); expect(fullPayloadRequests).toEqual([]); - await nav.getByRole("link", { name: "Subscriptions" }).click(); - await expect(subscriptions.getByRole("row")).toHaveCount(4); - await expect(subscriptions.getByRole("columnheader", { name: "Cooldown ends" })).toBeVisible(); - await expect(endTime).toBeVisible(); - await expect(subscriptions.getByRole("cell", { name: "Not recorded" })).toBeVisible(); + await page.goto(origin + "/clients/secondary"); + await expect(subscriptions.getByRole("row")).toHaveCount(3); + await expect(subscriptions.getByRole("cell", { name: "Expired" })).toBeVisible(); await subscriptions.getByRole("link", { name: /bbbbbbbb/ }).click(); await expect(page.getByText("Last cooldown started", { exact: true })).toBeVisible(); await expect(page.getByText("Not recorded", { exact: true })).toBeVisible(); await expect(subscriptions.locator(`time[datetime="${legacyCooldownEnd}"]`)).toBeVisible(); - await nav.getByRole("link", { name: "Subscriptions" }).click(); - await subscriptions.getByRole("link", { name: "Order assistant" }).click(); - await expect(page).toHaveURL(origin + "/clients/primary"); - await expect(subscriptions.getByRole("columnheader")).toHaveText(["Event", "Status", "Acknowledgment mode", "Expires", "Cooldown ends"]); - await expect(subscriptions.getByRole("row")).toHaveCount(2); - await expect(endTime).toBeVisible(); - await expect(subscriptions.getByRole("cell", { name: "Required" })).toBeVisible(); - await expect(subscriptions.getByRole("cell", { name: "Expired" })).toHaveCount(0); + await page.getByRole("link", { name: "Back to Events" }).click(); + await expect(page).toHaveURL(origin + "/events"); - await page.goto(origin + "/events"); + await page.goto(origin + "/events/subscriptions"); + await expect(page).toHaveURL(origin + "/events"); const description = await events.getByRole("cell", { name: "New orders" }).boundingBox(); expect(description).not.toBeNull(); await page.mouse.click(description.x + description.width / 2, description.y + description.height / 2); @@ -162,7 +164,7 @@ test("navigates Events, subscriptions and exact client connections through acces await page.getByRole("button", { name: "Delete", exact: true }).click(); await expect(page).toHaveURL(origin + "/events"); await expect(events.getByRole("link", { name: "orders.created" })).toHaveCount(0); - await nav.getByRole("link", { name: "Subscriptions" }).click(); + await page.goto(origin + "/clients/secondary"); await expect(subscriptions.getByRole("row")).toHaveCount(2); await expect(subscriptions.getByRole("link", { name: /orders.shipped/ })).toBeVisible(); });