|
1 | 1 | import { describe, test, expect } from 'bun:test' |
2 | 2 | import { renderToHtml } from '../../src/build/render' |
3 | 3 | import { Home } from '../../src/pages/home' |
4 | | -import { fixtureCatalog } from '../fixtures/catalog' |
| 4 | +import type { FeaturedLab } from '../../src/build/featured' |
5 | 5 |
|
6 | | -const config = { basePath: '/', buildTime: '2026-04-27T12:00:00Z' } |
7 | | -const heroContent = { |
8 | | - hero: 'Public infrastructure, in the open.', |
9 | | - intro: 'Flexion Labs gathers our open source work in one place.', |
| 6 | +const config = { basePath: '/', buildTime: '2026-05-01T12:00:00Z' } |
| 7 | + |
| 8 | +const hero = { |
| 9 | + title: 'Flexion Labs', |
| 10 | + subtitle: 'Solutions for the public, in the open', |
| 11 | + intro: '<p>Flexion is committed to <a href="https://flexion.us/contact-us/">reach out to us</a> excellence.</p>', |
| 12 | + learnMore: { |
| 13 | + commitment: 'Flexion is open by default.', |
| 14 | + about: 'We help organizations stay future-ready.', |
| 15 | + }, |
10 | 16 | } |
11 | 17 |
|
| 18 | +const featured: FeaturedLab[] = [ |
| 19 | + { |
| 20 | + title: 'Forms Lab', |
| 21 | + tagline: 'Digitize forms to create modern, accessible experiences for public outreach.', |
| 22 | + order: 1, |
| 23 | + links: [ |
| 24 | + { label: 'Demo (Forms Platform)', url: 'https://pp4cc7kwbf.us-east-1.awsapprunner.com/' }, |
| 25 | + { label: 'GitHub repository — Forms Platform', url: 'https://github.com/flexion/forms' }, |
| 26 | + ], |
| 27 | + }, |
| 28 | + { |
| 29 | + title: 'Messaging Lab', |
| 30 | + tagline: 'Text messaging services to deliver critical updates to the people you serve.', |
| 31 | + order: 2, |
| 32 | + links: [ |
| 33 | + { label: 'GitHub repository', url: 'https://github.com/flexion/flexion-notify' }, |
| 34 | + ], |
| 35 | + }, |
| 36 | + { |
| 37 | + title: 'Document Extractor Lab', |
| 38 | + tagline: 'Accurately extract data from PDFs and images for faster application processing.', |
| 39 | + order: 3, |
| 40 | + links: [ |
| 41 | + { label: 'GitHub repository', url: 'https://github.com/flexion/document-extractor' }, |
| 42 | + ], |
| 43 | + }, |
| 44 | +] |
| 45 | + |
12 | 46 | describe('Home', () => { |
13 | | - test('renders the hero statement as the h1', async () => { |
14 | | - const html = await renderToHtml( |
15 | | - <Home catalog={fixtureCatalog} hero={heroContent} config={config} />, |
16 | | - ) |
17 | | - expect(html).toMatch(/<h1[^>]*>Public infrastructure, in the open\.<\/h1>/) |
| 47 | + test('renders the site title as the h1', async () => { |
| 48 | + const html = await renderToHtml(<Home hero={hero} featured={featured} config={config} />) |
| 49 | + expect(html).toMatch(/<h1[^>]*>Flexion Labs<\/h1>/) |
| 50 | + }) |
| 51 | + |
| 52 | + test('renders the subtitle', async () => { |
| 53 | + const html = await renderToHtml(<Home hero={hero} featured={featured} config={config} />) |
| 54 | + expect(html).toContain('Solutions for the public, in the open') |
18 | 55 | }) |
19 | 56 |
|
20 | | - test('renders one card per featured entry', async () => { |
21 | | - const html = await renderToHtml( |
22 | | - <Home catalog={fixtureCatalog} hero={heroContent} config={config} />, |
23 | | - ) |
24 | | - expect(html).toContain('messaging') |
25 | | - expect(html).toContain('forms') |
26 | | - expect(html).toContain('document-extractor') |
27 | | - expect(html).not.toContain('old-prototype') |
| 57 | + test('renders the intro markdown as HTML including the reach-out link', async () => { |
| 58 | + const html = await renderToHtml(<Home hero={hero} featured={featured} config={config} />) |
| 59 | + expect(html).toContain('href="https://flexion.us/contact-us/"') |
28 | 60 | }) |
29 | 61 |
|
30 | | - test('renders quick stats reflecting the catalog', async () => { |
31 | | - const html = await renderToHtml( |
32 | | - <Home catalog={fixtureCatalog} hero={heroContent} config={config} />, |
33 | | - ) |
34 | | - // 7 total repos in the fixture; 3 active. |
35 | | - expect(html).toMatch(/7<\/strong>\s*public projects/) |
36 | | - expect(html).toMatch(/3<\/strong>\s*actively maintained/) |
| 62 | + test('renders one LabCard per featured lab in order', async () => { |
| 63 | + const html = await renderToHtml(<Home hero={hero} featured={featured} config={config} />) |
| 64 | + const indexOf = (s: string) => html.indexOf(s) |
| 65 | + expect(indexOf('Forms Lab')).toBeGreaterThan(-1) |
| 66 | + expect(indexOf('Messaging Lab')).toBeGreaterThan(-1) |
| 67 | + expect(indexOf('Document Extractor Lab')).toBeGreaterThan(-1) |
| 68 | + expect(indexOf('Forms Lab')).toBeLessThan(indexOf('Messaging Lab')) |
| 69 | + expect(indexOf('Messaging Lab')).toBeLessThan(indexOf('Document Extractor Lab')) |
37 | 70 | }) |
38 | 71 |
|
39 | | - test('renders the three audience paths', async () => { |
40 | | - const html = await renderToHtml( |
41 | | - <Home catalog={fixtureCatalog} hero={heroContent} config={config} />, |
42 | | - ) |
43 | | - expect(html).toContain('href="/work/"') |
| 72 | + test('renders each labs links inside its card', async () => { |
| 73 | + const html = await renderToHtml(<Home hero={hero} featured={featured} config={config} />) |
| 74 | + expect(html).toContain('href="https://github.com/flexion/forms"') |
| 75 | + expect(html).toContain('href="https://github.com/flexion/flexion-notify"') |
| 76 | + expect(html).toContain('href="https://github.com/flexion/document-extractor"') |
| 77 | + }) |
| 78 | + |
| 79 | + test('renders the Learn more section with commitment and about teasers', async () => { |
| 80 | + const html = await renderToHtml(<Home hero={hero} featured={featured} config={config} />) |
| 81 | + expect(html).toContain('Learn more') |
| 82 | + expect(html).toContain('Our open source commitment') |
| 83 | + expect(html).toContain('About Flexion') |
44 | 84 | expect(html).toContain('href="/commitment/"') |
45 | 85 | expect(html).toContain('href="/about/"') |
46 | 86 | }) |
| 87 | + |
| 88 | + test('does not render the stats strip', async () => { |
| 89 | + const html = await renderToHtml(<Home hero={hero} featured={featured} config={config} />) |
| 90 | + expect(html).not.toContain('home-stats') |
| 91 | + expect(html).not.toContain('public projects') |
| 92 | + }) |
47 | 93 | }) |
0 commit comments