Repository navigation
Hide the I/O Puzzle 2025 project from project listings #3
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** | ||
| * Tests for the search indexing script's project URLs | ||
| */ | ||
|
|
||
| import { describe, it, expect } from 'vitest'; | ||
| import { createRequire } from 'module'; | ||
| import { readFileSync } from 'fs'; | ||
|
|
||
| const require = createRequire(import.meta.url); | ||
| const { projectUrls } = require('../scripts/index-all-content.js'); | ||
|
|
||
| describe('index-all-content projectUrls', () => { | ||
| it('maps visible projects to their project URLs and skips hidden ones', () => { | ||
| const projects = [ | ||
| { id: 'shown' }, | ||
| { id: 'gone', hidden: true }, | ||
| { id: 'also-shown', hidden: false }, | ||
| ]; | ||
|
|
||
| expect(projectUrls(projects)).toEqual([ | ||
| 'https://helloemily.dev/projects/shown/', | ||
| 'https://helloemily.dev/projects/also-shown/', | ||
| ]); | ||
| }); | ||
|
|
||
| it('does not submit the hidden io-puzzle-2025 project from projects-data.json', () => { | ||
| const { projects } = JSON.parse(readFileSync('projects/projects-data.json', 'utf8')); | ||
|
|
||
| expect(projectUrls(projects)).not.toContain('https://helloemily.dev/projects/io-puzzle-2025/'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /** | ||
| * Tests for the project loader's display preparation | ||
| */ | ||
|
|
||
| import { describe, it, expect } from 'vitest'; | ||
| import { readFileSync } from 'fs'; | ||
| import { prepareProjects } from '../js/project-loader.js'; | ||
|
|
||
| const project = (id, overrides = {}) => ({ | ||
| id, | ||
| featured: false, | ||
| completionDate: '2025-01', | ||
| ...overrides, | ||
| }); | ||
|
|
||
| describe('Project Loader', () => { | ||
| describe('prepareProjects', () => { | ||
| it('omits hidden projects on the projects page', () => { | ||
| const projects = [ | ||
| project('shown-a', { completionDate: '2025-03' }), | ||
| project('hidden', { hidden: true, featured: true }), | ||
| project('shown-b', { completionDate: '2025-01' }), | ||
| ]; | ||
|
|
||
| const ids = prepareProjects(projects, '/pages/projects.html').map((p) => p.id); | ||
|
|
||
| expect(ids).toEqual(['shown-a', 'shown-b']); | ||
| }); | ||
|
|
||
| it('fills all three home page slots from visible projects when one is hidden', () => { | ||
| const projects = [ | ||
| project('hidden', { hidden: true, featured: true, completionDate: '2025-06' }), | ||
| project('p1', { completionDate: '2025-05' }), | ||
| project('p2', { completionDate: '2025-04' }), | ||
| project('p3', { completionDate: '2025-03' }), | ||
| project('p4', { completionDate: '2025-02' }), | ||
| ]; | ||
|
|
||
| const ids = prepareProjects(projects, '/').map((p) => p.id); | ||
|
|
||
| expect(ids).toEqual(['p1', 'p2', 'p3']); | ||
| }); | ||
|
|
||
| it('keeps projects with hidden set to false or absent', () => { | ||
| const projects = [ | ||
| project('explicit', { hidden: false, completionDate: '2025-02' }), | ||
| project('absent', { completionDate: '2025-01' }), | ||
| ]; | ||
|
|
||
| const ids = prepareProjects(projects, '/pages/projects.html').map((p) => p.id); | ||
|
|
||
| expect(ids).toEqual(['explicit', 'absent']); | ||
| }); | ||
| }); | ||
|
|
||
| describe('projects-data.json', () => { | ||
| const { projects } = JSON.parse(readFileSync('projects/projects-data.json', 'utf8')); | ||
|
|
||
| it('does not display any project linking to emilysueanderson.com', () => { | ||
| const displayed = prepareProjects(projects, '/pages/projects.html'); | ||
|
|
||
| const offending = displayed.filter((p) => /emilysueanderson\.com/i.test(JSON.stringify(p))); | ||
|
|
||
| expect(offending.map((p) => p.id)).toEqual([]); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.