Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions hub/client/application/hub/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ export const prototypeResponseSchema = z.object({
showPrototypeInfo: z.boolean().optional(),
})

export const buildResponseSchema = z.object({
repository: repositorySchema,
prototype: prototypeSchema,
build: buildSchema,
})

export const buildHistoryResponseSchema = z.object({
repository: repositorySchema,
prototype: prototypeSchema,
Expand Down
2 changes: 0 additions & 2 deletions hub/client/application/hub/contracts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { z } from "zod"
import type {
authorResultsSchema,
buildHistoryResponseSchema,
buildResponseSchema,
buildSchema,
paginationSchema,
prototypeDetailsSchema,
Expand All @@ -25,7 +24,6 @@ export type Pagination = z.infer<typeof paginationSchema>
export type WorkspaceResponse = z.infer<typeof workspaceResponseSchema>
export type RepositoryResponse = z.infer<typeof repositoryResponseSchema>
export type PrototypeResponse = z.infer<typeof prototypeResponseSchema>
export type BuildResponse = z.infer<typeof buildResponseSchema>
export type BuildHistoryResponse = z.infer<typeof buildHistoryResponseSchema>
export type AuthorResults = z.infer<typeof authorResultsSchema>
export type PrototypeDetails = z.infer<typeof prototypeDetailsSchema>
Expand Down
15 changes: 0 additions & 15 deletions hub/client/application/hub/mocks/create-mock-handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { sessionResponseSchema } from "@application/hub/session-contracts"

import type { MockStore } from "../create-mock-store/types"
import { MockStoreError } from "../store-error"
import { parseMockIdentifier as identifier } from "../parse-mock-identifier"
import { parseMockRecordIdentifier as recordIdentifier } from "../parse-mock-record-identifier"
import { parseMockQuery } from "../parse-mock-query"
import { respondMock } from "../respond-mock"
Expand Down Expand Up @@ -125,20 +124,6 @@ export function createMockHandlers(store: MockStore) {
}),
),

http.get(
api("/repositories/:repositoryId/prototypes/:prototypeId/builds/:buildNumber"),
({ request, params }) =>
withScenario(request, () =>
HttpResponse.json(
store.getBuild(
recordIdentifier(params.repositoryId),
recordIdentifier(params.prototypeId),
identifier(params.buildNumber),
),
),
),
),

http.patch(api("/repositories/:repositoryId/prototypes/:prototypeId"), ({ request, params }) =>
withScenario(request, async (_scenario, assertCurrentSession) => {
let body: unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ describe("createMockStore()", () => {
expect(() => store.getPrototype("2001", "1", 5)).toThrow(
expect.objectContaining({ status: 404 }),
)
expect(store.getBuild("2001", "1", 4).build.state).toBe("failed")
expect(store.getBuild("2001", "1", 5).build.state).toBe("running")
})

it("does not offer an unsuccessful Build as a preview when no successful Build exists", () => {
const store = createMockStore({ origin: window.location.origin })

expect(store.getPrototype("2001", "2").selectedBuild).toBeNull()
expect(store.getPrototype("2001", "3").selectedBuild).toBeNull()
expect(store.getBuild("2001", "2", 1).build.state).toBe("running")
})

it("registers another prototype when existing identifiers include a UUID", () => {
Expand Down
12 changes: 0 additions & 12 deletions hub/client/application/hub/mocks/create-mock-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import type {
AuthorResults,
BuildHistoryResponse,
BuildResponse,
PrototypeDetails,
PrototypeRecord,
PrototypeResponse,
Expand Down Expand Up @@ -254,17 +253,6 @@ export function createMockStore({ origin, seed = createFixtureSeed() }: Options)
}
},

getBuild(repositoryId: string, prototypeId: string, buildNumber: number): BuildResponse {
session.requireViewer()
const response = prototypeResponse(repositoryId, prototypeId, buildNumber)
if (!response.selectedBuild) throw new MockStoreError(404, "Build not found.")
return {
repository: response.repository,
prototype: response.prototype,
build: response.selectedBuild,
}
},

getBuildHistory(repositoryId: string, prototypeId: string, page = 1): BuildHistoryResponse {
session.requireViewer()
const prototype = prototypeRecord(repositoryId, prototypeId)
Expand Down
21 changes: 0 additions & 21 deletions hub/client/application/hub/requests/get-build/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions hub/client/application/hub/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ export default [
"repositories/:repositoryId/prototypes/:prototypeId/builds",
"routes/build-history/index.tsx",
),
route(
"repositories/:repositoryId/prototypes/:prototypeId/builds/:buildNumber",
"routes/build/index.tsx",
),
]),
route("*", "routes/not-found/index.tsx"),
] satisfies RouteConfig
36 changes: 0 additions & 36 deletions hub/client/application/hub/routes/build/index.tsx

This file was deleted.

32 changes: 30 additions & 2 deletions hub/client/application/hub/routes/expanded-flows.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { setupServer } from "msw/node"
import { useLoaderData, type RouteObject } from "react-router"
import { describe, expect, it, vi } from "vitest"

import type { FixtureBuild } from "../mocks/create-fixture-build/types"
import { createMockHandlers } from "../mocks/create-mock-handlers"
import { createMockStore } from "../mocks/create-mock-store"
import { mockDiagnostics } from "../mocks/diagnostics"
import seedData from "../mocks/seed.json"
import { settingsQuerySchema, settingsWorkspaceResponseSchema } from "../settings-contracts"
import ProductManagementRoute, {
clientAction as saveManagement,
Expand Down Expand Up @@ -342,7 +344,22 @@ describe("Hub expanded frontend flows", () => {
})

it("opens a newly created fixed-Build share after sign-out without loading a private workspace", async () => {
const store = createMockStore({ origin: window.location.origin })
const seed: Omit<typeof seedData, "builds"> & { builds: FixtureBuild[] } =
structuredClone(seedData)
const successful = seed.builds.find((build) => build.prototypeId === "1" && build.number === 3)
const running = seed.builds.find((build) => build.prototypeId === "2")
if (!successful || !running) throw new Error("The share-link flow needs Build fixtures.")
seed.builds.push(
{ ...running, prototypeId: "1", number: 4 },
{
...successful,
number: 5,
previewUrl: null,
desktopScreenshotUrl: null,
narrowScreenshotUrl: null,
},
)
const store = createMockStore({ origin: window.location.origin, seed })
const server = setupServer(...createMockHandlers(store))
const router = await renderHubFlow(
server,
Expand All @@ -352,6 +369,17 @@ describe("Hub expanded frontend flows", () => {
publicRoutes,
},
)
fireEvent.click(screen.getByRole("button", { name: "Choose build, v3" }))
const menu = screen.getByRole("menu", { name: "Choose build" })
expect(within(menu).getAllByRole("menuitem")).toHaveLength(2)
const first = within(menu).getByRole("menuitem", { name: /v1/i })
expect(within(menu).getByRole("menuitem", { name: /v3/i })).toBeVisible()
const firstLink = within(first).getByRole("link")
expect(firstLink).toHaveAttribute("href", "/repositories/2001/prototypes/1/share-links?build=1")
await router.settle(() => fireEvent.click(firstLink))
expect(router.state.location.pathname).toBe("/repositories/2001/prototypes/1/share-links")
expect(new URLSearchParams(router.state.location.search).get("build")).toBe("1")
expect(screen.getByRole("heading", { name: "Build 1" })).toBeVisible()
fireEvent.change(await screen.findByRole("textbox", { name: "Label" }), {
target: { value: "Stakeholder review" },
})
Expand All @@ -374,7 +402,7 @@ describe("Hub expanded frontend flows", () => {

await router.settle(() => router.navigate(sharedPath))

expect(await screen.findByTitle("Welcome · Build 3")).toBeInTheDocument()
expect(await screen.findByTitle("Welcome · Build 1")).toBeInTheDocument()
expect(store.session.read().viewer).toBeNull()
expect(privateReads).not.toHaveBeenCalled()
expect(screen.queryByRole("button", { name: /Account menu/ })).not.toBeInTheDocument()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { onTestFailed, onTestFinished, vi } from "vitest"
import { HubThemeProvider } from "@hooks/use-hub-theme"
import * as hubApi from "@application/hub/bootstrap-hub-api"
import { clientLoader as loadSession, ErrorBoundary, HydrateFallback } from "@application/hub/root"
import { clientLoader as loadBuild } from "@application/hub/routes/build"
import { clientLoader as loadBuildHistory } from "@application/hub/routes/build-history"
import { clientLoader as loadHome } from "@application/hub/routes/home"
import {
Expand All @@ -24,7 +23,6 @@ import { WorkspaceComponent } from "./workspace-component"
import { HomeComponent } from "./home-component"
import { RepositoryComponent } from "./repository-component"
import { PrototypeComponent } from "./prototype-component"
import { BuildComponent } from "./build-component"
import { BuildHistoryComponent } from "./build-history-component"
import { readTestRouteParameter } from "./read-test-route-parameter"

Expand Down Expand Up @@ -132,19 +130,6 @@ export async function renderHubFlow(
}),
Component: BuildHistoryComponent,
},
{
path: "/repositories/:repositoryId/prototypes/:prototypeId/builds/:buildNumber",
loader: ({ request, params }) =>
loadBuild({
request,
params: {
repositoryId: readTestRouteParameter(params, "repositoryId"),
prototypeId: readTestRouteParameter(params, "prototypeId"),
buildNumber: readTestRouteParameter(params, "buildNumber"),
},
}),
Component: BuildComponent,
},
...workspaceRoutes,
],
},
Expand Down
Loading
Loading