From 9a996c2a82d9ec2ab2f02b6e4f0a969e5efaa4d9 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Mon, 11 Dec 2023 10:31:21 -0500 Subject: [PATCH] test: address tests --- tests/resources/projects.spec.js | 17 ++++++++++++++--- tests/resources/units.spec.js | 27 ++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/tests/resources/projects.spec.js b/tests/resources/projects.spec.js index bcb87e76..ee26a3ee 100644 --- a/tests/resources/projects.spec.js +++ b/tests/resources/projects.spec.js @@ -43,7 +43,9 @@ describe('Project Resource CRUD', function () { describe('error states', function () { it('errors if there if there is no connection to the datalayer', async function () { sinon.stub(datalayer, 'dataLayerAvailable').resolves(false); - const response = await supertest(app).get('/v1/projects'); + const response = await supertest(app) + .get('/v1/projects') + .query({ page: 1, limit: 100 }); expect(response.statusCode).to.equal(400); expect(response.body.error).to.equal( @@ -55,7 +57,10 @@ describe('Project Resource CRUD', function () { describe('success states', function () { it('gets all the projects available', async function () { // no query params - const projects = await testFixtures.getProjectByQuery(); + const projects = await testFixtures.getProjectByQuery({ + page: 1, + limit: 100, + }); expect(projects.length).to.equal(12); }).timeout(TEST_WAIT_TIME * 10); @@ -63,6 +68,8 @@ describe('Project Resource CRUD', function () { // ?orgUid=XXXX const projects = await testFixtures.getProjectByQuery({ orgUid: 'a807e453-6524-49df-a32d-785e56cf560e', + page: 1, + limit: 100, }); expect(projects.length).to.equal(3); }).timeout(TEST_WAIT_TIME * 10); @@ -71,6 +78,8 @@ describe('Project Resource CRUD', function () { // ?search=XXXX const projects = await testFixtures.getProjectByQuery({ search: 'City of Arcata', + page: 1, + limit: 100, }); expect(projects.length).to.equal(1); }).timeout(TEST_WAIT_TIME * 10); @@ -80,6 +89,8 @@ describe('Project Resource CRUD', function () { const projects = await testFixtures.getProjectByQuery({ orgUid: 'a807e453-6524-49df-a32d-785e56cf560e', search: 'City of Arcata', + page: 1, + limit: 100, }); expect(projects.length).to.equal(1); @@ -222,7 +233,7 @@ describe('Project Resource CRUD', function () { describe('error states', function () { it('errors if no home organization exists', async function () { const responseCreate = await supertest(app) - .get('/v1/projects') + .post('/v1/projects') .send({ ...newProject, }); diff --git a/tests/resources/units.spec.js b/tests/resources/units.spec.js index 0f677335..83e88b6b 100644 --- a/tests/resources/units.spec.js +++ b/tests/resources/units.spec.js @@ -31,7 +31,9 @@ describe('Units Resource CRUD', function () { await testFixtures.createNewUnit(); await testFixtures.commitStagingRecords(); await testFixtures.waitForDataLayerSync(); - const result = await supertest(app).get('/v1/units'); + const result = await supertest(app) + .get('/v1/units') + .query({ page: 1, limit: 100 }); response = result.body[0]; }); @@ -44,7 +46,9 @@ describe('Units Resource CRUD', function () { it('gets all the units available', async function () { // no query params - const result = await supertest(app).get('/v1/units').query({}); + const result = await supertest(app) + .get('/v1/units') + .query({ page: 1, limit: 100 }); expect(result.body.length).to.not.equal(0); }).timeout(TEST_WAIT_TIME * 10); @@ -52,7 +56,7 @@ describe('Units Resource CRUD', function () { it('gets all the units filtered by orgUid', async function () { const result = await supertest(app) .get('/v1/units') - .query({ orgUid: response.orgUid }); + .query({ orgUid: response.orgUid, page: 1, limit: 100 }); expect(result.body.length).to.not.equal(1); // ?orgUid=XXXX @@ -73,7 +77,7 @@ describe('Units Resource CRUD', function () { const result = await supertest(app) .get('/v1/units') - .query({ order: 'SERIALNUMBER' }); + .query({ order: 'SERIALNUMBER', page: 1, limit: 100 }); expect(result.body[0].serialNumberBlock).to.equal('AAAAA1-AAAAA2'); expect(result.body[1].serialNumberBlock).to.equal('AAAAA11-AAAAA21'); @@ -86,7 +90,7 @@ describe('Units Resource CRUD', function () { // ?search=XXXX const result = await supertest(app) .get('/v1/units') - .query({ search: 'Certification' }); + .query({ search: 'Certification', page: 1, limit: 100 }); expect(result.body.length).to.not.equal(1); }).timeout(TEST_WAIT_TIME * 10); @@ -94,7 +98,12 @@ describe('Units Resource CRUD', function () { // ?orgUid=XXXX&search=XXXX const result = await supertest(app) .get('/v1/units') - .query({ orgUid: response.orgUid, search: 'Certification' }); + .query({ + orgUid: response.orgUid, + search: 'Certification', + page: 1, + limit: 100, + }); expect(result.body.length).to.not.equal(1); }).timeout(TEST_WAIT_TIME * 10); @@ -110,7 +119,11 @@ describe('Units Resource CRUD', function () { // ?warehouseUnitId=XXXX const result = await supertest(app) .get('/v1/units') - .query({ warehouseUnitId: response.warehouseUnitId, limit: 1 }); + .query({ + warehouseUnitId: response.warehouseUnitId, + page: 1, + limit: 100, + }); expect(result.body.length).to.not.equal(1); }).timeout(TEST_WAIT_TIME * 10);