|
| 1 | +describe('Link-List Block', () => { |
| 2 | + beforeAll(async () => { |
| 3 | + await page.goto(`${global.BASE_URL}pattern-library/`); |
| 4 | + }); |
| 5 | + |
| 6 | + it('should render the link-list block', async () => { |
| 7 | + await page.waitForSelector('.link-list'); |
| 8 | + const linkLists = await page.$$('.link-list'); |
| 9 | + expect(linkLists.length).toBeGreaterThanOrEqual(1); |
| 10 | + }); |
| 11 | + |
| 12 | + it('should render the link-list title', async () => { |
| 13 | + await page.waitForSelector('.link-list__title'); |
| 14 | + const linkListTitles = await page.$$('.link-list__title'); |
| 15 | + expect(linkListTitles.length).toBeGreaterThanOrEqual(1); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should render the link-list footer link, if it exists', async () => { |
| 19 | + await page.waitForSelector('.link-list > a'); |
| 20 | + const linkListsWithFooterLink = await page.$$('.link-list > a'); |
| 21 | + |
| 22 | + if (linkListsWithFooterLink) { |
| 23 | + expect(linkListsWithFooterLink.length).toBeGreaterThanOrEqual(1); |
| 24 | + }; |
| 25 | + }) |
| 26 | + |
| 27 | + describe('Link-List-Item', () => { |
| 28 | + beforeAll(async () => { |
| 29 | + await page.waitForSelector('.link-list-item'); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should apply an external link class when the link points outside of adobe.design', async () => { |
| 33 | + const linkListItemWithExternalLink = await page.$('.link-list-item:not([href^="https://adobe.design"])'); |
| 34 | + |
| 35 | + if (linkListItemWithExternalLink) { |
| 36 | + const hasExternalLinkClass = await linkListItemWithExternalLink.evaluate((el) => el.classList.contains('link-list-item--external')); |
| 37 | + expect(hasExternalLinkClass).toBe(true); |
| 38 | + } else { |
| 39 | + console.log('No link-list-items with external links found.'); |
| 40 | + }; |
| 41 | + }); |
| 42 | + |
| 43 | + it('should have job post classes applied when the link is a job posting', async () => { |
| 44 | + const linkListItemWithjobLink = await page.$('.link-list-item[href^="https://adobe.design/jobs/job-posts/"]'); |
| 45 | + |
| 46 | + if (linkListItemWithjobLink) { |
| 47 | + const linkListItemWithJobLinkChildren = await linkListItemWithjobLink.$$('span'); |
| 48 | + |
| 49 | + linkListItemWithJobLinkChildren.forEach(async (child) => { |
| 50 | + const classes = await child.evaluate((el) => el.classList); |
| 51 | + const hasJobClass = classes[0].startsWith('link-list-item__job'); |
| 52 | + expect(hasJobClass).toBe(true); |
| 53 | + }); |
| 54 | + } else { |
| 55 | + console.log('No link-list-items with job links found.'); |
| 56 | + }; |
| 57 | + }); |
| 58 | + }); |
| 59 | +}); |
0 commit comments