Skip to content

Commit

Permalink
Test for EmbedCard with and without author image
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickpatrickpatrick committed Feb 28, 2025
1 parent 3a71e6a commit 8a93428
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
10 changes: 10 additions & 0 deletions __tests__/embed-card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@ describe('Embed Card', () => {

await expect(page.$('.app-embed-card__placeholder')).resolves.toBe(null)
})

it('will not render author image if not specified', async () => {
await expect(page.$('app-embed-card__author-img')).resolves.toBe(null)
})

it('will render author image if specified', async () => {
await goTo(page, '/embed-test-author-img/')

await expect(page.$('.app-embed-card__author-img')).resolves.not.toBe(null)
})
})
47 changes: 47 additions & 0 deletions src/embed-test-author-img.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: Test Embed Page
description: Description
layout: layout-pane.njk
order: 16
draft: true
ignoreInSitemap: true
---

{% from "_embed-card.njk" import embedCard %}

{% from "_cookie-banner.njk" import cookieBanner %}

## Test Page

{% set html %}

<p class="govuk-body">You'll need to accept cookies to watch the videos on this page.</p>
<p class="govuk-body">If you don't want to accept cookies, the videos and transcripts are also available on YouTube.</p>
{% endset %}

{% set acceptHtml %}

<p class="govuk-body">You’ve accepted campaign cookies. You can <a class="govuk-link" href="/cookies/">change your cookie settings</a> at any time.</p>
{% endset %}

{% set rejectHtml %}

<p class="govuk-body">You’ve rejected campiagn cookies. You can <a class="govuk-link" href="/cookies/">change your cookie settings</a> at any time.</p>
{% endset %}

{% call cookieBanner({
html: html,
acceptHtml: acceptHtml,
rejectHtml: rejectHtml,
category: "campaign",
classes: "app-campaign-cookie-banner govuk-!-padding-right-5 govuk-!-padding-left-5 govuk-!-margin-bottom-5",
title: "Accept additional cookies to watch videos of Design System Day"
}) %}{% endcall %}

{% call embedCard({
ytId: "x91MPoITQ3I",
transcriptHref: "https://www.google.com",
authorImgSrc: "/images/yt-thumb-example.jpg",
title: "Test Video"
}) %}
{% endcall %}
2 changes: 1 addition & 1 deletion views/partials/_embed-card.njk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
{% if params.authorImgSrc %}
<div class="govuk-grid-column-one-third-from-desktop">
<img class="app-image--no-border" src="{{ params.authorImgSrc }}" alt="{{ params.authorImgAlt }}" role="presentation">
<img class="app-image--no-border app-embed-card__author-img" src="{{ params.authorImgSrc }}" alt="{{ params.authorImgAlt }}" role="presentation">
</div>
{% endif %}
</div>
Expand Down

0 comments on commit 8a93428

Please sign in to comment.