Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kimon-satan committed Dec 9, 2024
1 parent 01f46d3 commit 0ee174b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`SkipLink functions as expected 1`] = `
<body>
<div>
<div
class="sc-fqkvVR sc-hRJfrW cYDSBE kaiKJJ"
class="sc-fqkvVR sc-gmPhUn cYDSBE fGXRhP"
>
<div
class="sc-fqkvVR bBzdSm grey-shadow"
Expand All @@ -13,7 +13,7 @@ exports[`SkipLink functions as expected 1`] = `
class="sc-fqkvVR bBzdSm yellow-shadow"
/>
<a
class="sc-jxOSlx sc-gmPhUn iaokax hikYDM internal-button"
class="sc-jxOSlx sc-gFAWRd iaokax jSchQQ internal-button"
data-testid="skip-link"
href="foo"
style=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export const ExpiringBanner = ({
href={onwardHref}
onClick={onViewNewLessons}
>
View new lessons
{`View new ${isResourcesMessage ? "resources" : "lessons"}`}
</OakSecondaryButton>
</OakBox>
}
isOpen={isOpen}
message="We've made brand-new and improved lessons for you."
message={`We've made brand-new and improved ${isResourcesMessage ? "resources" : "lessons"} for you.`}
onDismiss={onClose}
title={title}
type="alert"
Expand Down
30 changes: 21 additions & 9 deletions src/components/TeacherViews/LessonOverview/LessonOverview.view.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, Fragment } from "react";
import React, { useRef, Fragment, useState } from "react";
import {
OakGrid,
OakGridArea,
Expand Down Expand Up @@ -47,9 +47,9 @@ import {
checkIsResourceCopyrightRestricted,
getIsResourceDownloadable,
} from "@/components/TeacherComponents/helpers/downloadAndShareHelpers/downloadsCopyright";
import NewContentBanner from "@/components/TeacherComponents/NewContentBanner/NewContentBanner";
import { GridArea } from "@/components/SharedComponents/Grid.deprecated";
import AspectRatio from "@/components/SharedComponents/AspectRatio";
import { ExpiringBanner } from "@/components/SharedComponents/ExpiringBanner";

export type LessonOverviewProps = {
lesson: LessonOverviewAll & { downloads: LessonOverviewDownloads } & {
Expand Down Expand Up @@ -98,7 +98,9 @@ export function LessonOverview({ lesson, isBeta }: LessonOverviewProps) {
lessonGuideUrl,
teacherShareButton,
additionalMaterialUrl,
actions,
} = lesson;

const { track } = useAnalytics();
const { analyticsUseCase } = useAnalyticsPageProps();
const commonPathway = getPathway(lesson);
Expand All @@ -121,6 +123,11 @@ export function LessonOverview({ lesson, isBeta }: LessonOverviewProps) {

const MathJaxLessonProvider = isMathJaxLesson ? MathJaxProvider : Fragment;

const [showExpiredLessonsBanner, setShowExpiredLessonsBanner] =
useState<boolean>(actions?.displayExpiringBanner);

const unitListingHref = `/teachers/key-stages/${keyStageSlug}/subjects/${subjectSlug}/programmes`;

const trackDownloadResourceButtonClicked = ({
downloadResourceButtonName,
}: {
Expand Down Expand Up @@ -252,13 +259,6 @@ export function LessonOverview({ lesson, isBeta }: LessonOverviewProps) {
teacherShareButton={teacherShareButton}
/>
<MaxWidth $ph={16} $pb={80}>
<NewContentBanner
keyStageSlug={keyStageSlug ?? ""}
subjectSlug={subjectSlug ?? ""}
subjectTitle={subjectTitle ? subjectTitle.toLowerCase() : ""}
programmeSlug={programmeSlug ?? ""}
isLegacy={lessonCohort === LEGACY_COHORT}
/>
{expired ? (
<Box $pa={16} $mb={64}>
<OakHeading $font={"heading-7"} tag={"h2"} $mb="space-between-s">
Expand Down Expand Up @@ -291,8 +291,20 @@ export function LessonOverview({ lesson, isBeta }: LessonOverviewProps) {
/>
</OakFlex>
</GridArea>

<OakGridArea $colSpan={[12, 9]}>
<OakFlex $flexDirection={"column"} $position={"relative"}>
<OakBox $pb={"inner-padding-m"}>
<ExpiringBanner
isOpen={showExpiredLessonsBanner}
isResourcesMessage={true}
onwardHref={unitListingHref}
onClose={() => {
setShowExpiredLessonsBanner(false);
}}
/>
</OakBox>

{pageLinks.find((p) => p.label === "Lesson guide") &&
lessonGuideUrl && (
<LessonItemContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export const transformedLessonOverviewData = (
lessonGuideUrl: content.lessonGuideAssetObjectUrl ?? null,
phonicsOutcome: content.phonicsOutcome,
pathways: pathways,
actions: browseData.actions,
};
};

Expand Down
9 changes: 5 additions & 4 deletions src/node-lib/curriculum-api-2023/shared.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ export const lessonOverviewQuizData = z

export type LessonOverviewQuizData = z.infer<typeof lessonOverviewQuizData>;

const camelActionSchema = zodToCamelCase(actionsSchema);

export type Actions = z.infer<typeof camelActionSchema>;

export const baseLessonOverviewSchema = z.object({
isLegacy: z.boolean(),
lessonSlug: z.string(),
Expand Down Expand Up @@ -199,6 +203,7 @@ export const baseLessonOverviewSchema = z.object({
updatedAt: z.string(),
lessonGuideUrl: z.string().nullable(),
phonicsOutcome: z.string().nullish(),
actions: camelActionSchema.nullish(),
});
export type LessonBase = z.infer<typeof baseLessonOverviewSchema>;

Expand Down Expand Up @@ -239,10 +244,6 @@ export const baseLessonDownloadsSchema = z.object({
loginRequired: z.boolean().nullable(),
});

const camelActionSchema = zodToCamelCase(actionsSchema);

export type Actions = z.infer<typeof camelActionSchema>;

export const lessonListItemSchema = z.object({
lessonSlug: z.string(),
lessonTitle: z.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const LessonListPage: NextPage<LessonListingPageProps> = ({
expiringBanner={
<ExpiringBanner
isOpen={showExpiredLessonsBanner}
isResourcesMessage={false}
isResourcesMessage={true}
onwardHref={unitListingHref}
onClose={() => {
setShowExpiredLessonsBanner(false);
Expand Down

0 comments on commit 0ee174b

Please sign in to comment.