Skip to content
Open
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: 6 additions & 0 deletions apis/api-gateway/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,10 @@ type VideoBlock implements Block @join__type(graph: API_JOURNEYS, key: "id") @j
showGeneratedSubtitles: Boolean
customizable: Boolean
mediaVideo: MediaVideo @join__field(graph: API_JOURNEYS_MODERN)
"""
Publisher notes for template adapters (e.g. trailer, intro).
"""
notes: String @join__field(graph: API_JOURNEYS_MODERN)
}

"""
Expand Down Expand Up @@ -5033,6 +5037,7 @@ input VideoBlockCreateInput @join__type(graph: API_JOURNEYS_MODERN) {
subtitleLanguageId: ID
showGeneratedSubtitles: Boolean
customizable: Boolean
notes: String
}

input VideoBlockUpdateInput @join__type(graph: API_JOURNEYS_MODERN) {
Expand Down Expand Up @@ -5060,6 +5065,7 @@ input VideoBlockUpdateInput @join__type(graph: API_JOURNEYS_MODERN) {
source: VideoBlockSource
showGeneratedSubtitles: Boolean
customizable: Boolean
notes: String
}

input LanguagesFilter @join__type(graph: API_LANGUAGES) {
Expand Down
5 changes: 5 additions & 0 deletions apis/api-journeys-modern/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,9 @@ type VideoBlock implements Block
showGeneratedSubtitles: Boolean
mediaVideo: MediaVideo
customizable: Boolean

"""Publisher notes for template adapters (e.g. trailer, intro)."""
notes: String
}

input VideoBlockCreateInput {
Expand Down Expand Up @@ -2424,6 +2427,7 @@ input VideoBlockCreateInput {
subtitleLanguageId: ID
showGeneratedSubtitles: Boolean
customizable: Boolean
notes: String
}

enum VideoBlockObjectFit {
Expand Down Expand Up @@ -2465,6 +2469,7 @@ input VideoBlockUpdateInput {
source: VideoBlockSource
showGeneratedSubtitles: Boolean
customizable: Boolean
notes: String
}

type VideoCollapseEvent implements Event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export const VideoBlockCreateInput = builder.inputType(
posterBlockId: t.id({ required: false }),
subtitleLanguageId: t.id({ required: false }),
showGeneratedSubtitles: t.boolean({ required: false }),
customizable: t.boolean({ required: false })
customizable: t.boolean({ required: false }),
notes: t.string({ required: false })
})
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const VideoBlockUpdateInput = builder.inputType(
youTube source: videoId required`
}),
showGeneratedSubtitles: t.boolean({ required: false }),
customizable: t.boolean({ required: false })
customizable: t.boolean({ required: false }),
notes: t.string({ required: false })
})
}
)
5 changes: 5 additions & 0 deletions apis/api-journeys-modern/src/schema/block/video/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ youTube source: videoId, title, description, and duration present`,
}),
customizable: t.exposeBoolean('customizable', {
nullable: true
}),
notes: t.exposeString('notes', {
nullable: true,
description:
'Publisher notes for template adapters (e.g. trailer, intro).'
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jest.mock('./service', () => {
}
})

type VideoBlockUpdateResult = {
data?: { videoBlockUpdate: { notes: string | null } }
}

describe('videoBlockUpdate', () => {
const mockUser = { id: 'userId' }
const authClient = getClient({
Expand Down Expand Up @@ -47,6 +51,7 @@ describe('videoBlockUpdate', () => {
posterBlockId
parentBlockId
showGeneratedSubtitles
notes
subtitleLanguage {
id
}
Expand Down Expand Up @@ -97,6 +102,7 @@ describe('videoBlockUpdate', () => {
journeyId: 'journeyId',
typename: 'VideoBlock',
subtitleLanguage: null,
notes: null,
...input
})
},
Expand Down Expand Up @@ -156,4 +162,83 @@ describe('videoBlockUpdate', () => {
]
})
})

it('updates and returns notes when notes is set', async () => {
fetchBlockWithJourneyAcl.mockResolvedValue({
id,
journeyId: 'journeyId',
journey: { id: 'journeyId' }
})
mockAbility.mockReturnValue(true)

const notesInput = { notes: 'test trailer note' }
const tx = {
block: {
update: jest.fn().mockResolvedValue({
id,
journeyId: 'journeyId',
typename: 'VideoBlock',
subtitleLanguage: null,
...input,
...notesInput
})
},
journey: { update: jest.fn().mockResolvedValue({ id: 'journeyId' }) }
}
prismaMock.$transaction.mockImplementation(async (cb: any) => await cb(tx))

const result = await authClient({
document: VIDEO_BLOCK_UPDATE,
variables: { id, input: { ...input, ...notesInput } }
})

expect(
(result as VideoBlockUpdateResult).data?.videoBlockUpdate.notes
).toBe('test trailer note')
expect(tx.block.update).toHaveBeenCalledWith(
expect.objectContaining({
where: { id },
data: expect.objectContaining({ notes: 'test trailer note' })
})
)
})

it('clears notes when notes is set to empty string', async () => {
fetchBlockWithJourneyAcl.mockResolvedValue({
id,
journeyId: 'journeyId',
journey: { id: 'journeyId' }
})
mockAbility.mockReturnValue(true)

const tx = {
block: {
update: jest.fn().mockResolvedValue({
id,
journeyId: 'journeyId',
typename: 'VideoBlock',
subtitleLanguage: null,
notes: '',
...input
})
},
journey: { update: jest.fn().mockResolvedValue({ id: 'journeyId' }) }
}
prismaMock.$transaction.mockImplementation(async (cb: any) => await cb(tx))

const result = await authClient({
document: VIDEO_BLOCK_UPDATE,
variables: { id, input: { ...input, notes: '' } }
})

expect(
(result as VideoBlockUpdateResult).data?.videoBlockUpdate.notes
).toBe('')
expect(tx.block.update).toHaveBeenCalledWith(
expect.objectContaining({
where: { id },
data: expect.objectContaining({ notes: '' })
})
)
})
})
1 change: 1 addition & 0 deletions apis/api-journeys/src/app/__generated__/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions apis/api-journeys/src/app/modules/block/video/video.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,8 @@ type VideoBlock implements Block @key(fields: "id") @shareable {
subtitleLanguage: Language @shareable
showGeneratedSubtitles: Boolean @shareable
customizable: Boolean @shareable
"""
Publisher notes for template adapters (e.g. trailer, intro).
"""
notes: String @shareable
}
1 change: 1 addition & 0 deletions apps/journeys-admin/__generated__/globalTypes.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Block" ADD COLUMN "notes" TEXT;
1 change: 1 addition & 0 deletions libs/prisma/journeys/db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ model Block {
settings Json @default("{ }") // block settings
exportOrder Int? // column order for CSV exports and Google Sheets syncs
customizable Boolean?
notes String? // VideoBlock: publisher notes for template adapters (e.g. trailer, intro)

@@unique([slug, journeyId])
@@index(journeyId)
Expand Down
Loading