Skip to content

Commit

Permalink
chore: Update processRecurrence tests
Browse files Browse the repository at this point in the history
Running the tests locally crashes the server, because the retro
constructed for testing was not fully fleshed out.
Also updated the RRules used to have the frequency weekly, which is the
only setting the app allows.
  • Loading branch information
Dschoordsch committed May 22, 2024
1 parent 7a3c567 commit 2139962
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions packages/server/__tests__/processRecurrence.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import ms from 'ms'
import TeamMemberId from 'parabol-client/shared/gqlIds/TeamMemberId'
import {RRule} from 'rrule'
import getRethink from '../database/rethinkDriver'
import DiscussPhase from '../database/types/DiscussPhase'
import MeetingRetrospective from '../database/types/MeetingRetrospective'
import MeetingTeamPrompt from '../database/types/MeetingTeamPrompt'
import ReflectPhase from '../database/types/ReflectPhase'
Expand Down Expand Up @@ -71,13 +73,14 @@ test('Should not end meetings that are not scheduled to end', async () => {
const r = await getRethink()
const {userId} = await signUp()
const {id: teamId} = (await getUserTeams(userId))[0]
const teamMemberId = TeamMemberId.join(teamId, userId)

const meetingId = generateUID()
const meeting = new MeetingTeamPrompt({
id: meetingId,
teamId,
meetingCount: 0,
phases: [new TeamPromptResponsesPhase(['foobar'])],
phases: [new TeamPromptResponsesPhase([teamMemberId])],
facilitatorUserId: userId,
meetingPrompt: 'What are you working on today? Stuck on anything?'
})
Expand Down Expand Up @@ -108,13 +111,14 @@ test('Should not end meetings that are scheduled to end in the future', async ()
const r = await getRethink()
const {userId} = await signUp()
const {id: teamId} = (await getUserTeams(userId))[0]
const teamMemberId = TeamMemberId.join(teamId, userId)

const meetingId = generateUID()
const meeting = new MeetingTeamPrompt({
id: meetingId,
teamId,
meetingCount: 0,
phases: [new TeamPromptResponsesPhase(['foobar'])],
phases: [new TeamPromptResponsesPhase([teamMemberId])],
facilitatorUserId: userId,
meetingPrompt: 'What are you working on today? Stuck on anything?',
scheduledEndTime: new Date(Date.now() + ms('5m'))
Expand Down Expand Up @@ -148,13 +152,14 @@ test('Should end meetings that are scheduled to end in the past', async () => {
const r = await getRethink()
const {userId} = await signUp()
const {id: teamId} = (await getUserTeams(userId))[0]
const teamMemberId = TeamMemberId.join(teamId, userId)

const meetingId = generateUID()
const meeting = new MeetingTeamPrompt({
id: meetingId,
teamId,
meetingCount: 0,
phases: [new TeamPromptResponsesPhase(['foobar'])],
phases: [new TeamPromptResponsesPhase([teamMemberId])],
facilitatorUserId: userId,
meetingPrompt: 'What are you working on today? Stuck on anything?',
scheduledEndTime: new Date(Date.now() - ms('5m'))
Expand Down Expand Up @@ -186,6 +191,7 @@ test('Should end the current team prompt meeting and start a new meeting', async
const r = await getRethink()
const {userId} = await signUp()
const {id: teamId} = (await getUserTeams(userId))[0]
const teamMemberId = TeamMemberId.join(teamId, userId)

const now = new Date()

Expand All @@ -194,8 +200,9 @@ test('Should end the current team prompt meeting and start a new meeting', async
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - 2, 9)
)
const recurrenceRule = new RRule({
freq: RRule.DAILY,
dtstart: startDate
freq: RRule.WEEKLY,
dtstart: startDate,
byweekday: [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR, RRule.SA, RRule.SU]
})

const meetingSeriesId = await insertMeetingSeriesQuery({
Expand All @@ -212,7 +219,7 @@ test('Should end the current team prompt meeting and start a new meeting', async
id: meetingId,
teamId,
meetingCount: 0,
phases: [new TeamPromptResponsesPhase(['foobar'])],
phases: [new TeamPromptResponsesPhase([teamMemberId])],
facilitatorUserId: userId,
meetingPrompt: 'What are you working on today? Stuck on anything?',
scheduledEndTime: new Date(Date.now() - ms('5m')),
Expand Down Expand Up @@ -269,8 +276,10 @@ test('Should end the current retro meeting and start a new meeting', async () =>
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - 2, 9)
)
const recurrenceRule = new RRule({
freq: RRule.DAILY,
dtstart: startDate
freq: RRule.WEEKLY,
dtstart: startDate,
interval: 1,
byweekday: [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR, RRule.SA, RRule.SU]
})

const meetingSeriesId = await insertMeetingSeriesQuery({
Expand All @@ -287,7 +296,7 @@ test('Should end the current retro meeting and start a new meeting', async () =>
id: meetingId,
teamId,
meetingCount: 0,
phases: [new ReflectPhase(teamId, [])],
phases: [new ReflectPhase(teamId, []), new DiscussPhase(undefined)],
facilitatorUserId: userId,
scheduledEndTime: new Date(Date.now() - ms('5m')),
meetingSeriesId,
Expand Down Expand Up @@ -339,6 +348,7 @@ test('Should only start a new meeting if it would still be active', async () =>
const r = await getRethink()
const {userId} = await signUp()
const {id: teamId} = (await getUserTeams(userId))[0]
const teamMemberId = TeamMemberId.join(teamId, userId)

const now = new Date()

Expand All @@ -347,8 +357,9 @@ test('Should only start a new meeting if it would still be active', async () =>
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - 5, 9)
)
const recurrenceRule = new RRule({
freq: RRule.DAILY,
dtstart: startDate
freq: RRule.WEEKLY,
dtstart: startDate,
byweekday: [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR, RRule.SA, RRule.SU]
})

const newMeetingSeriesId = await insertMeetingSeriesQuery({
Expand All @@ -365,7 +376,7 @@ test('Should only start a new meeting if it would still be active', async () =>
id: meetingId,
teamId,
meetingCount: 0,
phases: [new TeamPromptResponsesPhase(['foobar'])],
phases: [new TeamPromptResponsesPhase([teamMemberId])],
facilitatorUserId: userId,
meetingPrompt: 'What are you working on today? Stuck on anything?',
scheduledEndTime: new Date(Date.now() - ms('73h')),
Expand Down Expand Up @@ -403,6 +414,7 @@ test('Should not start a new meeting if the rrule has not started', async () =>
const r = await getRethink()
const {userId} = await signUp()
const {id: teamId} = (await getUserTeams(userId))[0]
const teamMemberId = TeamMemberId.join(teamId, userId)

const now = new Date()

Expand All @@ -411,8 +423,9 @@ test('Should not start a new meeting if the rrule has not started', async () =>
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + 1, 9)
)
const recurrenceRule = new RRule({
freq: RRule.DAILY,
dtstart: startDate
freq: RRule.WEEKLY,
dtstart: startDate,
byweekday: [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR, RRule.SA, RRule.SU]
})

const newMeetingSeriesId = await insertMeetingSeriesQuery({
Expand All @@ -429,7 +442,7 @@ test('Should not start a new meeting if the rrule has not started', async () =>
id: meetingId,
teamId,
meetingCount: 0,
phases: [new TeamPromptResponsesPhase(['foobar'])],
phases: [new TeamPromptResponsesPhase([teamMemberId])],
facilitatorUserId: userId,
meetingPrompt: 'What are you working on today? Stuck on anything?',
scheduledEndTime: new Date(Date.now() - ms('1h')),
Expand Down Expand Up @@ -467,6 +480,7 @@ test('Should not hang if the rrule interval is invalid', async () => {
const r = await getRethink()
const {userId} = await signUp()
const {id: teamId} = (await getUserTeams(userId))[0]
const teamMemberId = TeamMemberId.join(teamId, userId)

const now = new Date()

Expand Down Expand Up @@ -495,7 +509,7 @@ test('Should not hang if the rrule interval is invalid', async () => {
id: meetingId,
teamId,
meetingCount: 0,
phases: [new TeamPromptResponsesPhase(['foobar'])],
phases: [new TeamPromptResponsesPhase([teamMemberId])],
facilitatorUserId: userId,
meetingPrompt: 'What are you working on today? Stuck on anything?',
scheduledEndTime: new Date(Date.now() - ms('5m')),
Expand Down

0 comments on commit 2139962

Please sign in to comment.