-
Notifications
You must be signed in to change notification settings - Fork 6
Allow for registration phase reopening if submission or TG submission phases are open #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,7 +330,7 @@ describe('challenge phase service unit tests', () => { | |
| } | ||
| }) | ||
|
|
||
| it('partially update challenge phase - cannot reopen when open phase is not a successor', async () => { | ||
| it('partially update challenge phase - can reopen registration when submission is open', async () => { | ||
| const startDate = new Date('2025-06-01T00:00:00.000Z') | ||
| const endDate = new Date('2025-06-02T00:00:00.000Z') | ||
|
|
||
|
|
@@ -350,6 +350,60 @@ describe('challenge phase service unit tests', () => { | |
| } | ||
| }) | ||
|
|
||
| try { | ||
| const challengePhase = await service.partiallyUpdateChallengePhase( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| authUser, | ||
| data.challenge.id, | ||
| data.challengePhase1Id, | ||
| { | ||
| isOpen: true | ||
| } | ||
| ) | ||
| should.equal(challengePhase.id, data.challengePhase1Id) | ||
| should.equal(challengePhase.isOpen, true) | ||
| should.equal(challengePhase.actualEndDate, null) | ||
| } finally { | ||
| await prisma.challengePhase.update({ | ||
| where: { id: data.challengePhase1Id }, | ||
| data: { | ||
| isOpen: false, | ||
| actualStartDate: startDate, | ||
| actualEndDate: endDate | ||
| } | ||
| }) | ||
| await prisma.challengePhase.update({ | ||
| where: { id: data.challengePhase2Id }, | ||
| data: { | ||
| isOpen: false, | ||
| predecessor: data.challengePhase1Id, | ||
| name: 'Submission' | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| }) | ||
|
|
||
| it('partially update challenge phase - cannot reopen when open phase is not a successor or submission variant', async () => { | ||
| const startDate = new Date('2025-06-01T00:00:00.000Z') | ||
| const endDate = new Date('2025-06-02T00:00:00.000Z') | ||
|
|
||
| await prisma.challengePhase.update({ | ||
| where: { id: data.challengePhase1Id }, | ||
| data: { | ||
| isOpen: false, | ||
| actualStartDate: startDate, | ||
| actualEndDate: endDate | ||
| } | ||
| }) | ||
| await prisma.challengePhase.update({ | ||
| where: { id: data.challengePhase2Id }, | ||
| data: { | ||
| isOpen: true, | ||
| predecessor: null, | ||
| name: 'Review' | ||
| } | ||
| }) | ||
|
|
||
| try { | ||
| await service.partiallyUpdateChallengePhase(authUser, data.challenge.id, data.challengePhase1Id, { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| isOpen: true | ||
|
|
@@ -366,7 +420,16 @@ describe('challenge phase service unit tests', () => { | |
| where: { id: data.challengePhase2Id }, | ||
| data: { | ||
| isOpen: false, | ||
| predecessor: data.challengePhase1Id | ||
| predecessor: data.challengePhase1Id, | ||
| name: 'Submission' | ||
| } | ||
| }) | ||
| await prisma.challengePhase.update({ | ||
| where: { id: data.challengePhase1Id }, | ||
| data: { | ||
| isOpen: false, | ||
| actualStartDate: startDate, | ||
| actualEndDate: endDate | ||
| } | ||
| }) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[💡
performance]The
normalizePhaseNamefunction is called twice for each phase inopenPhaseswhen checkinghasSubmissionVariantOpen. Consider normalizingphase?.nameonce before thesomemethod to improve performance slightly.