Skip to content

Fix/api urls - #996

Open
martimpassos wants to merge 4 commits into
mainfrom
fix/api-urls
Open

martimpassos wants to merge 4 commits into
mainfrom
fix/api-urls

Conversation

@martimpassos

Copy link
Copy Markdown
Collaborator

Fixes a bug where API routes wouldn't match the encoded project id and adds minimal API tests.

Comment thread test/common/api.test.js
it('returns the payload and the requested id', async () => {
let action

rsvp = async (a) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use t.mock for mocks/spies instead

Comment thread test/common/api.test.js
expect(await res.json()).to.eql({
project: '/tmp/current.tpy',
status: 'ok',
version: '1.0.0'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to use context.version as the expected value

Comment thread test/common/api.test.js
dispatch: () => {},
log: { debug () {}, error () {} },
resolveProject: (id) => resolveProject(id),
rsvp: (win, action) => rsvp(action),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best use proper mocks/spies here instead of defining rsvp, resolveProject twice

@inukshuk inukshuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! But let's use node-test mocks instead of rolling our own. You can either import from node:test or use the test/suite contexts (first argument passed to test/it)

@inukshuk

inukshuk commented Sep 4, 2026

Copy link
Copy Markdown
Member

Also it will be good to rebase this on main, because I pushed some changes to unify some of the actions (e.g. note creation used separate commands and the one used by the API was already outdated).

It would be great to add a chain of tests (each one building on the next) like: starting with an empty project (incidentally, create a new project is probably an API call we're missing that could be useful?) import item/photo, add a tag, add a note, add a transcription, extract the photo. With the API using some of the internal commands now this actually makes the API a useful tool for integration testing stuff on a real project.

@inukshuk inukshuk mentioned this pull request Oct 25, 2026
2 of 4 tasks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants