Skip to content

Add tests - #4

Open
david-mears-2 wants to merge 15 commits into
poc-no-testsfrom
poc-with-tests
Open

Add tests#4
david-mears-2 wants to merge 15 commits into
poc-no-testsfrom
poc-with-tests

Conversation

@david-mears-2

@david-mears-2 david-mears-2 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Unit and integration tests. The majority of the apparent 5000-line diff is from fixtures and package-lock.json.

To avoid making tests dependent on potentially changing data, the integration tests use small fixtures (relatively small compared to real data). These are generated by a script, which is configured by tests/fixtures/fixture-config.json.

Calls to DuckDB are mocked in unit tests.

@david-mears-2
david-mears-2 force-pushed the poc-with-tests branch 2 times, most recently from 046932e to 2abc152 Compare September 3, 2026 15:33

@EmmaLRussell EmmaLRussell left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, just a couple of tiny queries to take or leave.

How were the test data files created? Could you include instructions in the README in case these need to be changed?
UPDATE: I just found the generate-test-fixtures script! So maybe mention that in the README..

Could add coverage?

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +37 to +38
- uses: actions/checkout@v5
- uses: actions/setup-node@v5

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No big deal, but there are newer versions of these actions.

Comment on lines +19 to +22
bounds: {
min: { lng: -70.0635, lat: 12.4124 },
max: { lng: -69.8654, lat: 12.624 },
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I guess you haven't had any floating point comparison issues with this test yet - might be an issue later with real bounds calculation..?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added expect.closeTo

.get('/metadata')
.query({ model_release: '../private' });

expect(response.status).toBe(400);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I wonder if this should be a 404 rather than 400? Request is well formed , but the data doesn't exist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed message to 'Unknown' instead of 'Invalid', and 400 to 404

});

expect(response.status).toBe(200);
// Expect all admin1 values to be unique

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this just a misleading comment? Looks like it's checking admin0 not admin1?

// Expect all admin1 values to be unique
const uniqueAdmin0 = new Set(response.body.admin0);
expect(uniqueAdmin0.size).toBe(2);
expect(response.body.admin0).toEqual(['ETH', 'MLI']);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not really sure you need to do the unique check if you're then going to test the exact values here anyway..?

expect(uniqueAdmin0.size).toBe(2);
expect(response.body.admin0).toEqual(['ETH', 'MLI']);
expect(response.body.median).toHaveLength(2);
expect(response.body.median).toEqual(expect.arrayContaining([

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there any reason not to just use toStrictEqual here? Wouldn't need length check in that case i think.? Same goes for similar tests elsewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point


expect(response.status).toBe(400);
expect(response.body.error).toBe(
'Missing required query parameters: model_release, properties, gene, mutation',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this idea with requiring all these parameters to avoid sending huge deluge of data to lazy clients? Definitely think it makes sense to require model_release, I think an empty properties could potentially imply "just give me all properties". Maybe gene is required by all mutations could be implied?
Probably not important if we turn out to be our only client!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, my original design did have 'empty list of properties implies give all properties', but the size of data made me want to force consumers to explicitly confirm that's what they want!

Comment thread tests/unit/data.test.ts Outdated
@@ -0,0 +1,226 @@
// WHERE I GOT UP TO - reviewing changes/tests as far down as this file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Obsolete comment?

@david-mears-2

Copy link
Copy Markdown
Contributor Author

How were the test data files created? Could you include instructions in the README in case these need to be changed? UPDATE: I just found the generate-test-fixtures script! So maybe mention that in the README..

Updated README

Could add coverage?

Added coverage

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