Repository navigation
Conversation
- getCommits/getProjectData: the hardened controllers return "repoName query parameter is required" and a fixed 500 message instead of the raw error, and getProjectData returns the encoded project string. - createRepo: has_projects (the tests still had the old hash_projects typo). - createMetaData: include the fields added for the SQLite migration and the 'default' theme fallback; restore mocks after each test so a failure can't leave Date mocked for the next one. - createProject: rewritten against the current controller (sanitised repo names, timestamp default, projectName/creatorName, thumbnail, the SQLite row), with db mocked. - Point SQLITE_PATH at :memory: in the test setup; db.ts otherwise creates projects.sqlite outside the repo on every run. - Add a workflow that runs npm test on pull requests and pushes to main.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
npm testonmainfails 17 of 129 tests, and two suites (createProject,getProjectData) don't compile. Nothing runs the tests in CI, so they drifted after the API hardening in #24 and #25. This PR brings them back in line with the current behaviour and adds a workflow so it stays that way.Test updates (no
src/changes):getCommits/getProjectData: the controllers now answer400 { message: "repoName query parameter is required" }and a fixed500message instead of the raw error object.getProjectDatareturns the encoded project string (Promise<string>), so the mocks now resolve that string.createRepo: the request useshas_projects. The tests still expected the oldhash_projectstypo.createMetaData: includesprojectName,updatedAt,originalCreator,isMigratedandisMusicBlocks, plus the'default'theme fallback, with one new test for the name/creator arguments. Mocks are restored in anafterEach, because a failing assertion skipped the inlinerestoreAllMocks()and leftDatemocked for the next test.createProject: rewritten against the current controller. It covers:-, not_) and the timestamp default,projectName/creatorName,dbis mocked there. 15 tests.Test hygiene:
src/utils/db.tsopensSQLITE_PATH, which defaults to../../../projects.sqlite, as soon as it's imported. So every test run created a realprojects.sqlitenext to the repo.tests/setup.tsnow setsSQLITE_PATH=':memory:'first.CI: a new
.github/workflows/test.ymlrunsnpm ci && npm teston pull requests and pushes tomain, with Node 20 like the Dockerfile.Result: 9/9 suites, 167/167 tests pass.
npm run test:type-checkandeslint testsreport the same 13 / 6 pre-existing errors asmain, so I left them out of this PR.