Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOW-12][DB][3/3] YouTube stream creation #174

Merged
merged 26 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
81bd2c0
Implement connections
markspolakovs Nov 12, 2023
6e2018c
Add settings
markspolakovs Nov 12, 2023
3fd275c
YouTube integration
markspolakovs Nov 12, 2023
c4abdbd
Use metadata for stream naming
markspolakovs Nov 12, 2023
159adcb
Save broadcast/stream IDs to the DB
markspolakovs Nov 15, 2023
c383c14
Replace FIXME with TODO
markspolakovs Nov 16, 2023
22551ac
Fix integration tests
markspolakovs Nov 16, 2023
0156002
Update desktop tests with new columns
markspolakovs Nov 16, 2023
9a8afd3
Fix test type errors and missing imports
markspolakovs Nov 16, 2023
2754938
Pass down rundown/continuity item IDs
markspolakovs Nov 16, 2023
36e9b27
Integration test for YT
markspolakovs Nov 16, 2023
058f6a8
Slow down / make test setup more reliable
markspolakovs Nov 16, 2023
64c7c39
Hopefully make integration tests reliable
markspolakovs Nov 21, 2023
2448f99
Make tests not depend on show ID
markspolakovs Nov 21, 2023
e34678b
Implement connections
markspolakovs Nov 12, 2023
fe23d33
Add settings
markspolakovs Nov 12, 2023
a0fab3f
Move server tests to Jest (#178)
markspolakovs Nov 21, 2023
abb3c4a
Migrate integration test from vi to jest
markspolakovs Nov 21, 2023
148895b
Dummy commit to trigger build
markspolakovs Nov 21, 2023
db2d86d
Dummy commit to trigger build
markspolakovs Nov 21, 2023
3e7a097
Merge remote-tracking branch 'origin/main' into yt-3-yt
markspolakovs Nov 21, 2023
9e180c4
Merge branch 'yt-2-settings' into yt-3-yt
markspolakovs Nov 21, 2023
b70664c
Fix tests
markspolakovs Nov 21, 2023
8418225
Fix typechecks
markspolakovs Nov 21, 2023
be889be
Revert truncate change for test API
markspolakovs Nov 21, 2023
7c2b9fd
Merge branch 'main' into yt-3-yt
markspolakovs Nov 21, 2023
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
3 changes: 3 additions & 0 deletions desktop/src/main/obsHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ beforeAll(() => {
rundowns: [],
continuityItems: [],
version: 1,
ytBroadcastID: null,
ytStreamID: null,
});
});

