fix: example.env merge conflict

This commit is contained in:
Stevan Freeborn
2023-02-19 13:00:31 -06:00
9 changed files with 258 additions and 9 deletions
@@ -0,0 +1,5 @@
import { OnspringClient } from './../../src';
import { expect } from 'chai';
import { baseURL, apiKey } from '../mochaRootHooks';
describe('deleteRecordById', function () {});
@@ -0,0 +1,5 @@
import { OnspringClient } from './../../src';
import { expect } from 'chai';
import { baseURL, apiKey } from '../mochaRootHooks';
describe('getRecordById', function () {});
@@ -0,0 +1,5 @@
import { OnspringClient } from './../../src';
import { expect } from 'chai';
import { baseURL, apiKey } from '../mochaRootHooks';
describe('getRecordsByAppId', function () {});
@@ -0,0 +1,5 @@
import { OnspringClient } from './../../src';
import { expect } from 'chai';
import { baseURL, apiKey } from '../mochaRootHooks';
describe('getRecordsByIds', function () {});
@@ -0,0 +1,5 @@
import { OnspringClient } from './../../src';
import { expect } from 'chai';
import { baseURL, apiKey } from '../mochaRootHooks';
describe('queryRecords', function () {});
@@ -0,0 +1,5 @@
import { OnspringClient } from './../../src';
import { expect } from 'chai';
import { baseURL, apiKey } from '../mochaRootHooks';
describe('saveRecord', function () {});
+138 -8
View File
@@ -1,4 +1,4 @@
import { OnspringClient } from './../../src'; import { DataFormat, OnspringClient, ReportDataType } from './../../src';
import { expect } from 'chai'; import { expect } from 'chai';
import { baseURL, apiKey } from '../mochaRootHooks'; import { baseURL, apiKey } from '../mochaRootHooks';
@@ -6,17 +6,147 @@ describe('getReportById', function () {
this.timeout(30000); this.timeout(30000);
this.retries(3); this.retries(3);
it('should return a report', async function () {}); it('should return a report', async function () {
const client = new OnspringClient(baseURL, apiKey);
it('should return report data for a report with chart data when report data is requested', async function () {}); if (process.env.TEST_REPORT === undefined) {
expect.fail('TEST_REPORT is not defined');
}
it('should return chart data for a report with a chart when chart data is requested', async function () {}); const response = await client.getReportById(
parseInt(process.env.TEST_REPORT)
);
it('should return a 400 error if chart data is requested for a report without chart data', async function () {}); expect(response.statusCode).to.equal(200);
expect(response.isSuccessful).to.be.true;
expect(response.message).to.equal('');
expect(response.data).to.not.be.null;
it('should return a 401 error if the api key is invalid', async function () {}); if (response.data != null) {
expect(response.data.columns).to.not.be.null;
expect(response.data.columns).to.be.an('array');
expect(response.data.rows).to.not.be.null;
expect(response.data.rows).to.be.an('array');
it('should return a 403 error if the api key does not have access to the report', async function () {}); response.data.rows.forEach((row) => {
expect(row).to.not.be.null;
expect(row.recordId).to.not.be.null;
expect(row.cells).to.not.be.null;
expect(row.cells).to.be.an('array');
});
}
});
it('should return a 404 error if the report does not exist', async function () {}); it('should return report data for a report with chart data when report data is requested', async function () {
const client = new OnspringClient(baseURL, apiKey);
if (process.env.TEST_REPORT_WITH_CHART_DATA === undefined) {
expect.fail('TEST_REPORT_WITH_CHART_DATA is not defined');
}
const response = await client.getReportById(
parseInt(process.env.TEST_REPORT_WITH_CHART_DATA)
);
expect(response.statusCode).to.equal(200);
expect(response.isSuccessful).to.be.true;
expect(response.message).to.equal('');
expect(response.data).to.not.be.null;
if (response.data != null) {
expect(response.data.columns).to.not.be.null;
expect(response.data.columns).to.be.an('array');
expect(response.data.rows).to.not.be.null;
expect(response.data.rows).to.be.an('array');
response.data.rows.forEach((row) => {
expect(row).to.not.be.null;
expect(row.recordId).to.not.be.null;
expect(row.cells).to.not.be.null;
expect(row.cells).to.be.an('array');
});
}
});
it('should return chart data for a report with a chart when chart data is requested', async function () {
const client = new OnspringClient(baseURL, apiKey);
if (process.env.TEST_REPORT_WITH_CHART_DATA === undefined) {
expect.fail('TEST_REPORT_WITH_CHART_DATA is not defined');
}
const response = await client.getReportById(
parseInt(process.env.TEST_REPORT_WITH_CHART_DATA),
DataFormat.Raw,
ReportDataType.ChartData
);
expect(response.statusCode).to.equal(200);
expect(response.isSuccessful).to.be.true;
expect(response.message).to.equal('');
expect(response.data).to.not.be.null;
if (response.data != null) {
expect(response.data.columns).to.not.be.null;
expect(response.data.columns).to.be.an('array');
expect(response.data.rows).to.not.be.null;
expect(response.data.rows).to.be.an('array');
response.data.rows.forEach((row) => {
expect(row).to.not.be.null;
expect(row.recordId).to.not.be.null;
expect(row.cells).to.not.be.null;
expect(row.cells).to.be.an('array');
});
}
});
it('should return a 400 error if chart data is requested for a report without chart data', async function () {
const client = new OnspringClient(baseURL, apiKey);
if (process.env.TEST_REPORT === undefined) {
expect.fail('TEST_REPORT is not defined');
}
const response = await client.getReportById(
parseInt(process.env.TEST_REPORT),
DataFormat.Raw,
ReportDataType.ChartData
);
expect(response.statusCode).to.equal(400);
expect(response.isSuccessful).to.be.false;
expect(response.message).to.not.be.null.and.not.be.undefined;
expect(response.data).to.be.null;
});
it('should return a 401 error if the api key is invalid', async function () {
const client = new OnspringClient(baseURL, 'invalid');
const response = await client.getReportById(1);
expect(response.statusCode).to.equal(401);
expect(response.isSuccessful).to.be.false;
expect(response.message).to.be.undefined;
expect(response.data).to.be.null;
});
it('should return a 403 error if the api key does not have access to the report', async function () {
const client = new OnspringClient(baseURL, apiKey);
const response = await client.getReportById(1);
expect(response.statusCode).to.equal(403);
expect(response.isSuccessful).to.be.false;
expect(response.message).to.not.be.null.and.not.be.undefined;
expect(response.data).to.be.null;
});
it('should return a 404 error if the report does not exist', async function () {
const client = new OnspringClient(baseURL, apiKey);
const response = await client.getReportById(0);
expect(response.statusCode).to.equal(404);
expect(response.isSuccessful).to.be.false;
expect(response.message).to.be.undefined;
expect(response.data).to.be.null;
});
}); });
@@ -0,0 +1,86 @@
import { OnspringClient } from '../../src';
import { expect } from 'chai';
import { baseURL, apiKey } from '../mochaRootHooks';
describe('getReportsByAppId', function () {
this.timeout(30000);
this.retries(3);
it('should return a list of reports', async function () {
const client = new OnspringClient(baseURL, apiKey);
if (process.env.TEST_SURVEY_ID === undefined) {
expect.fail('TEST_SURVEY_ID is not defined');
}
const response = await client.getReportsByAppId(
parseInt(process.env.TEST_SURVEY_ID)
);
expect(response.statusCode).to.equal(200);
expect(response.isSuccessful).to.be.true;
expect(response.message).to.equal('');
expect(response.data).to.not.be.null;
if (response.data != null) {
expect(response.data.pageNumber).to.not.be.null;
expect(response.data.pageSize).to.not.be.null;
expect(response.data.totalRecords).to.not.be.null;
expect(response.data.totalPages).to.not.be.null;
expect(response.data.items).to.not.be.null;
expect(response.data.items).to.be.an('array');
response.data.items.forEach((report) => {
expect(report.appId).to.not.be.null;
expect(report.id).to.not.be.null;
expect(report.name).to.not.be.null;
expect(report.description).to.not.be.null;
});
}
});
it('should return a 400 error if page size is invalid', async function () {
const client = new OnspringClient(baseURL, apiKey);
if (process.env.TEST_SURVEY_ID === undefined) {
expect.fail('TEST_SURVEY_ID is not defined');
}
const response = await client.getReportsByAppId(
parseInt(process.env.TEST_SURVEY_ID),
{ pageSize: 1001, pageNumber: 1 }
);
expect(response.statusCode).to.equal(400);
expect(response.isSuccessful).to.be.false;
expect(response.message).to.not.be.null.and.to.not.be.undefined;
expect(response.data).to.be.null;
});
it('should return a 401 error if the api key is invalid', async function () {
const client = new OnspringClient(baseURL, 'invalid');
const response = await client.getReportsByAppId(1);
expect(response.statusCode).to.equal(401);
expect(response.isSuccessful).to.be.false;
expect(response.message).to.be.undefined;
expect(response.data).to.be.null;
});
it('should return a 403 error if the api key does not have access to one of the reports', async function () {
const client = new OnspringClient(baseURL, apiKey);
if (process.env.TEST_APP_ID_NO_ACCESS === undefined) {
expect.fail('TEST_APP_ID_NO_ACCESS is not defined');
}
const response = await client.getReportsByAppId(
parseInt(process.env.TEST_APP_ID_NO_ACCESS)
);
expect(response.statusCode).to.equal(403);
expect(response.isSuccessful).to.be.false;
expect(response.message).to.not.be.null.and.to.not.be.undefined;
expect(response.data).to.be.null;
});
});
+4 -1
View File
@@ -21,4 +21,7 @@ TEST_LIST_FIELD=NEEDS_TO_BE_SET
TEST_LIST_FIELD_NO_ACCESS=NEEDS_TO_BE_SET TEST_LIST_FIELD_NO_ACCESS=NEEDS_TO_BE_SET
TEST_LIST_ID=NEEDS_TO_BE_SET TEST_LIST_ID=NEEDS_TO_BE_SET
TEST_LIST_ID_NO_ACCESS=NEEDS_TO_BE_SET TEST_LIST_ID_NO_ACCESS=NEEDS_TO_BE_SET
TEST_LIST_ITEM_ID_NO_ACCESS=NEEDS_TO_BE_SET TEST_LIST_ITEM_ID_NO_ACCESS=NEEDS_TO_BE_SET
TEST_REPORT=NEEDS_TO_BE_SET
TEST_REPORT_NO_ACCESS=NEEDS_TO_BE_SET
TEST_REPORT_WITH_CHART_DATA=NEEDS_TO_BE_SET