-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Desktop E2E tests: show creation and selection (#88)
* Desktop E2E show creation and selection * Add assertion that the show load succeeded
- Loading branch information
1 parent
2ff2ff5
commit 69a7c8c
Showing
10 changed files
with
164 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* eslint-disable no-empty-pattern */ | ||
import { | ||
test as base, | ||
_electron as electron, | ||
expect, | ||
type ElectronApplication, | ||
type Page, | ||
} from "@playwright/test"; | ||
import { server } from "./serverAPI"; | ||
|
||
const test = base.extend<{ | ||
app: [ElectronApplication, Page]; | ||
}>({ | ||
app: async ({}, use) => { | ||
const app = await electron.launch({ args: [".vite/build/main.js"] }); | ||
const win = await app.firstWindow(); | ||
|
||
await win.waitForLoadState("domcontentloaded"); | ||
|
||
await win.getByLabel("Server address").fill("http://localhost:3000"); | ||
await win.getByLabel("Server Password").fill("aaa"); | ||
|
||
await win.getByRole("button", { name: "Connect" }).click(); | ||
|
||
await expect( | ||
win.getByRole("heading", { name: "Select a show" }), | ||
).toBeVisible(); | ||
|
||
await use([app, win]); | ||
|
||
await expect( | ||
app.evaluate(({ ipcMain }) => ipcMain.emit("resetTestSettings")), | ||
).not.toBe(false); | ||
|
||
await win.close(); | ||
await app.close(); | ||
}, | ||
}); | ||
|
||
test.beforeEach(async ({ request }) => { | ||
await request.post( | ||
"http://localhost:3000/api/resetDBInTestsDoNotUseOrYouWillBeFired", | ||
); | ||
await server.shows.create.mutate({ | ||
name: "Test Show", | ||
start: new Date("2026-01-01T19:00:00Z"), | ||
continuityItems: { | ||
create: { | ||
name: "Test Continuity", | ||
durationSeconds: 0, | ||
order: 0, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
test("can select newly created show", async ({ app: [_app, page] }) => { | ||
const row = page.getByRole("listitem").filter({ hasText: "Test Show" }); | ||
expect(row).toBeVisible(); | ||
const btn = row.getByRole("button", { name: "Select" }); | ||
await btn.click(); | ||
await expect(page.getByRole("button", { name: "Test Show" })).toBeVisible(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { fetch } from "undici"; | ||
import type { AppRouter } from "bowser-server/app/api/_router"; | ||
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client"; | ||
import SuperJSON from "superjson"; | ||
|
||
export const server = createTRPCProxyClient<AppRouter>({ | ||
links: [ | ||
httpBatchLink({ | ||
url: "http://localhost:3000/api/trpc", | ||
headers: () => ({ | ||
Authorization: "Bearer aaa", | ||
}), | ||
// @ts-expect-error the undici types don't match what TRPC is expecting, but they're close enough | ||
fetch, | ||
}), | ||
], | ||
transformer: SuperJSON, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
import { initTRPC } from "@trpc/server"; | ||
import { TRPCError, initTRPC } from "@trpc/server"; | ||
import superjson from "superjson"; | ||
|
||
const t = initTRPC.create({ | ||
transformer: superjson, | ||
}); | ||
|
||
export const publicProcedure = t.procedure; | ||
export const e2eProcedure = t.procedure.use(({ next }) => { | ||
if (process.env.E2E_TEST !== "true") { | ||
throw new TRPCError({ | ||
code: "FORBIDDEN", | ||
message: "This endpoint is only available in e2e tests", | ||
}); | ||
} | ||
return next(); | ||
}); | ||
export const router = t.router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters