Skip to content

Commit

Permalink
YKI(Frontend): Don't allow queueing if registration is not ongoing [d…
Browse files Browse the repository at this point in the history
…eploy]
  • Loading branch information
pkoivisto committed Jan 12, 2024
1 parent a4b133c commit 6cd4f13
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
61 changes: 59 additions & 2 deletions frontend/packages/yki/src/tests/jest/utils/examSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe('ExamSessionUtils', () => {
...baseExamSession,
open: false,
upcoming_admission: false,
upcoming_post_admission: false
upcoming_post_admission: false,
},
{
kind: RegistrationKind.Admission,
Expand All @@ -283,7 +283,7 @@ describe('ExamSessionUtils', () => {
{
...baseExamSession,
upcoming_admission: false,
upcoming_post_admission: true
upcoming_post_admission: true,
},
{
kind: RegistrationKind.PostAdmission,
Expand Down Expand Up @@ -325,6 +325,63 @@ describe('ExamSessionUtils', () => {
);
});

it('should allow subscribing for notifications only within regular admission period', () => {
expectEffectiveRegistrationDetails(
{
...baseExamSession,
open: true,
upcoming_admission: true,
upcoming_post_admission: true,
queue_full: false,
},
{
availableQueue: true,
}
);

// Queue full -> availableQueue: false
expectEffectiveRegistrationDetails(
{
...baseExamSession,
open: true,
upcoming_admission: true,
upcoming_post_admission: true,
queue_full: true,
},
{
availableQueue: false,
}
);

// Regular admission over -> availableQueue: false
expectEffectiveRegistrationDetails(
{
...baseExamSession,
open: true,
upcoming_admission: false,
upcoming_post_admission: true,
queue_full: true,
},
{
availableQueue: false,
}
);

// Admission not yet started -> availableQueue: false
expectEffectiveRegistrationDetails(
{
...baseExamSession,
open: false,
upcoming_admission: true,
upcoming_post_admission: true,
queue_full: true,
},
{
availableQueue: false,
}
);
});

afterAll(() => {
jest.useRealTimers();
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/yki/src/utils/examSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class ExamSessionUtils {
participants: examSession.participants,
quota: examSession.max_participants,
availablePlaces: ExamSessionUtils.getAvailablePlaces(examSession),
availableQueue: !examSession.queue_full,
availableQueue: examSession.open && !examSession.queue_full,
open: examSession.open,
};
} else {
Expand Down

0 comments on commit 6cd4f13

Please sign in to comment.