Skip to content

Add data-ph- elements to CTA buttons #1821

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

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe("Learning Resource Expanded", () => {
}) as HTMLAnchorElement

expect(link.href).toMatch(new RegExp(`^${resource.url}/?$`))
expect(link.getAttribute("data-ph-action")).toBe("click-cta")
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ const CallToActionSection = ({
<StyledLink
target="_blank"
size="medium"
data-ph-action="click-cta"
data-ph-offered-by={offeredBy?.code}
data-ph-resource-type={resource.resource_type}
data-ph-resource-id={resource.id}
endIcon={<RiExternalLinkLine />}
href={getCallToActionUrl(resource) || ""}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ describe("Learning Resource Expanded", () => {

setup(resource)

const linkName = "Learn More"
const linkName = "Learn More About"
if (linkName) {
const link = screen.getByRole("link", {
name: linkName,
}) as HTMLAnchorElement

expect(link.href).toMatch(new RegExp(`^${resource.url}/?$`))
expect(link.getAttribute("data-ph-action")).toBe("click-cta")
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ const getCallToActionText = (resource: LearningResource): string => {
const accessCourseMaterials = "Access Course Materials"
const watchOnYouTube = "Watch on YouTube"
const listenToPodcast = "Listen to Podcast"
const learnMore = "Learn More"
const learnMore = "Learn More About"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming V2 isnt displayed anywhere yet. was this copy change intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was not, fixed in bb7bd02

const callsToAction = {
[ResourceTypeEnum.Course]: learnMore,
[ResourceTypeEnum.Program]: learnMore,
Expand Down Expand Up @@ -355,6 +355,10 @@ const CallToActionSection = ({
<StyledLink
target="_blank"
size="medium"
data-ph-action="click-cta"
data-ph-offered-by={offeredBy?.code}
data-ph-resource-type={resource.resource_type}
data-ph-resource-id={resource.id}
endIcon={<RiExternalLinkLine />}
href={getCallToActionUrl(resource) || ""}
>
Expand Down
Loading