Skip to content

Commit

Permalink
more api tests
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Cassidy <[email protected]>
  • Loading branch information
stevecassidy committed Nov 2, 2023
1 parent 088bfc6 commit 445d5c6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {createNotebook, getNotebooks} from '../src/couchdb/notebooks';
import {ProjectUIModel} from 'faims3-datamodel';
import {DEVELOPER_MODE} from '../src/buildconfig';
import {expect} from 'chai';
import {resetDatabases} from './mocks';
import {resetDatabases, cleanDataDBS} from './mocks';
import {restoreFromBackup} from '../src/couchdb/backupRestore';

const uispec: ProjectUIModel = {
Expand All @@ -52,6 +52,7 @@ const username = 'bobalooba';
describe('API tests', () => {
beforeEach(async () => {
await resetDatabases();
await cleanDataDBS();
const signing_key = await getSigningKey();
const adminUser = await getUserFromEmailOrUsername('admin');
if (adminUser) {
Expand Down Expand Up @@ -303,6 +304,24 @@ describe('API tests', () => {
}
});

it('can download records as json', async () => {
// pull in some test data
await restoreFromBackup('test/backup.jsonl');

const adminUser = await getUserFromEmailOrUsername('admin');
if (adminUser) {
const notebooks = await getNotebooks(adminUser);
expect(notebooks).to.have.lengthOf(2);

await request(app)
.get('/api/notebooks/1693291182736-campus-survey-demo/records/')
.set('Authorization', `Bearer ${adminToken}`)
.set('Content-Type', 'application/json')
.expect(200)
.expect('Content-Type', 'application/json; charset=utf-8');
}
});

it('can download records as csv', async () => {
// pull in some test data
await restoreFromBackup('test/backup.jsonl');
Expand Down

0 comments on commit 445d5c6

Please sign in to comment.