Skip to content

Commit 3a0db80

Browse files
committed
fixed tests to reflect that filter with orgId is now required
1 parent 6cb4b87 commit 3a0db80

File tree

1 file changed

+24
-40
lines changed

1 file changed

+24
-40
lines changed

src/routes/orgConfig/list.spec.js

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,40 +32,12 @@ describe('LIST organization config', () => {
3232
];
3333

3434
beforeEach(() => testUtil.clearDb()
35-
.then(() => models.OrgConfig.create(configs[0]))
36-
.then(() => models.OrgConfig.create(configs[1]))
37-
.then(() => Promise.resolve()),
35+
.then(() => models.OrgConfig.bulkCreate(configs)),
3836
);
3937
after(testUtil.clearDb);
4038

4139
describe('GET /orgConfig', () => {
42-
it('should return 200 for admin', (done) => {
43-
request(server)
44-
.get(`${orgConfigPath}`)
45-
.set({
46-
Authorization: `Bearer ${testUtil.jwts.admin}`,
47-
})
48-
.expect(200)
49-
.end((err, res) => {
50-
const config = configs[0];
51-
52-
const resJson = res.body.result.content;
53-
resJson.should.have.length(2);
54-
resJson[0].id.should.be.eql(config.id);
55-
resJson[0].orgId.should.be.eql(config.orgId);
56-
resJson[0].configName.should.be.eql(config.configName);
57-
resJson[0].configValue.should.be.eql(config.configValue);
58-
should.exist(resJson[0].createdAt);
59-
resJson[0].updatedBy.should.be.eql(config.updatedBy);
60-
should.exist(resJson[0].updatedAt);
61-
should.not.exist(resJson[0].deletedBy);
62-
should.not.exist(resJson[0].deletedAt);
63-
64-
done();
65-
});
66-
});
67-
68-
it('should return 200 with filters', (done) => {
40+
it('should return 200 for admin with filter', (done) => {
6941
request(server)
7042
.get(`${orgConfigPath}?filter=orgId%3Din%28${configs[0].orgId}%29%26configName=${configs[0].configName}`)
7143
.set({
@@ -91,48 +63,60 @@ describe('LIST organization config', () => {
9163
});
9264
});
9365

94-
it('should return 200 even if user is not authenticated', (done) => {
66+
it('should return 200 even if user is not authenticated with filter', (done) => {
9567
request(server)
96-
.get(`${orgConfigPath}`)
68+
.get(`${orgConfigPath}?filter=orgId%3Din%28${configs[0].orgId}%29%26configName=${configs[0].configName}`)
9769
.expect(200, done);
9870
});
9971

100-
it('should return 200 for connect admin', (done) => {
72+
it('should return 200 for connect admin with filter', (done) => {
10173
request(server)
102-
.get(`${orgConfigPath}`)
74+
.get(`${orgConfigPath}?filter=orgId%3Din%28${configs[0].orgId}%29%26configName=${configs[0].configName}`)
10375
.set({
10476
Authorization: `Bearer ${testUtil.jwts.connectAdmin}`,
10577
})
10678
.expect(200)
10779
.end(done);
10880
});
10981

110-
it('should return 200 for connect manager', (done) => {
82+
it('should return 200 for connect manager with filter', (done) => {
11183
request(server)
112-
.get(`${orgConfigPath}`)
84+
.get(`${orgConfigPath}?filter=orgId%3Din%28${configs[0].orgId}%29%26configName=${configs[0].configName}`)
11385
.set({
11486
Authorization: `Bearer ${testUtil.jwts.manager}`,
11587
})
11688
.expect(200)
11789
.end(done);
11890
});
11991

120-
it('should return 200 for member', (done) => {
92+
it('should return 200 for member with filter', (done) => {
12193
request(server)
122-
.get(`${orgConfigPath}`)
94+
.get(`${orgConfigPath}?filter=orgId%3Din%28${configs[0].orgId}%29%26configName=${configs[0].configName}`)
12395
.set({
12496
Authorization: `Bearer ${testUtil.jwts.member}`,
12597
})
12698
.expect(200, done);
12799
});
128100

129-
it('should return 200 for copilot', (done) => {
101+
it('should return 200 for copilot with filter', (done) => {
130102
request(server)
131-
.get(`${orgConfigPath}`)
103+
.get(`${orgConfigPath}?filter=orgId%3Din%28${configs[0].orgId}%29%26configName=${configs[0].configName}`)
132104
.set({
133105
Authorization: `Bearer ${testUtil.jwts.copilot}`,
134106
})
135107
.expect(200, done);
136108
});
109+
110+
it('should return 422 without filter query param', (done) => {
111+
request(server)
112+
.get(`${orgConfigPath}`)
113+
.expect(422, done);
114+
});
115+
116+
it('should return 422 with filter query param but without orgId defined', (done) => {
117+
request(server)
118+
.get(`${orgConfigPath}?filter=configName=${configs[0].configName}`)
119+
.expect(422, done);
120+
});
137121
});
138122
});

0 commit comments

Comments
 (0)