Skip to content

Commit

Permalink
Merge pull request #394 from UN-OCHA/CD-537
Browse files Browse the repository at this point in the history
test: update E2E to match the upcoming change to OCHA Services
  • Loading branch information
rupl authored Feb 26, 2024
2 parents 11f39d3 + 9c9f7a8 commit 065b076
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- develop
- 'cd-*'
- 'CD-*'
- 'OPS-*'
- 'feature/**'
- main
release:
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
import env from './_env'

describe('OCHAServicesDropdown', () => {
describe('OCHAServices', () => {
beforeAll(async() => {
await page.goto(env.baseUrl);
});

it('should expand when clicked', async() => {
const toggle = await page.$('#cd-ocha-dropdown-toggler');
await toggle.click();
const hidden = await page.$eval('#cd-ocha-dropdown', el => el.dataset.cdHidden);
await expect(hidden).toMatch('false');
});

it('should contain up to four links in the Related Platforms section', async() => {
const relatedPlatformsLimit = 4;
await page.waitForSelector('.cd-ocha-dropdown__section:first-child');
const relatedPlatformsLength = await page.$$eval('.cd-ocha-dropdown__section:first-child', nodeList => nodeList.length);
await page.waitForSelector('.cd-ocha-services__section:first-child');
const relatedPlatformsLength = await page.$$eval('.cd-ocha-services__section:first-child', nodeList => nodeList.length);
await expect(relatedPlatformsLength).toBeLessThanOrEqual(relatedPlatformsLimit);
});

it('should NOT contain links with default text in the Related Platforms section', async() => {
const relatedPlatformsText = await page.$eval('.cd-ocha-dropdown__section:first-child .cd-ocha-dropdown__link a', (el) => el.innerHTML);
const relatedPlatformsText = await page.$eval('.cd-ocha-services__section:first-child :is(.cd-ocha-services__link, .cd-ocha-dropdown__link) a', (el) => el.innerHTML);
await expect(relatedPlatformsText).not.toMatch('Customizable');
});

it('should contain eight links in the Other OCHA Services section', async() => {
const otherOchaServicesLimit = 8;
await page.waitForSelector('.cd-ocha-dropdown__section:not(:first-child)');
const otherOchaServicesLength = await page.$$eval('.cd-ocha-dropdown__section:not(:first-child)', nodeList => nodeList.length);
await page.waitForSelector('.cd-ocha-services__section:not(:first-child)');
const otherOchaServicesLength = await page.$$eval('.cd-ocha-services__section:not(:first-child)', nodeList => nodeList.length);
await expect(otherOchaServicesLength).toBeLessThanOrEqual(otherOchaServicesLimit);
});

Expand All @@ -52,14 +45,14 @@ describe('OCHAServicesDropdown', () => {
'https://reliefweb.int/',
'https://vosocc.unocha.org/'
];
const otherOchaServices = await page.$$eval('.cd-ocha-dropdown__section:not(:first-child) .cd-ocha-dropdown__link a', text => { return text.map(text => text.textContent).slice(0, 8) });
const otherOchaServicesHref = await page.$$eval('.cd-ocha-dropdown__section:not(:first-child) .cd-ocha-dropdown__link a', anchors => { return anchors.map(anchor => anchor.href).slice(0, 8) });
const otherOchaServices = await page.$$eval('.cd-ocha-services__section:not(:first-child) .cd-ocha-services__link a', text => { return text.map(text => text.textContent).slice(0, 8) });
const otherOchaServicesHref = await page.$$eval('.cd-ocha-services__section:not(:first-child) .cd-ocha-services__link a', anchors => { return anchors.map(anchor => anchor.href).slice(0, 8) });
await expect(otherOchaServices).toEqual(otherOchaServicesCorporate);
await expect(otherOchaServicesHref).toEqual(otherOchaServicesCorporateHref);
});

it('should include a button to UNOCHA.org DS list', async() => {
const seeAllButtonHref = await page.$eval('.cd-ocha-dropdown__see-all', (el) => el.href);
const seeAllButtonHref = await page.$eval('.cd-ocha-services__see-all', (el) => el.href);
const expectedUrl = 'https://www.unocha.org/ocha-digital-services';
await expect(seeAllButtonHref).toEqual(expectedUrl);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% endblock %}

{% block ocha %}
{% include '@common_design_subtheme/cd/cd-header/cd-ocha.html.twig' %}
{% include '@common_design_subtheme/cd/cd-footer/cd-ocha.html.twig' %}
{% endblock %}

{% endembed %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% embed '@common_design/cd/cd-footer/cd-ocha.html.twig' %}

{% block related_platforms %}
<li class="cd-ocha-services__link"><a href="https://example.com">{{ 'Overridden in sub-theme'|t }}</a></li>
<li class="cd-ocha-services__link"><a href="https://example.com">{{ 'Custom link'|t }}</a></li>
<li class="cd-ocha-services__link"><a href="https://example.com">{{ 'Custom link'|t }}</a></li>
<li class="cd-ocha-services__link"><a href="https://example.com">{{ 'Custom link'|t }}</a></li>
{% endblock %}

{% endembed %}

This file was deleted.

0 comments on commit 065b076

Please sign in to comment.