|
| 1 | +import { describe, it, expect, beforeEach, afterEach } from 'vitest'; |
| 2 | +import fs from 'fs'; |
| 3 | +import path from 'path'; |
| 4 | + |
| 5 | +/** |
| 6 | + * Tests for Disclaimer Banner |
| 7 | + * Verifies key elements and content of the disclaimer banner. |
| 8 | + */ |
| 9 | +describe('Disclaimer Banner Support', () => { |
| 10 | + beforeEach(() => { |
| 11 | + // Load the actual index.html content |
| 12 | + const htmlPath = path.resolve(__dirname, 'index.html'); |
| 13 | + const htmlContent = fs.readFileSync(htmlPath, 'utf-8'); |
| 14 | + document.body.innerHTML = htmlContent; |
| 15 | + }); |
| 16 | + |
| 17 | + afterEach(() => { |
| 18 | + document.body.innerHTML = ''; |
| 19 | + }); |
| 20 | + |
| 21 | + it('should display the banner', () => { |
| 22 | + const banner = document.getElementById('disclaimer-banner'); |
| 23 | + expect(banner).not.toBeNull(); |
| 24 | + expect(banner?.getAttribute('role')).toBe('banner'); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should contain the correct disclaimer text', () => { |
| 28 | + const textWrapper = document.querySelector('.disclaimer-banner__text-wrapper'); |
| 29 | + expect(textWrapper).not.toBeNull(); |
| 30 | + expect(textWrapper?.textContent).toContain('This is not official government information'); |
| 31 | + expect(textWrapper?.textContent).toContain('Prototype by Ad Hoc'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should have a link to the About page', () => { |
| 35 | + const aboutLink = document.querySelector('.disclaimer-banner__links a[href="/about.html"]'); |
| 36 | + expect(aboutLink).not.toBeNull(); |
| 37 | + }); |
| 38 | + |
| 39 | + it('should have a link to the official copyright.gov site', () => { |
| 40 | + const officialLink = document.querySelector('.disclaimer-banner__textWrapper a[href="https://www.copyright.gov/comp3/"]'); |
| 41 | + // The class might be slightly different in structure, check specific anchor |
| 42 | + const links = Array.from(document.querySelectorAll('#disclaimer-banner a')); |
| 43 | + const hasOfficialLink = links.some(link => link.getAttribute('href') === 'https://www.copyright.gov/comp3/'); |
| 44 | + expect(hasOfficialLink).toBe(true); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should have the Ad Hoc logo', () => { |
| 48 | + const logo = document.querySelector('.disclaimer-banner__logo img'); |
| 49 | + expect(logo).not.toBeNull(); |
| 50 | + expect(logo?.getAttribute('alt')).toBe('Ad Hoc'); |
| 51 | + }); |
| 52 | +}); |
0 commit comments