Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/opt-out-banners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@node-core/doc-kit': minor
---

Add banner opt-out
39 changes: 36 additions & 3 deletions e2e/announcement-banner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ test.describe('Announcement Banner', () => {

await page.goto('/assert.html');

const banner = page.getByRole('region', { name: 'Announcements' });
const banner = page.getByRole('region', { name: 'Announcement' });
await expect(banner).toBeVisible();
await expect(banner).toContainText('Important announcement for all users');
await expect(
banner.getByRole('button', { name: 'Close banner' })
).toBeVisible();
});

test('renders a banner with a link', async ({ page }) => {
Expand All @@ -39,7 +42,7 @@ test.describe('Announcement Banner', () => {

await page.goto('/assert.html');

const banner = page.getByRole('region', { name: 'Announcements' });
const banner = page.getByRole('region', { name: 'Announcement' });
await expect(banner).toBeVisible();

const link = banner.getByRole('link', { name: 'Read the release notes' });
Expand All @@ -60,7 +63,37 @@ test.describe('Announcement Banner', () => {
await page.waitForLoadState('networkidle');

await expect(
page.getByRole('region', { name: 'Announcements' })
page.getByRole('region', { name: 'Announcement' })
).not.toBeAttached();
});

test('persists dismissal until the banner text changes', async ({ page }) => {
let text = 'Dismiss this announcement';

await page.route(REMOTE_CONFIG_URL, route =>
route.fulfill({
contentType: 'application/json',
body: JSON.stringify({
websiteBanners: { index: { text } },
}),
})
);

await page.goto('/assert.html');

const banner = page.getByRole('region', { name: 'Announcement' });
await banner.getByRole('button', { name: 'Close banner' }).click();
await expect(banner).not.toBeAttached();
await expect
.poll(() => page.evaluate(() => localStorage.getItem('banner-dismissal')))
.toBe(text);

await page.reload();
await page.waitForLoadState('networkidle');
await expect(banner).not.toBeAttached();

text = 'A new announcement';
await page.reload();
await expect(banner).toContainText(text);
});
});
33 changes: 14 additions & 19 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@heroicons/react": "^2.2.0",
"@minify-html/wasm": "^0.18.1",
"@node-core/rehype-shiki": "^1.4.2",
"@node-core/ui-components": "^1.7.0",
"@node-core/ui-components": "^1.7.2",
"@orama/orama": "^3.1.18",
"@orama/ui": "^1.5.4",
"@rollup/plugin-virtual": "^3.0.2",
Expand Down

This file was deleted.

Loading
Loading