Skip to content

Commit

Permalink
Add integration tests for event-log on thesis status change
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksTeresh committed Sep 25, 2024
1 parent 3c50e9c commit 38dfeb9
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/server/routes/thesis.integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ describe('thesis router', () => {
})

describe('when the thesis has status other than PLANING or IN_PROGRESS', () => {
it('should return 200 and update the thesis', async () => {
it('should return 200, update the thesis and log the status update event', async () => {
await ProgramManagement.create({
programId: 'Testing program',
userId: user2.id,
Expand Down Expand Up @@ -2828,13 +2828,18 @@ describe('thesis router', () => {
.field('json', JSON.stringify(updatedThesis))

expect(response.status).toEqual(200)

const eventLog = await EventLog.findOne({
where: { thesisId: thesis1.id, type: 'THESIS_STATUS_CHANGED' },
})
expect(eventLog).not.toBeNull()
})
})
})

describe('when the user is a teacher and is a supervisor of the thesis', () => {
describe('when the thesis has PLANNING status', () => {
it('should return 403 and a correct error message', async () => {
it('should return 403 and a correct error message, and not log status change event', async () => {
const updatedThesis = {
programId: 'Updated program',
studyTrackId: 'new-test-study-track-id',
Expand Down Expand Up @@ -2892,6 +2897,11 @@ describe('thesis router', () => {
],
},
})

const eventLog = await EventLog.findOne({
where: { type: 'THESIS_STATUS_CHANGED' },
})
expect(eventLog).toBeNull()
})
})

Expand All @@ -2901,7 +2911,7 @@ describe('thesis router', () => {
thesis1.save()
})

it('should return 200 and update the thesis', async () => {
it('should return 200, update the thesis and not log status change event', async () => {
const updatedThesis = {
programId: 'Updated program',
studyTrackId: 'new-test-study-track-id',
Expand Down Expand Up @@ -2950,6 +2960,11 @@ describe('thesis router', () => {
)
.field('json', JSON.stringify(updatedThesis))
expect(response.status).toEqual(200)

const eventLog = await EventLog.findOne({
where: { type: 'THESIS_STATUS_CHANGED' },
})
expect(eventLog).toBeNull()
})
})

Expand All @@ -2959,7 +2974,7 @@ describe('thesis router', () => {
thesis1.save()
})

it('should return 200 and update the thesis', async () => {
it('should return 200, update the thesis and log status change event', async () => {
const updatedThesis = {
programId: 'Updated program',
studyTrackId: 'new-test-study-track-id',
Expand Down Expand Up @@ -3008,6 +3023,11 @@ describe('thesis router', () => {
)
.field('json', JSON.stringify(updatedThesis))
expect(response.status).toEqual(200)

const eventLog = await EventLog.findOne({
where: { type: 'THESIS_STATUS_CHANGED', thesisId: thesis1.id },
})
expect(eventLog).not.toBeNull()
})
})
})
Expand Down

0 comments on commit 38dfeb9

Please sign in to comment.