-
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.
- Loading branch information
1 parent
0d9444f
commit 6865f76
Showing
6 changed files
with
196 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { | ||
ElectronApplication, | ||
Page, | ||
test as base, | ||
_electron as electron, | ||
expect, | ||
} from "@playwright/test"; | ||
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client"; | ||
import type { AppRouter } from "bowser-server/app/api/_router"; | ||
import MockOBSWebSocket from "@bowser/testing/MockOBSWebSocket"; | ||
import SuperJSON from "superjson"; | ||
|
||
const api = createTRPCProxyClient<AppRouter>({ | ||
links: [ | ||
httpBatchLink({ | ||
url: "http://localhost:3000/trpc", | ||
headers: () => ({ | ||
Authorization: "Bearer aaa", | ||
}), | ||
}), | ||
], | ||
transformer: SuperJSON, | ||
}); | ||
|
||
const test = base.extend<{ | ||
app: [ElectronApplication, Page]; | ||
obs: MockOBSWebSocket; | ||
}>({ | ||
app: async ({ request }, 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 win.close(); | ||
await app.close(); | ||
}, | ||
obs: async (_, use) => { | ||
const mows = await MockOBSWebSocket.create(expect); | ||
await use(mows); | ||
await mows.close(); | ||
}, | ||
}); | ||
|
||
test.beforeEach(async ({ request }) => { | ||
await request.post( | ||
"http://localhost:3000/api/resetDBInTestsDoNotUseOrYouWillBeFired", | ||
); | ||
await api.shows.create.mutate({ | ||
name: "Test Show", | ||
start: new Date("2026-01-01T19:00:00Z"), | ||
continuityItems: { | ||
create: { | ||
name: "Test Continuity", | ||
durationSeconds: 0, | ||
order: 0, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
test("continuity works", async ({ app: [app, win], obs }) => { | ||
await win.getByRole("button", { name: "Select" }).click(); | ||
|
||
await expect(win.getByLabel("Settings")).toBeVisible(); | ||
await win.getByLabel("Settings").click(); | ||
|
||
await win.getByRole("tab", { name: "OBS" }).click(); | ||
|
||
await win.getByLabel("OBS Host").fill("localhost"); | ||
await win.getByLabel("OBS WebSocket Port").fill(obs.port.toString(10)); | ||
await win.getByLabel("OBS WebSocket Password").fill("there is no password"); | ||
await win.getByRole("button", { name: "Connect" }).click(); | ||
await expect(win.getByTestId("OBSSettings.error")).not.toBeVisible(); | ||
await expect(win.getByTestId("OBSSettings.success")).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
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 testOnlyProcedure = publicProcedure.use(async ({ next }) => { | ||
if (process.env.E2E_TEST === "true") { | ||
return await next(); | ||
} | ||
throw new TRPCError({ | ||
code: "UNAUTHORIZED", | ||
message: "This procedure is only available in end-to-end tests.", | ||
}); | ||
}); | ||
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