-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(scheduler-service): add filter related changes, add relation cont…
…rollers (#34) add filter intake capabilities to listing APIs, add-relation controller, add and update acceptance SFO-89, SFO-80
- Loading branch information
Showing
17 changed files
with
1,123 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...cheduler-service/src/__tests__/acceptance/calendar-subscriptions.controller.acceptance.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import {Client, expect} from '@loopback/testlab'; | ||
import * as jwt from 'jsonwebtoken'; | ||
import {CalendarRepository} from '../../repositories'; | ||
import {SchedulerApplication} from '../application'; | ||
import {setUpApplication} from './helper'; | ||
|
||
describe('Calendar-Subscription Controller', () => { | ||
let app: SchedulerApplication; | ||
let client: Client; | ||
let calendarRepo: CalendarRepository; | ||
let calendarId: string; | ||
|
||
const pass = 'test_password'; | ||
const testUser = { | ||
id: 1, | ||
username: 'test_user', | ||
password: pass, | ||
permissions: [ | ||
'ViewSubscription', | ||
'CreateSubscription', | ||
'UpdateSubscription', | ||
'DeleteSubscription', | ||
'CreateCalendar', | ||
'ViewCalendar', | ||
], | ||
}; | ||
|
||
const token = jwt.sign(testUser, 'kdskssdkdfs', { | ||
expiresIn: 180000, | ||
issuer: 'sf', | ||
}); | ||
|
||
before('setupApplication', async () => { | ||
({app, client} = await setUpApplication()); | ||
}); | ||
after(async () => app.stop()); | ||
|
||
before(givenRepositories); | ||
afterEach(deleteMockData); | ||
before(setUpMockData); | ||
|
||
it('gives status 422 when data sent is incorrect', async () => { | ||
const reqData = {invalid: 'dummy'}; | ||
const response = await client | ||
.post(`/calendars/${calendarId}/subscriptions`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send(reqData) | ||
.expect(422); | ||
|
||
expect(response).to.have.property('error'); | ||
}); | ||
|
||
it('gives status 401 when no token is passed', async () => { | ||
const response = await client | ||
.get(`/calendars/${calendarId}/subscriptions`) | ||
.expect(401); | ||
|
||
expect(response).to.have.property('error'); | ||
}); | ||
|
||
it('gives status 200 when token is passed', async () => { | ||
await client | ||
.get(`/calendars/${calendarId}/subscriptions`) | ||
.set('authorization', `Bearer ${token}`) | ||
.expect(200); | ||
}); | ||
|
||
it('gives status 422 when subscription details are not correct', async () => { | ||
const subscriptionToAdd = {invalid: 'dummy'}; | ||
|
||
await client | ||
.post(`/calendars/${calendarId}/subscriptions`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send(subscriptionToAdd) | ||
.expect(422); | ||
}); | ||
|
||
it('deletes subscriptions belonging to a calendarId successfully', async () => { | ||
await client | ||
.del(`/calendars/${calendarId}/subscriptions`) | ||
.set('authorization', `Bearer ${token}`) | ||
.expect(200); | ||
}); | ||
|
||
it('updates subscriptions belonging to a calendarId successfully', async () => { | ||
const response = await client | ||
.patch(`/calendars/${calendarId}/subscriptions`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({isHidden: true}) | ||
.expect(200); | ||
expect(response.body).to.have.properties('count'); | ||
}); | ||
|
||
async function setUpMockData() { | ||
const calendar = await client | ||
.post(`/calendars`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({identifier: 'dummy'}); | ||
|
||
calendarId = calendar.body.id; | ||
|
||
await client | ||
.post(`/calendars/${calendarId}/subscriptions`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({identifier: 'dummy'}); | ||
} | ||
|
||
async function deleteMockData() { | ||
await calendarRepo.deleteAllHard(); | ||
} | ||
|
||
async function givenRepositories() { | ||
calendarRepo = await app.getRepository(CalendarRepository); | ||
} | ||
}); |
115 changes: 115 additions & 0 deletions
115
...scheduler-service/src/__tests__/acceptance/calendar-working-hour.controller.acceptance.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import {Client, expect} from '@loopback/testlab'; | ||
import * as jwt from 'jsonwebtoken'; | ||
import {CalendarRepository} from '../../repositories'; | ||
import {SchedulerApplication} from '../application'; | ||
import {setUpApplication} from './helper'; | ||
|
||
describe('Calendar-WorkingHour Controller', () => { | ||
let app: SchedulerApplication; | ||
let client: Client; | ||
let calendarRepo: CalendarRepository; | ||
let calendarId: string; | ||
|
||
const pass = 'test_password'; | ||
const testUser = { | ||
id: 1, | ||
username: 'test_user', | ||
password: pass, | ||
permissions: [ | ||
'ViewWorkingHour', | ||
'CreateWorkingHour', | ||
'UpdateWorkingHour', | ||
'DeleteWorkingHour', | ||
'CreateCalendar', | ||
'ViewCalendar', | ||
], | ||
}; | ||
|
||
const token = jwt.sign(testUser, 'kdskssdkdfs', { | ||
expiresIn: 180000, | ||
issuer: 'sf', | ||
}); | ||
|
||
before('setupApplication', async () => { | ||
({app, client} = await setUpApplication()); | ||
}); | ||
after(async () => app.stop()); | ||
|
||
before(givenRepositories); | ||
afterEach(deleteMockData); | ||
before(setUpMockData); | ||
|
||
it('gives status 422 when data sent is incorrect', async () => { | ||
const reqData = {invalid: 'dummy'}; | ||
const response = await client | ||
.post(`/calendars/${calendarId}/working-hours`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send(reqData) | ||
.expect(422); | ||
|
||
expect(response).to.have.property('error'); | ||
}); | ||
|
||
it('gives status 401 when no token is passed', async () => { | ||
const response = await client | ||
.get(`/calendars/${calendarId}/working-hours`) | ||
.expect(401); | ||
|
||
expect(response).to.have.property('error'); | ||
}); | ||
|
||
it('gives status 200 when token is passed', async () => { | ||
await client | ||
.get(`/calendars/${calendarId}/working-hours`) | ||
.set('authorization', `Bearer ${token}`) | ||
.expect(200); | ||
}); | ||
|
||
it('gives status 422 when workingHour details are not correct', async () => { | ||
const workingHourToAdd = {invalid: 'dummy'}; | ||
|
||
await client | ||
.post(`/calendars/${calendarId}/working-hours`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send(workingHourToAdd) | ||
.expect(422); | ||
}); | ||
|
||
it('deletes working-hours belonging to a calendarId successfully', async () => { | ||
await client | ||
.del(`/calendars/${calendarId}/working-hours`) | ||
.set('authorization', `Bearer ${token}`) | ||
.expect(200); | ||
}); | ||
|
||
it('updates working-hours belonging to a calendarId successfully', async () => { | ||
const response = await client | ||
.patch(`/calendars/${calendarId}/working-hours`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({dayOfWeek: 1}) | ||
.expect(200); | ||
expect(response.body).to.have.properties('count'); | ||
}); | ||
|
||
async function setUpMockData() { | ||
const calendar = await client | ||
.post(`/calendars`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({identifier: 'dummy'}); | ||
|
||
calendarId = calendar.body.id; | ||
|
||
await client | ||
.post(`/calendars/${calendarId}/working-hours`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({identifier: 'dummy'}); | ||
} | ||
|
||
async function deleteMockData() { | ||
await calendarRepo.deleteAllHard(); | ||
} | ||
|
||
async function givenRepositories() { | ||
calendarRepo = await app.getRepository(CalendarRepository); | ||
} | ||
}); |
115 changes: 115 additions & 0 deletions
115
...ices/scheduler-service/src/__tests__/acceptance/event-attachment.controller.acceptance.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import {Client, expect} from '@loopback/testlab'; | ||
import * as jwt from 'jsonwebtoken'; | ||
import {EventRepository} from '../../repositories'; | ||
import {SchedulerApplication} from '../application'; | ||
import {setUpApplication} from './helper'; | ||
|
||
describe('Event-Attachment Controller', () => { | ||
let app: SchedulerApplication; | ||
let client: Client; | ||
let eventRepo: EventRepository; | ||
let eventId: string; | ||
|
||
const pass = 'test_password'; | ||
const testUser = { | ||
id: 1, | ||
username: 'test_user', | ||
password: pass, | ||
permissions: [ | ||
'ViewAttachment', | ||
'CreateAttachment', | ||
'UpdateAttachment', | ||
'DeleteAttachment', | ||
'CreateEvent', | ||
'ViewEvent', | ||
], | ||
}; | ||
|
||
const token = jwt.sign(testUser, 'kdskssdkdfs', { | ||
expiresIn: 180000, | ||
issuer: 'sf', | ||
}); | ||
|
||
before('setupApplication', async () => { | ||
({app, client} = await setUpApplication()); | ||
}); | ||
after(async () => app.stop()); | ||
|
||
before(givenRepositories); | ||
afterEach(deleteMockData); | ||
before(setUpMockData); | ||
|
||
it('gives status 422 when data sent is incorrect', async () => { | ||
const reqData = {invalid: 'dummy'}; | ||
const response = await client | ||
.post(`/events/${eventId}/attachments`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send(reqData) | ||
.expect(422); | ||
|
||
expect(response).to.have.property('error'); | ||
}); | ||
|
||
it('gives status 401 when no token is passed', async () => { | ||
const response = await client | ||
.get(`/events/${eventId}/attachments`) | ||
.expect(401); | ||
|
||
expect(response).to.have.property('error'); | ||
}); | ||
|
||
it('gives status 200 when token is passed', async () => { | ||
await client | ||
.get(`/events/${eventId}/attachments`) | ||
.set('authorization', `Bearer ${token}`) | ||
.expect(200); | ||
}); | ||
|
||
it('gives status 422 when attachment details are not correct', async () => { | ||
const attachmentToAdd = {invalid: 'dummy'}; | ||
|
||
await client | ||
.post(`/events/${eventId}/attachments`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send(attachmentToAdd) | ||
.expect(422); | ||
}); | ||
|
||
it('deletes attachments belonging to a eventId successfully', async () => { | ||
await client | ||
.del(`/events/${eventId}/attachments`) | ||
.set('authorization', `Bearer ${token}`) | ||
.expect(200); | ||
}); | ||
|
||
it('updates attachments belonging to a eventId successfully', async () => { | ||
const response = await client | ||
.patch(`/events/${eventId}/attachments`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({fileUrl: 'dummy'}) | ||
.expect(200); | ||
expect(response.body).to.have.properties('count'); | ||
}); | ||
|
||
async function setUpMockData() { | ||
const event = await client | ||
.post(`/events`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({identifier: 'dummy'}); | ||
|
||
eventId = event.body.id; | ||
|
||
await client | ||
.post(`/events/${eventId}/attachments`) | ||
.set('authorization', `Bearer ${token}`) | ||
.send({identifier: 'dummy'}); | ||
} | ||
|
||
async function deleteMockData() { | ||
await eventRepo.deleteAllHard(); | ||
} | ||
|
||
async function givenRepositories() { | ||
eventRepo = await app.getRepository(EventRepository); | ||
} | ||
}); |
Oops, something went wrong.