Skip to content

Commit 76c4305

Browse files
Merge pull request #1030 from ReliefApplications/next
Next
2 parents 95d108e + f89ad12 commit 76c4305

File tree

86 files changed

+2609
-1585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2609
-1585
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
- next-major
1616
- beta
1717
- alpha
18-
- "[0-9]*.[0-9x]*.x"
18+
- '[0-9]*.[0-9x]*.x'
1919

2020
concurrency:
2121
group: ${{ github.workflow }}-${{ github.ref }}
@@ -64,11 +64,11 @@ jobs:
6464
# path: .env
6565
- name: Test
6666
#run: npm run test
67-
run: docker-compose -f docker-compose.test.yml run test-server npm run test
67+
run: docker-compose -f docker-compose.test.yml run test-server npm run test -- --runInBand --ci
6868

6969
- name: Archive code coverage result
7070
if: success()
7171
uses: actions/upload-artifact@v3
7272
with:
7373
name: deploy_coverage
74-
path: coverage
74+
path: coverage

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
# [2.8.0](https://github.com/ReliefApplications/ems-backend/compare/v2.7.2...v2.8.0) (2024-04-24)
2+
3+
4+
### Bug Fixes
5+
6+
* csv export should now lookalike excel export ([#981](https://github.com/ReliefApplications/ems-backend/issues/981)) ([b13e55c](https://github.com/ReliefApplications/ems-backend/commit/b13e55c94c10bebae42e30ac29dc83b30c9a7a88))
7+
* some ref data aggregations would not send correct data. Now use field name instead of grahp ql field name ([#998](https://github.com/ReliefApplications/ems-backend/issues/998)) ([d2e7074](https://github.com/ReliefApplications/ems-backend/commit/d2e7074853ff10fd29ad7b7f4e3d41683846e5cf))
8+
* update user management and who configurations ([38798f2](https://github.com/ReliefApplications/ems-backend/commit/38798f252efa2a62bd5256fcf5e031d77cabfdfc))
9+
10+
11+
### Features
12+
13+
* Add email + AAD user type to automation rules ([#2468](https://github.com/ReliefApplications/ems-backend/issues/2468)) ([2240e1e](https://github.com/ReliefApplications/ems-backend/commit/2240e1ecedb3626738273adecf92fc3ed80c3bad)), closes [#89936](https://github.com/ReliefApplications/ems-backend/issues/89936) [#89936](https://github.com/ReliefApplications/ems-backend/issues/89936) [#89936](https://github.com/ReliefApplications/ems-backend/issues/89936)
14+
* role based display for action buttons ([#1008](https://github.com/ReliefApplications/ems-backend/issues/1008)) ([1579d04](https://github.com/ReliefApplications/ems-backend/commit/1579d040f1828fd11acba366786fe188295014b6))
15+
16+
17+
### Reverts
18+
19+
* Revert "AB#90725 - Transform gis/feature endpoint into POST" (#1019) ([62178d0](https://github.com/ReliefApplications/ems-backend/commit/62178d0bce90e270b673f87f939fff5de1ba2b1c)), closes [AB#90725](https://github.com/AB/issues/90725) [#1019](https://github.com/ReliefApplications/ems-backend/issues/1019)
20+
* Revert "change response type #90266 (#1011)" (#1016) ([35ff495](https://github.com/ReliefApplications/ems-backend/commit/35ff49551aaec6495b5928806d4af6452becfd0e)), closes [#90266](https://github.com/ReliefApplications/ems-backend/issues/90266) [#1011](https://github.com/ReliefApplications/ems-backend/issues/1011) [#1016](https://github.com/ReliefApplications/ems-backend/issues/1016)
21+
* use field name instead of graphql field name ([c6975da](https://github.com/ReliefApplications/ems-backend/commit/c6975da6cd10d071fb34ba64b4290fa585b976f0))
22+
23+
## [2.7.2](https://github.com/ReliefApplications/ems-backend/compare/v2.7.1...v2.7.2) (2024-03-25)
24+
25+
26+
### Bug Fixes
27+
28+
* add check for empty context filter ([#995](https://github.com/ReliefApplications/ems-backend/issues/995)) ([31a8544](https://github.com/ReliefApplications/ems-backend/commit/31a85447f4a418000d763049d1f0d38261d82f66))
29+
* now working nested fields in reference data aggregation ([ed564b3](https://github.com/ReliefApplications/ems-backend/commit/ed564b3f9eef48f06674144ac94d153c5e494d91))
30+
131
## [2.7.1](https://github.com/ReliefApplications/ems-backend/compare/v2.7.0...v2.7.1) (2024-03-04)
232

333

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,33 @@ In order to execute tests locally, you can execute the command:
2929
docker-compose -f docker-compose.test.yml run test-server npm run test
3030
```
3131

32+
Or this command:
33+
```
34+
npm run test
35+
```
36+
3237
It is also possible to run tests on a single file, by passing it as a parameter:
3338
```
3439
docker-compose -f docker-compose.test.yml run test-server npm run test -- <path_to_file>
3540
```
3641

42+
Or with this command:
43+
```
44+
npm run test -- <path_to_file>
45+
```
46+
47+
You can also limit the tests to one specific folder. For example:
48+
```
49+
npm run test -- --testPathPattern=models
50+
```
51+
52+
Note: If you're running the tests on Windows, make sure the test command in your `package.json` file is set up correctly. Here's the command that should be in the `scripts` section of your `package.json` file:
53+
54+
```json
55+
"test": "node --max-old-space-size=8192 ./node_modules/jest/bin/jest.js --logHeapUsage --forceExit"
56+
```
57+
Will only run tests in the **models** folder.
58+
3759
# RabbitMQ
3860

3961
If management platform is not reachable at 15672, you can use this command ( while containers are running ):

__tests__/global.setup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'tsconfig-paths/register';
2+
import dotenv from 'dotenv';
3+
dotenv.config();
24
import { startDatabase, initDatabase, stopDatabase } from '@server/database';
35
import config from 'config';
46
import { logger } from '@services/logger.service';

__tests__/jest.setup.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// This line is important, as it will prevent the delete folder method to use actual logic
2+
// As we don't want to test if deletion of azure files work or not, we skip it
3+
// Mocking for this module must be done before any other imports
4+
jest.mock('@utils/files/deleteFolder');
5+
16
import { startDatabase } from '../src/server/database';
27

38
// Execute before each file.
@@ -6,5 +11,7 @@ beforeAll(async () => {
611
}, 20000);
712

813
afterAll(async () => {
9-
//await stopDatabase();
14+
// await stopDatabase();
15+
// Avoid memory issue
16+
if (global.gc) global.gc();
1017
});

__tests__/models/aggregation.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ describe('Aggregation models tests', () => {
9595
};
9696
expect(async () =>
9797
new Resource(duplicateResource).save()
98-
).rejects.toThrowError(
99-
'E11000 duplicate key error collection: test.resources index: name_1 dup key'
100-
);
98+
).rejects.toMatchObject({
99+
code: 11000,
100+
});
101101
});
102102

103103
test('test with incorrect resource name field', async () => {

__tests__/models/apiConfiguration.test.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ describe('ApiConfiguration models tests', () => {
3434
};
3535
expect(async () =>
3636
new ApiConfiguration(duplicateApiConfig).save()
37-
).rejects.toThrowError(
38-
'E11000 duplicate key error collection: test.apiconfigurations index: name_1 dup key'
39-
);
37+
).rejects.toMatchObject({
38+
code: 11000,
39+
});
4040
});
4141

4242
test('test with incorrect api configuration status field', async () => {
@@ -60,4 +60,26 @@ describe('ApiConfiguration models tests', () => {
6060
).rejects.toThrow(Error);
6161
}
6262
});
63+
64+
test('test with incorrect api configuration authType field', async () => {
65+
for (let i = 0; i < 1; i++) {
66+
const apiConfig = {
67+
name: faker.random.word(),
68+
status: status.pending,
69+
authType: faker.random.word(), // Invalid value
70+
endpoint: faker.internet.url(),
71+
graphQLEndpoint: `${faker.internet.url()}/graphql`,
72+
pingUrl: 'PR',
73+
settings: {
74+
authTargetUrl: faker.internet.url(),
75+
apiClientID: faker.datatype.uuid(),
76+
safeSecret: faker.datatype.uuid(),
77+
scope: faker.random.word(),
78+
},
79+
};
80+
await expect(
81+
new ApiConfiguration(apiConfig).save()
82+
).rejects.toThrowError();
83+
}
84+
});
6385
});

__tests__/models/application.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ describe('Application models tests', () => {
3838
};
3939
expect(async () =>
4040
new Application(duplicateApplication).save()
41-
).rejects.toThrowError(
42-
'E11000 duplicate key error collection: test.applications index: name_1 dup key'
43-
);
41+
).rejects.toMatchObject({
42+
code: 11000,
43+
});
4444
});
4545

4646
test('test application delete', async () => {
@@ -71,7 +71,7 @@ describe('Application models tests', () => {
7171
}).save();
7272

7373
const isDelete = await Application.deleteOne({ _id: applicationData._id });
74-
expect(isDelete.ok).toEqual(1);
74+
expect(isDelete.acknowledged).toEqual(true);
7575
expect(isDelete.deletedCount).toEqual(1);
7676
});
7777
});

__tests__/models/channel.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ describe('Channel models tests', () => {
2121
};
2222
expect(async () =>
2323
new Channel(duplicateApiConfig).save()
24-
).rejects.toThrowError(
25-
'E11000 duplicate key error collection: test.channels index: title_1_application_1_form_1 dup key'
26-
);
24+
).rejects.toMatchObject({
25+
code: 11000,
26+
});
2727
});
2828

2929
test('test with blank channel name field', async () => {
3030
for (let i = 0; i < 1; i++) {
3131
const channelData = {
3232
title: '',
3333
};
34-
expect(async () => new Channel(channelData).save()).rejects.toThrow(
34+
await expect(async () => new Channel(channelData).save()).rejects.toThrow(
3535
Error
3636
);
3737
}
@@ -50,7 +50,7 @@ describe('Channel models tests', () => {
5050
}
5151

5252
const isDelete = await Channel.deleteOne({ _id: channelData._id });
53-
expect(isDelete.ok).toEqual(1);
53+
expect(isDelete.acknowledged).toEqual(true);
5454
expect(isDelete.deletedCount).toEqual(1);
5555
});
5656
});

__tests__/models/client.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ describe('Client models tests', () => {
2626
name: faker.name.fullName(),
2727
clientId: client.clientId,
2828
};
29-
expect(async () => new Client(inputData).save()).rejects.toThrowError(
30-
'E11000 duplicate key error collection: test.clients index: clientId_1 dup key'
31-
);
29+
expect(async () => new Client(inputData).save()).rejects.toMatchObject({
30+
code: 11000,
31+
});
3232
});
3333

3434
test('test client with duplicate oid field', async () => {

0 commit comments

Comments
 (0)