Expand All @@ -42,6 +44,7 @@ describe("addOrReplaceMediaAsScene", () => {
order: 1,
durationSeconds: 15,
showId: 1,
ytBroadcastID: null,
},
],
durationSeconds: 15,
Expand Down
3 changes: 3 additions & 0 deletions desktop/src/main/ontimeHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ describe("ontimeHelpers", () => {
name: "Test",
start: new Date("2023-10-06T19:00:00+01:00"),
version: 0,
ytBroadcastID: null,
ytStreamID: null,
rundowns: [
{
id: 1,
name: "Test Rundown",
showId: 1,
order: 1,
assets: [],
ytBroadcastID: null,
items: [
{
id: 1,
Expand Down
4 changes: 1 addition & 3 deletions jobrunner/src/jobrunner.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { integrate } from "@bowser/testing";

integrate("doOneJob", () => {
beforeEach(async () => {
await db.$executeRawUnsafe(
`TRUNCATE TABLE "base_jobs" RESTART IDENTITY CASCADE`,
);
await db.$executeRawUnsafe(`DELETE FROM "base_jobs"`);
});
it("works", async () => {
await db.dummyTestJob.create({
Expand Down
8 changes: 2 additions & 6 deletions jobrunner/src/jobs/ProcessMediaJob.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ async function uploadTestFileToTus() {

integrate("ProcessMediaJob", () => {
beforeEach(async () => {
await db.$executeRawUnsafe(
`TRUNCATE TABLE "base_jobs" RESTART IDENTITY CASCADE`,
);
await db.$executeRawUnsafe(
`TRUNCATE TABLE "shows" RESTART IDENTITY CASCADE`,
);
await db.$executeRawUnsafe(`DELETE FROM "base_jobs"`);
await db.$executeRawUnsafe(`DELETE FROM "shows"`);
});
it("works", async () => {
const testMediaID = await uploadTestFileToTus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ exports[`shows listUpcoming returns upcoming shows 1`] = `
"name": "Test Show",
"start": Any<Date>,
"version": 0,
"ytBroadcastID": null,
"ytStreamID": null,
}
`;
2 changes: 1 addition & 1 deletion server/app/api/__tests__/shows.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const api = appRouter.createCaller({});

integrate("shows", () => {
beforeEach(async () => {
await db.$executeRawUnsafe("TRUNCATE TABLE shows CASCADE");
await db.$executeRawUnsafe("DELETE FROM shows");
});
describe("listUpcoming", () => {
it("returns nothing with no shows", async () => {
Expand Down
149 changes: 40 additions & 109 deletions server/app/shows/[show_id]/actions.integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import { db } from "@/lib/db";
import { reorderShowItems } from "./actions";
import { integrate } from "@bowser/testing";
import { ContinuityItem, Rundown, Show } from "@bowser/prisma/client";

jest.mock("server-only", () => ({}));
jest.mock("next/cache", () => ({ revalidatePath: () => {} }));

const TEST_TIME = new Date("2023-07-21T16:46:35.036Z");

integrate("reorderShowItems", () => {
let testShow: Show & {
rundowns: Rundown[];
continuityItems: ContinuityItem[];
};
beforeEach(async () => {
await db.$executeRawUnsafe("TRUNCATE TABLE shows RESTART IDENTITY CASCADE");
await db.show.create({
await db.$executeRawUnsafe("DELETE FROM shows");
testShow = await db.show.create({
data: {
id: 1,
name: "Test Show",
start: TEST_TIME,
rundowns: {
createMany: {
data: [
{
id: 1,
name: "Test 1",
order: 0,
},
{
id: 2,
name: "Test 3",
order: 2,
},
Expand All @@ -35,13 +37,11 @@ integrate("reorderShowItems", () => {
createMany: {
data: [
{
id: 1,
name: "Test 2",
durationSeconds: 0,
order: 1,
},
{
id: 2,
name: "Test 4",
durationSeconds: 0,
order: 3,
Expand All @@ -50,135 +50,66 @@ integrate("reorderShowItems", () => {
},
},
},
include: {
rundowns: true,
continuityItems: true,
},
});
});

test("move 2 to 1", async () => {
await reorderShowItems(1, "continuity_item", 1, 0);
await reorderShowItems(
testShow.id,
"continuity_item",
testShow.continuityItems[0].id,
0,
);
const newShow = await db.show.findFirstOrThrow({
where: { id: 1 },
where: { id: testShow.id },
include: { rundowns: true, continuityItems: true },
});
const newItems = [...newShow.rundowns, ...newShow.continuityItems].sort(
(a, b) => a.order - b.order,
);
expect(newItems).toMatchInlineSnapshot(`
[
{
"durationSeconds": 0,
"id": 1,
"mediaId": null,
"name": "Test 2",
"order": 0,
"showId": 1,
},
{
"id": 1,
"name": "Test 1",
"order": 1,
"showId": 1,
},
{
"id": 2,
"name": "Test 3",
"order": 2,
"showId": 1,
},
{
"durationSeconds": 0,
"id": 2,
"mediaId": null,
"name": "Test 4",
"order": 3,
"showId": 1,
},
]
`);
expect(newItems.map((x) => x.id)).toEqual([
testShow.continuityItems[0].id,
testShow.rundowns[0].id,
testShow.rundowns[1].id,
testShow.continuityItems[1].id,
]);
});

test("move 3 to 1", async () => {
await reorderShowItems(1, "rundown", 2, 0);
await reorderShowItems(testShow.id, "rundown", testShow.rundowns[1].id, 0);
const newShow = await db.show.findFirstOrThrow({
where: { id: 1 },
where: { id: testShow.id },
include: { rundowns: true, continuityItems: true },
});
const newItems = [...newShow.rundowns, ...newShow.continuityItems].sort(
(a, b) => a.order - b.order,
);
expect(newItems).toMatchInlineSnapshot(`
[
{
"id": 2,
"name": "Test 3",
"order": 0,
"showId": 1,
},
{
"id": 1,
"name": "Test 1",
"order": 1,
"showId": 1,
},
{
"durationSeconds": 0,
"id": 1,
"mediaId": null,
"name": "Test 2",
"order": 2,
"showId": 1,
},
{
"durationSeconds": 0,
"id": 2,
"mediaId": null,
"name": "Test 4",
"order": 3,
"showId": 1,
},
]
`);
expect(newItems.map((x) => x.id)).toEqual([
testShow.rundowns[1].id,
testShow.rundowns[0].id,
testShow.continuityItems[0].id,
testShow.continuityItems[1].id,
]);
});

test("move 1 to 4", async () => {
await reorderShowItems(1, "rundown", 1, 3);
await reorderShowItems(testShow.id, "rundown", testShow.rundowns[0].id, 3);
const newShow = await db.show.findFirstOrThrow({
where: { id: 1 },
where: { id: testShow.id },
include: { rundowns: true, continuityItems: true },
});
const newItems = [...newShow.rundowns, ...newShow.continuityItems].sort(
(a, b) => a.order - b.order,
);
expect(newItems).toMatchInlineSnapshot(`
[
{
"durationSeconds": 0,
"id": 1,
"mediaId": null,
"name": "Test 2",
"order": 0,
"showId": 1,
},
{
"id": 2,
"name": "Test 3",
"order": 1,
"showId": 1,
},
{
"durationSeconds": 0,
"id": 2,
"mediaId": null,
"name": "Test 4",
"order": 2,
"showId": 1,
},
{
"id": 1,
"name": "Test 1",
"order": 3,
"showId": 1,
},
]
`);
expect(newItems.map((x) => x.id)).toEqual([
testShow.continuityItems[0].id,
testShow.rundowns[1].id,
testShow.continuityItems[1].id,
testShow.rundowns[0].id,
]);
});
});
Loading
Loading