diff --git a/tests/rendering-fixtures/head.js b/tests/rendering-fixtures/head.js new file mode 100644 index 000000000000..3cdd03297b9b --- /dev/null +++ b/tests/rendering-fixtures/head.js @@ -0,0 +1,13 @@ +import { getDOM } from '../helpers/e2etest.js' + +describe('', () => { + test('includes page intro in `description` meta tag', async () => { + const $ = await getDOM('/get-started/markdown/intro') + // The intro has Markdown syntax which becomes HTML encoded in the lead element. + const lead = $('[data-testid="lead"] p') + expect(lead.html()).toMatch('syntax') + // As a meta description its content is stripped of all HTML + const description = $('head meta[name="description"]') + expect(description.attr('content')).toBe('This intro has Markdown syntax for GitHub') + }) +}) diff --git a/tests/rendering/head.js b/tests/rendering/head.js deleted file mode 100644 index 3a4132421bb7..000000000000 --- a/tests/rendering/head.js +++ /dev/null @@ -1,29 +0,0 @@ -import { getDOM } from '../helpers/e2etest.js' -import { jest } from '@jest/globals' - -jest.useFakeTimers({ legacyFakeTimers: true }) - -describe('', () => { - jest.setTimeout(5 * 60 * 1000) - - test('includes page intro in `description` meta tag', async () => { - const $ = await getDOM('/en/articles/about-ssh') - const $description = $('meta[name="description"]') - expect($description.attr('content').startsWith('Using the SSH protocol')).toBe(true) - }) - - test('renders `description` meta tag in plaintext (no HTML)', async () => { - const $ = await getDOM('/en/articles/about-pull-request-merges') - const $description = $('meta[name="description"]') - // plain text intro - expect( - $description.attr('content').startsWith('You can merge pull requests by retaining') - ).toBe(true) - // HTML intro - expect( - $('[data-testid="lead"]') - .html() - .startsWith('

You can merge pull requests') - ) - }) -})