diff --git a/frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpanded.test.tsx b/frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpanded.test.tsx index 4848ea4785..0af5945c86 100644 --- a/frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpanded.test.tsx +++ b/frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpanded.test.tsx @@ -11,6 +11,7 @@ import { ThemeProvider } from "../ThemeProvider/ThemeProvider" import invariant from "tiny-invariant" import type { LearningResource } from "api" import { faker } from "@faker-js/faker/locale/en" +import { PLATFORMS } from "../Logo/Logo" const IMG_CONFIG: LearningResourceExpandedProps["imgConfig"] = { key: "fake-key", @@ -132,6 +133,28 @@ describe("Learning Resource Expanded", () => { }, ) + test.each([ResourceTypeEnum.PodcastEpisode])( + "Renders xpro logo conditionally on offered_by=xpro and not platform.code", + (resourceType) => { + const resource = factories.learningResources.resource({ + resource_type: resourceType, + platform: { code: "test" }, + offered_by: { code: "xpro" }, + podcast_episode: { + episode_link: "https://example.com", + }, + }) + + setup(resource) + const xproImage = screen + .getAllByRole("img") + .find((img) => img.getAttribute("alt")?.includes("xPRO")) + + expect(xproImage).toBeInTheDocument() + expect(xproImage).toHaveAttribute("alt", PLATFORMS["xpro"].name) + }, + ) + test(`Renders info section for resource type "${ResourceTypeEnum.Video}"`, () => { const resource = factories.learningResources.resource({ resource_type: ResourceTypeEnum.Video, diff --git a/frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpanded.tsx b/frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpanded.tsx index 8949a85719..e188df4962 100644 --- a/frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpanded.tsx +++ b/frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpanded.tsx @@ -212,11 +212,13 @@ const CallToActionSection = ({ ) } - - const platformImage = - PLATFORMS[resource?.platform?.code as PlatformEnum]?.image - const { platform } = resource! + const offeredBy = resource?.offered_by + const platformCode = + (offeredBy?.code as PlatformEnum) === PlatformEnum.Xpro + ? (offeredBy?.code as PlatformEnum) + : (platform?.code as PlatformEnum) + const platformImage = PLATFORMS[platformCode]?.image const getCallToActionText = (resource: LearningResource): string => { if (resource?.platform?.code === PlatformEnum.Ocw) { @@ -244,7 +246,7 @@ const CallToActionSection = ({ {platformImage ? ( on - + ) : null}