Skip to content

Commit

Permalink
Add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
echaidemenos committed Aug 4, 2023
1 parent c5e3bb3 commit 298bfd1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main.js",
"lint": "eslint \"{src,apps,libs,test,scripts}/**/*.{ts,js}\" --max-warnings 0",
"test": "cross-env NODE_ENV=test jest --config ./test/jest.json --silent",
"test": "cross-env NODE_ENV=test jest --config ./test/jest.json",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/time-series/time-series.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export class TimeSeriesService {
const uploadResponse = await Bluebird.Promise.map(
files,
async ({ path, originalname, mimetype }) => {
console.log('path', path);

Check warning on line 255 in packages/api/src/time-series/time-series.service.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement
try {
const ignoredHeaders = await uploadTimeSeriesData({
user,
Expand Down Expand Up @@ -281,6 +282,7 @@ export class TimeSeriesService {
error: error.message,
};
} finally {
console.log('unlinkSync path', path);

Check warning on line 285 in packages/api/src/time-series/time-series.service.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement
// Remove file once its processing is over
unlinkSync(path);
}
Expand Down
23 changes: 23 additions & 0 deletions packages/api/src/time-series/time-series.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,29 +186,41 @@ export const timeSeriesTests = () => {
let surveyPoints: SiteSurveyPoint[];
let fistSitePointId: number;

console.log(0);

Check warning on line 189 in packages/api/src/time-series/time-series.spec.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement

it('setups the user relations', async () => {
console.log(1);

Check warning on line 192 in packages/api/src/time-series/time-series.spec.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement

user = await dataSource.getRepository(User).findOne({
where: { firebaseUid: siteManagerUserMock.firebaseUid as string },
select: ['id'],
});

console.log(2);

Check warning on line 199 in packages/api/src/time-series/time-series.spec.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement

sites = await dataSource.getRepository(Site).find();
expect(sites.length).toBe(3);

console.log(3);

Check warning on line 204 in packages/api/src/time-series/time-series.spec.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement

surveyPoints = await dataSource.getRepository(SiteSurveyPoint).find();
fistSitePointId = surveyPoints.find((x) => x.siteId === sites[0].id)
?.id as number;

expect(fistSitePointId).toBeDefined();
expect(csvDataMock.length).toBe(30);

console.log(4);

Check warning on line 213 in packages/api/src/time-series/time-series.spec.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement

await dataSource
.getRepository(User)
.createQueryBuilder('user')
.relation('administeredSites')
.of(user)
.add(sites.slice(0, 2));

console.log(5);

Check warning on line 222 in packages/api/src/time-series/time-series.spec.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement

firstSiteRows = 20;
});

Expand All @@ -230,6 +242,8 @@ export const timeSeriesTests = () => {
return result;
});

console.log(6);

Check warning on line 245 in packages/api/src/time-series/time-series.spec.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement

const csvString = stringify(editedData, { header: true });

mockExtractAndVerifyToken(siteManager2FirebaseUserMock);
Expand All @@ -238,6 +252,8 @@ export const timeSeriesTests = () => {
.attach('files', Buffer.from(csvString), 'data.csv')
.set('Content-Type', 'text/csv');

console.log(7);

Check warning on line 255 in packages/api/src/time-series/time-series.spec.ts

View workflow job for this annotation

GitHub Actions / api_test_and_build

Unexpected console statement

expect(resp.status).toBe(201);

expect(
Expand All @@ -246,6 +262,8 @@ export const timeSeriesTests = () => {
});

it('upload fails for wrong site id', async () => {
console.log(8);

const editedData = csvDataMock.map((row, i) => {
const result = row;

Expand All @@ -264,6 +282,8 @@ export const timeSeriesTests = () => {
.attach('files', Buffer.from(csvString), 'data2.csv')
.set('Content-Type', 'text/csv');

console.log(9);

expect(
response.body.find(
(x) => x.error === `Invalid values for 'aqualink_site_id'`,
Expand All @@ -272,6 +292,7 @@ export const timeSeriesTests = () => {
});

it('upload fails for wrong survey point id', async () => {
console.log(10);
const wrongPointId = surveyPoints.find((x) => x.id !== fistSitePointId)
?.id as number;

Expand All @@ -296,6 +317,8 @@ export const timeSeriesTests = () => {
.attach('files', Buffer.from(csvString), 'data2.csv')
.set('Content-Type', 'text/csv');

console.log(11);

expect(
response.body.find((x) =>
(x.error as string).startsWith('Survey point with id'),
Expand Down
18 changes: 9 additions & 9 deletions packages/api/test/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ describe('AppController (e2e)', () => {
expect(app).toBeDefined();
});

describe('HealthCheck (e2e) /health-check', healthCheckTests);
// describe('HealthCheck (e2e) /health-check', healthCheckTests);

describe('User (e2e) /users', userTests);
// describe('User (e2e) /users', userTests);

describe('Site SurveyPoints (e2e) /site-survey-points', surveyPointTests);
// describe('Site SurveyPoints (e2e) /site-survey-points', surveyPointTests);

describe('Collection (e2e) /collections', collectionTests);
// describe('Collection (e2e) /collections', collectionTests);

describe('Time Series (e2e) /time-series', timeSeriesTests);

describe('Region (e2e) /regions', regionTests);
// describe('Region (e2e) /regions', regionTests);

describe('Site Application {e2e) /site-applications', siteApplicationTests);
// describe('Site Application {e2e) /site-applications', siteApplicationTests);

describe('Survey (e2e) /sites/:id/surveys', surveyTests);
// describe('Survey (e2e) /sites/:id/surveys', surveyTests);

describe('Sites (e2e) /sites', siteTests);
// describe('Sites (e2e) /sites', siteTests);

describe('Sensors (e2e) /sensors', sensorTests);
// describe('Sensors (e2e) /sensors', sensorTests);

afterAll(async () => {
await testService.cleanUpApp();
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": "../",
"testEnvironment": "node",
"testRegex": ["app.spec.ts$", "test.ts$"],
"testRegex": ["app.spec.ts$"],
"testTimeout": 120000,
"verbose": true,
"collectCoverage": true,
Expand Down

0 comments on commit 298bfd1

Please sign in to comment.