Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into BC-5170-no-preview-fo…
Browse files Browse the repository at this point in the history
…r-larger-files
  • Loading branch information
SevenWaysDP committed Oct 25, 2023
2 parents 6966569 + 3e112cc commit 20f5164
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
nest_lint:
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 6
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,27 @@ describe('AccountIdmToDtoMapperDb', () => {
});

describe('when date is undefined', () => {
it('should use actual date', () => {
const setup = () => {
const testIdmEntity: IdmAccount = {
id: 'id',
};

const dateMock = new Date();
jest.useFakeTimers();
jest.setSystemTime(dateMock);

return { testIdmEntity, dateMock };
};

it('should use actual date', () => {
const { testIdmEntity, dateMock } = setup();

const ret = mapper.mapToDto(testIdmEntity);

const now = new Date();
expect(ret.createdAt).toEqual(now);
expect(ret.updatedAt).toEqual(now);
expect(ret.createdAt).toEqual(dateMock);
expect(ret.updatedAt).toEqual(dateMock);

jest.useRealTimers();
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createMock } from '@golevelup/ts-jest';
import { EntityManager } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
Expand All @@ -13,6 +14,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import NodeClam from 'clamscan';
import { Request } from 'express';
import request from 'supertest';
import { FileRecord, FileRecordParentType } from '../../entity';
Expand Down Expand Up @@ -62,6 +64,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -103,6 +104,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -102,6 +103,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EntityId, Permission } from '@shared/domain';
import { AntivirusService } from '@shared/infra/antivirus';
import { S3ClientAdapter } from '@shared/infra/s3-client';
import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -115,6 +116,8 @@ describe('files-storage controller (API)', () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createMock } from '@golevelup/ts-jest';
import { EntityManager } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
Expand All @@ -13,6 +14,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import NodeClam from 'clamscan';
import { Request } from 'express';
import request from 'supertest';
import { FileRecordParentType, PreviewStatus } from '../../entity';
Expand Down Expand Up @@ -62,6 +64,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AntivirusService } from '@shared/infra/antivirus';
import { PreviewProducer } from '@shared/infra/preview-generator';
import { S3ClientAdapter } from '@shared/infra/s3-client';
import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -116,6 +117,8 @@ describe('File Controller (API) - preview', () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createMock } from '@golevelup/ts-jest';
import { EntityManager } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
Expand All @@ -13,6 +14,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import NodeClam from 'clamscan';
import { Request } from 'express';
import request from 'supertest';
import { FileRecord, FileRecordParentType } from '../../entity';
Expand Down Expand Up @@ -62,6 +64,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -127,6 +128,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe('SchoolYearService', () => {

describe('getCurrentSchoolYear', () => {
const setup = () => {
jest.setSystemTime(new Date('2022-06-01').getTime());
const schoolYear: SchoolYearEntity = schoolYearFactory.build({
startDate: new Date('2021-09-01'),
endDate: new Date('2022-12-31'),
Expand All @@ -60,7 +59,6 @@ describe('SchoolYearService', () => {

describe('findById', () => {
const setup = () => {
jest.setSystemTime(new Date('2022-06-01').getTime());
const schoolYear: SchoolYearEntity = schoolYearFactory.build({
startDate: new Date('2021-09-01'),
endDate: new Date('2022-12-31'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import {
import { Request } from 'express';
import request from 'supertest';

// config must be set outside before the server module is imported, otherwise the configuration is already set
Configuration.set('FEATURE_COPY_SERVICE_ENABLED', true);
Configuration.set('INCOMING_REQUEST_TIMEOUT_COPY_API', 1);

// eslint-disable-next-line import/first
import { ServerTestModule } from '@modules/server/server.module';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('createPrometheusMetricsApp', () => {
describe('should create an app that should', () => {
it('collect all the available metrics and expose them on given route', async () => {
const testMetricsRoute = '/prometheus-metrics';
const exampleDefaultMetricName = 'process_heap_bytes';
const exampleDefaultMetricName = 'process_cpu_user_seconds_total';
const exampleMetricsRouteMetric =
`sc_api_response_time_in_seconds_count{` +
`method="GET",` +
Expand Down

0 comments on commit 20f5164

Please sign in to comment.