-
Notifications
You must be signed in to change notification settings - Fork 0
feat(bento): Phase Ic — responsive polish and visual regression tests #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||||||||||||||||||||||||||||||||||
| import { existsSync, readFileSync } from 'fs'; | ||||||||||||||||||||||||||||||||||||||
| import { resolve } from 'path'; | ||||||||||||||||||||||||||||||||||||||
| import { describe, expect, it } from 'vitest'; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const DIST = resolve(process.cwd(), 'dist'); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| describe('bento grid structure', () => { | ||||||||||||||||||||||||||||||||||||||
| const indexPath = resolve(DIST, 'index.html'); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('dist/index.html exists', () => { | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To improve test performance, the const indexPath = resolve(DIST, 'index.html');
const html = readFileSync(indexPath, 'utf8');
it('dist/index.html exists', () => { |
||||||||||||||||||||||||||||||||||||||
| expect(existsSync(indexPath)).toBe(true); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('has bento-grid section', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading the it('has bento-grid section', () => {
expect(html).toContain('class="bento-grid"'); |
||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('class="bento-grid"'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('aria-label="Portfolio overview"'); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('has hero cell with name and stat pills', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('bento-cell--hero'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('Anthony James Padavano'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('stat-pill'); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('has 2 featured project cards with transition:name', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
| const featured = html.match(/bento-card--featured/g); | ||||||||||||||||||||||||||||||||||||||
| expect(featured?.length).toBe(2); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('data-astro-transition-scope'); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Tighten featured cards assertion to ensure the transition scope is applied specifically to featured cards This test only checks that
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('has controls cell with view toggle and depth control', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('controls-cell'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('bento-view-toggle'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('data-shibui-control'); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('has persona cell with 4 persona links', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('persona-cell'); | ||||||||||||||||||||||||||||||||||||||
| const personaLinks = html.match(/persona-cell__link/g); | ||||||||||||||||||||||||||||||||||||||
| expect(personaLinks?.length).toBeGreaterThanOrEqual(4); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+41
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (testing): Clarify whether exactly 4 personas are expected and assert accordingly The test name implies exactly 4 persona links, but the assertion uses |
||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('has CTA cell', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('cta-cell'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('Start a conversation'); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('has see-all projects link', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('bento-card--see-all'); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('does NOT have old ProjectGrid or home-pair', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).not.toContain('project-grid'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).not.toContain('home-pair'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).not.toContain('organ-group__toggle'); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('has dual-view data attributes', () => { | ||||||||||||||||||||||||||||||||||||||
| const html = readFileSync(indexPath, 'utf8'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('data-hero-view="engineering"'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('data-hero-view="creative"'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('data-stats-view="engineering"'); | ||||||||||||||||||||||||||||||||||||||
| expect(html).toContain('data-stats-view="creative"'); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+66
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (testing): Add a test to assert that bento cells do not use The PR description specifies “No |
||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Reuse the built HTML instead of reading index.html from disk in every test
Each test re-reads
dist/index.html, adding unnecessary I/O and duplication. Consider loading it once in abeforeAll(e.g., into a sharedlet html: string) and reusing it across tests to keep them focused on structure and simplify future changes (like switching entry files).Suggested implementation:
Anywhere later in this file that calls
readFileSync(indexPath, ...)or otherwise re-readsdist/index.htmlshould be updated to use the sharedhtmlvariable instead. For example, replaceconst html = readFileSync(indexPath, 'utf-8');with uses of the top-levelhtmldefined in thedescribeblock (e.g., directly passinghtmlinto the DOM parser or string matchers).