-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds media clips to lesson overview
- Loading branch information
Showing
28 changed files
with
414 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
49 changes: 49 additions & 0 deletions
49
src/components/TeacherComponents/LessonOverviewMediaClips/LessonMediaClipWithThumbnail.tsx
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,49 @@ | ||
import { FC } from "react"; | ||
import { | ||
OakMediaClipStackListItem, | ||
OakMediaClipStackListItemProps, | ||
} from "@oaknational/oak-components"; | ||
|
||
import { | ||
PlaybackPolicy, | ||
useSignedThumbnailToken, | ||
} from "@/components/SharedComponents/VideoPlayer/useSignedVideoToken"; | ||
|
||
export type LessonMediaClipWithThumbnailProps = Omit< | ||
OakMediaClipStackListItemProps, | ||
"imageUrl" | "imageAltText" | ||
> & { | ||
playbackId: string; | ||
playbackPolicy: PlaybackPolicy; | ||
numberOfClips: number; | ||
}; | ||
|
||
const LessonMediaClipWithThumbnail: FC<LessonMediaClipWithThumbnailProps> = ({ | ||
title, | ||
playbackId, | ||
playbackPolicy, | ||
numberOfClips, | ||
href, | ||
}: LessonMediaClipWithThumbnailProps) => { | ||
const thumbnailToken = useSignedThumbnailToken({ | ||
playbackId, | ||
playbackPolicy, | ||
isLegacy: false, | ||
}); | ||
|
||
const thumbnailImage = thumbnailToken | ||
? `https://image.mux.com/${playbackId}/thumbnail.png?token=${thumbnailToken.playbackToken}` | ||
: ""; | ||
|
||
return ( | ||
<OakMediaClipStackListItem | ||
title={title} | ||
imageUrl={thumbnailImage} | ||
imageAltText="" | ||
href={href} | ||
numberOfClips={numberOfClips} | ||
/> | ||
); | ||
}; | ||
|
||
export default LessonMediaClipWithThumbnail; |
38 changes: 38 additions & 0 deletions
38
...omponents/TeacherComponents/LessonOverviewMediaClips/LessonOverviewMediaClips.stories.tsx
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,38 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { | ||
OakBox, | ||
OakMaxWidth, | ||
OakThemeProvider, | ||
oakDefaultTheme, | ||
} from "@oaknational/oak-components"; | ||
|
||
import Component from "./LessonOverviewMediaClips"; | ||
|
||
import lessonMediaClipsFixtures from "@/node-lib/curriculum-api-2023/fixtures/lessonMediaClips.fixture"; | ||
|
||
const meta: Meta<typeof Component> = { | ||
component: Component, | ||
argTypes: { | ||
learningCycleVideos: lessonMediaClipsFixtures().mediaClips, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof Component>; | ||
|
||
export const LessonOverviewMediaClips: Story = { | ||
args: { | ||
learningCycleVideos: lessonMediaClipsFixtures().mediaClips, | ||
}, | ||
render: (args) => { | ||
return ( | ||
<OakThemeProvider theme={oakDefaultTheme}> | ||
<OakMaxWidth> | ||
<OakBox> | ||
<Component {...args} /> | ||
</OakBox> | ||
</OakMaxWidth> | ||
</OakThemeProvider> | ||
); | ||
}, | ||
}; |
75 changes: 75 additions & 0 deletions
75
src/components/TeacherComponents/LessonOverviewMediaClips/LessonOverviewMediaClips.test.tsx
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,75 @@ | ||
import LessonOverviewMediaClips from "./LessonOverviewMediaClips"; | ||
|
||
import renderWithTheme from "@/__tests__/__helpers__/renderWithTheme"; | ||
import { resolveOakHref } from "@/common-lib/urls"; | ||
import lessonMediaClipsFixtures from "@/node-lib/curriculum-api-2023/fixtures/lessonMediaClips.fixture"; | ||
|
||
jest.mock("@/common-lib/urls", () => ({ | ||
resolveOakHref: jest.fn(), | ||
})); | ||
|
||
// TODO: Clean up the tests | ||
// TODO: Add storybook file so can test with more video entries | ||
|
||
const mockLearningCycleVideos = lessonMediaClipsFixtures().mediaClips; | ||
|
||
describe("LessonOverviewMediaClips", () => { | ||
it("renders correctly with given props", () => { | ||
const { getByText } = renderWithTheme( | ||
<LessonOverviewMediaClips | ||
learningCycleVideos={mockLearningCycleVideos} | ||
unitSlug="unit-slug" | ||
programmeSlug="programme-slug" | ||
/>, | ||
); | ||
|
||
expect( | ||
getByText("Introduction physical exercise video"), | ||
).toBeInTheDocument(); | ||
expect(getByText("Cycle 1 running video")).toBeInTheDocument(); | ||
}); | ||
|
||
it("calls resolveOakHref with correct arguments when programmeSlug and unitSlug are provided", () => { | ||
renderWithTheme( | ||
<LessonOverviewMediaClips | ||
learningCycleVideos={mockLearningCycleVideos} | ||
unitSlug="unit-slug" | ||
programmeSlug="programme-slug" | ||
/>, | ||
); | ||
|
||
expect(resolveOakHref).toHaveBeenCalledWith({ | ||
page: "lesson-media", | ||
lessonSlug: "cycle-1-running-video", | ||
programmeSlug: "programme-slug", | ||
unitSlug: "unit-slug", | ||
}); | ||
|
||
expect(resolveOakHref).toHaveBeenCalledWith({ | ||
page: "lesson-media", | ||
lessonSlug: "cycle-2-video", | ||
programmeSlug: "programme-slug", | ||
unitSlug: "unit-slug", | ||
}); | ||
}); | ||
|
||
it("calls resolveOakHref with correct arguments when programmeSlug and unitSlug are not provided", () => { | ||
renderWithTheme( | ||
<LessonOverviewMediaClips | ||
learningCycleVideos={mockLearningCycleVideos} | ||
unitSlug={null} | ||
programmeSlug={null} | ||
/>, | ||
); | ||
|
||
expect(resolveOakHref).toHaveBeenCalledWith({ | ||
page: "lesson-media-canonical", | ||
lessonSlug: "introduction-physical-exercise-video", | ||
}); | ||
|
||
expect(resolveOakHref).toHaveBeenCalledWith({ | ||
page: "lesson-media-canonical", | ||
lessonSlug: "cycle-1-running-video", | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.