fix: tests

This commit is contained in:
2023-05-31 15:05:41 +02:00
parent 0d60b8bfad
commit 68400f2480
29 changed files with 647 additions and 272 deletions

View File

@@ -24,10 +24,11 @@ import {expect} from 'chai';
import {bulk, DEFAULT_TEST_TIMEOUT} from '../common.js';
import {testApp} from '../tests-setup.js';
import {readFile} from 'fs/promises';
import {v4} from 'uuid';
const book = JSON.parse(
await readFile('node_modules/@openstapps/core/test/resources/indexable/Book.1.json', 'utf8'),
);
await readFile('node_modules/@openstapps/core/test/resources/indexable/Book.2.json', 'utf8'),
).instance;
describe('Bulk routes', async function () {
// increase timeout for the suite
@@ -60,7 +61,7 @@ describe('Bulk routes', async function () {
it('should return (throw) error if a bulk with the provided UID cannot be found when adding to a bulk', async function () {
await testApp.post(bulkRoute.urlPath).set('Content-Type', 'application/json').send(request);
const bulkAddRouteUrlPath = bulkAddRoute.urlPath.toLocaleLowerCase().replace(':uid', 'a-wrong-uid');
const bulkAddRouteUrlPath = bulkAddRoute.urlPath.toLocaleLowerCase().replace(':uid', v4());
const {status} = await testApp
.post(bulkAddRouteUrlPath)
@@ -75,10 +76,10 @@ describe('Bulk routes', async function () {
.post(bulkRoute.urlPath)
.set('Content-Type', 'application/json')
.send(request);
const bulkAddRouteurlPath = bulkAddRoute.urlPath.toLocaleLowerCase().replace(':uid', response.body.uid);
const bulkAddRouteUrlPath = bulkAddRoute.urlPath.toLocaleLowerCase().replace(':uid', response.body.uid);
const {status, body} = await testApp
.post(bulkAddRouteurlPath)
.post(bulkAddRouteUrlPath)
.set('Content-Type', 'application/json')
.send(book);
@@ -88,10 +89,10 @@ describe('Bulk routes', async function () {
it('should return (throw) error if a bulk with the provided UID cannot be found when closing a bulk (done)', async function () {
await testApp.post(bulkRoute.urlPath).set('Content-Type', 'application/json').send(request);
const bulkDoneRouteurlPath = bulkDoneRoute.urlPath.toLocaleLowerCase().replace(':uid', 'a-wrong-uid');
const bulkDoneRouteUrlPath = bulkDoneRoute.urlPath.toLocaleLowerCase().replace(':uid', 'a-wrong-uid');
const {status} = await testApp
.post(bulkDoneRouteurlPath)
.post(bulkDoneRouteUrlPath)
.set('Content-Type', 'application/json')
.send({});

View File

@@ -24,7 +24,7 @@ use(chaiAsPromised);
const book = JSON.parse(
await readFile('node_modules/@openstapps/core/test/resources/indexable/Book.1.json', 'utf8'),
);
).instance;
describe('Thing update route', async function () {
// increase timeout for the suite