Skip to content

Commit

Permalink
Don't run devtools test in regular mode
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Cassidy <[email protected]>
  • Loading branch information
stevecassidy committed Aug 25, 2023
1 parent 5d620e2 commit 6ead4dd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
31 changes: 17 additions & 14 deletions test/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {getSigningKey} from '../src/authkeys/signing_keys';
import fs from 'fs';
import {createNotebook} from '../src/couchdb/notebooks';
import {ProjectUIModel} from 'faims3-datamodel';
import {DEVELOPER_MODE} from '../src/buildconfig';

const uispec: ProjectUIModel = {
fields: [],
Expand Down Expand Up @@ -174,17 +175,19 @@ test('update notebook roles', async () => {
}
});

test('create random record', async () => {
const nb1 = await createNotebook('NB1', uispec, {});

if (nb1) {
return request(app)
.post(`/api/notebooks/${nb1}/generate`)
.set('Authorization', `Bearer ${adminToken}`)
.set('Content-Type', 'application/json')
.send({count: 10})
.expect(200);
} else {
throw new Error('could not make test notebook');
}
});
if (DEVELOPER_MODE) {
test('create random record', async () => {
const nb1 = await createNotebook('NB1', uispec, {});

if (nb1) {
return request(app)
.post(`/api/notebooks/${nb1}/generate`)
.set('Authorization', `Bearer ${adminToken}`)
.set('Content-Type', 'application/json')
.send({count: 10})
.expect(200);
} else {
throw new Error('could not make test notebook');
}
});
}
26 changes: 16 additions & 10 deletions test/devtools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {createNotebook} from '../src/couchdb/notebooks';
import * as fs from 'fs';
import {createRandomRecord} from '../src/couchdb/devtools';
import {registerClient} from 'faims3-datamodel';
import {DEVELOPER_MODE} from '../src/buildconfig';

// set up the database module faims3-datamodel with our callbacks to get databases
registerClient({
Expand All @@ -38,17 +39,22 @@ registerClient({
shouldDisplayRecord: () => true,
});

test('createRecords', async () => {
await initialiseDatabases();
if (DEVELOPER_MODE) {
test('createRecords', async () => {
await initialiseDatabases();

const jsonText = fs.readFileSync('./notebooks/sample_notebook.json', 'utf-8');
const {metadata, 'ui-specification': uiSpec} = JSON.parse(jsonText);
const jsonText = fs.readFileSync(
'./notebooks/sample_notebook.json',
'utf-8'
);
const {metadata, 'ui-specification': uiSpec} = JSON.parse(jsonText);

const projectID = await createNotebook('Test Notebook', uiSpec, metadata);
const projectID = await createNotebook('Test Notebook', uiSpec, metadata);

expect(projectID).not.toBe(undefined);
expect(projectID).not.toBe(undefined);

if (projectID) {
await createRandomRecord(projectID);
}
});
if (projectID) {
await createRandomRecord(projectID);
}
});
}

0 comments on commit 6ead4dd

Please sign in to comment.