Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<link rel="shortcut icon" href="/img/icons/favicon.ico">
<meta property="og:image" content="https://data.firefox.com/img/ogimage.png">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary_large_image">
<!-- data-rh lets react-helmet-async replace this with each page's own og:title. -->
<meta property="og:title" content="Firefox Public Data Report" data-rh="true">
<title>Firefox Public Data Report</title>
</head>
<body>
Expand Down
4 changes: 4 additions & 0 deletions tests/playwright/specs/jsDisabled.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ test('Correct <noscript> message is displayed when JavaScript is disabled', asyn
await expect(page.locator('#enable-javascript')).toBeVisible();
await expect(page.locator('#enable-javascript')).toHaveText('You need to enable JavaScript to run this app.');
});

test('index.html has an og:title for crawlers that do not run JavaScript', async ({ page }) => {
await expect(page.locator('meta[property="og:title"]')).toHaveAttribute('content', 'Firefox Public Data Report');
});
29 changes: 29 additions & 0 deletions tests/playwright/specs/og-title.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { test, expect } = require('../fixtureData');


const pages = [
['/', 'Firefox Public Data Report'],
['/contact', 'Contact | Firefox Public Data Report'],
['/dashboard/hardware', 'Hardware Across the Web | Firefox Public Data Report'],
];

for (const [path, title] of pages) {
test(`${path} replaces the static og:title with its own`, async ({ page }) => {
await page.goto(path);
await expect(page).toHaveTitle(title);

const ogTitle = page.locator('meta[property="og:title"]');
await expect(ogTitle).toHaveCount(1);
await expect(ogTitle).toHaveAttribute('content', title);
});
}

test('Navigating between pages keeps a single og:title', async ({ page }) => {
await page.goto('/contact');
await page.locator('#main-navigation a', { hasText: 'Hardware' }).click();
await expect(page).toHaveTitle('Hardware Across the Web | Firefox Public Data Report');

const ogTitle = page.locator('meta[property="og:title"]');
await expect(ogTitle).toHaveCount(1);
await expect(ogTitle).toHaveAttribute('content', 'Hardware Across the Web | Firefox Public Data Report');
});
Loading