-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b453e5
commit 7257ada
Showing
30 changed files
with
617 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,11 @@ | ||
# test-helpers | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Building | ||
|
||
Run `nx build test-helpers` to build the library. | ||
|
||
## Running unit tests | ||
|
||
Run `nx test test-helpers` to execute the unit tests via [Jest](https://jestjs.io). |
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,5 @@ | ||
{ | ||
"name": "@rovacc/test-helpers", | ||
"version": "0.0.1", | ||
"type": "commonjs" | ||
} |
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,31 @@ | ||
{ | ||
"name": "test-helpers", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/test-helpers/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/vite:build", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/libs/test-helpers" | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/vite:test", | ||
"outputs": ["coverage/libs/test-helpers"], | ||
"options": { | ||
"passWithNoTests": true, | ||
"reportsDirectory": "../../coverage/libs/test-helpers" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["libs/test-helpers/**/*.ts"] | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
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,15 @@ | ||
export async function deleteCollection(collectionPath: string) { | ||
const endpoint = process.env['FIRESTORE_EMULATOR_HOST'] as string | ||
const project = process.env['GCLOUD_PROJECT'] as string | ||
|
||
const response = await fetch( | ||
`http://${endpoint}/emulator/v1/projects/${project}/databases/(default)/documents/${collectionPath}`, | ||
{ | ||
method: 'DELETE', | ||
} | ||
); | ||
if (response.status !== 200) { | ||
throw new Error('Trouble clearing Emulator: ' + (await response.text())); | ||
} | ||
} | ||
|
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 @@ | ||
export { deleteCollection } from './delete-collection' |
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,2 @@ | ||
export * from './firestore' | ||
export * from './training/events' |
22 changes: 22 additions & 0 deletions
22
libs/test-helpers/src/training/events/build-training-completed-event.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,22 @@ | ||
import { TrainingCompletedEvent, TrainingCompletedEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingCompletedEventData['payload']> | ||
} | ||
|
||
export const buildTrainingCompletedEvent = (args: Args): TrainingCompletedEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-completed', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
reason: 'completed', | ||
reasonDetailed: 'rating_upgraded', | ||
...args.override | ||
} | ||
}) |
32 changes: 32 additions & 0 deletions
32
libs/test-helpers/src/training/events/build-training-cpt-performed-event.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,32 @@ | ||
import { TrainingCptPerformedEvent, TrainingCptPerformedEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingCptPerformedEventData['payload']> | ||
} | ||
|
||
export const buildTrainingCptPerformedEvent = (args: Args): TrainingCptPerformedEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-cpt-performed', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
assessedBy: { | ||
id: 200200, | ||
name: 'member-name' | ||
}, | ||
report: { | ||
purpose: "cpt_ots", | ||
workload: "light", | ||
complexity: "routine", | ||
traffic: "light", | ||
comments: 'Session went well' | ||
}, | ||
passed: true, | ||
...args.override | ||
} | ||
}) |
21 changes: 21 additions & 0 deletions
21
libs/test-helpers/src/training/events/build-training-cpt-requested-event.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,21 @@ | ||
import { TrainingCptRequestedEvent } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingCptRequestedEvent['payload']> | ||
} | ||
|
||
export const buildTrainingCptRequestedEvent = (args: Args): TrainingCptRequestedEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-cpt-requested', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
requestedBy: { id: 123123, name: 'Requested By Name' }, | ||
...args.override | ||
} | ||
}) |
21 changes: 21 additions & 0 deletions
21
libs/test-helpers/src/training/events/build-training-cpt-scheduled-event.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,21 @@ | ||
import { TrainingCptScheduledEvent } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingCptScheduledEvent['payload']> | ||
} | ||
|
||
export const buildTrainingCptScheduledEvent = (args: Args): TrainingCptScheduledEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-cpt-scheduled', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
scheduledAt: new Date(), | ||
...args.override | ||
} | ||
}) |
19 changes: 19 additions & 0 deletions
19
libs/test-helpers/src/training/events/build-training-intent-confirmation-expired-event.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,19 @@ | ||
import { TrainingIntentConfirmationExpiredEvent, TrainingIntentConfirmationExpiredEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingIntentConfirmationExpiredEventData['payload']> | ||
} | ||
|
||
export const buildTrainingIntentConfirmationExpiredEvent = | ||
(args: Args): TrainingIntentConfirmationExpiredEvent => ({ | ||
name: 'training-intent-confirmation-expired', | ||
trainingId: args.trainingId, | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: {}, | ||
}) |
19 changes: 19 additions & 0 deletions
19
libs/test-helpers/src/training/events/build-training-intent-confirmation-rejected-event.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,19 @@ | ||
import { TrainingIntentConfirmationRejectedEvent, TrainingIntentConfirmationRejectedEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingIntentConfirmationRejectedEventData['payload']> | ||
} | ||
|
||
export const buildTrainingIntentConfirmationRejectedEvent = | ||
(args: Args): TrainingIntentConfirmationRejectedEvent => ({ | ||
name: 'training-intent-confirmation-rejected', | ||
trainingId: args.trainingId, | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: {}, | ||
}) |
18 changes: 18 additions & 0 deletions
18
libs/test-helpers/src/training/events/build-training-intent-confirmation-requested-event.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,18 @@ | ||
import { TrainingIntentConfirmationRequestedEvent, TrainingIntentConfirmationRequestedEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingIntentConfirmationRequestedEventData['payload']> | ||
} | ||
|
||
export const buildTrainingIntentConfirmationRequestedEvent = (args: Args): TrainingIntentConfirmationRequestedEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-intent-confirmation-requested', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: {} | ||
}) |
18 changes: 18 additions & 0 deletions
18
libs/test-helpers/src/training/events/build-training-intent-confirmation-responded-event.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,18 @@ | ||
import { TrainingIntentConfirmationRespondedEvent, TrainingIntentConfirmationRespondedEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingIntentConfirmationRespondedEventData['payload']> | ||
} | ||
|
||
export const buildTrainingIntentConfirmationRespondedEvent = (args: Args): TrainingIntentConfirmationRespondedEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-intent-confirmation-responded', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: {} | ||
}) |
23 changes: 23 additions & 0 deletions
23
libs/test-helpers/src/training/events/build-training-intent-event.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,23 @@ | ||
import { TrainingIntentEvent } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingIntentEvent> | ||
} | ||
|
||
export const buildTrainingIntentEvent = (args: Args): TrainingIntentEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-intent', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
student: 123123123, | ||
rating: 2, | ||
purpose: 'acquire_rating', | ||
...args.override | ||
} | ||
}) |
22 changes: 22 additions & 0 deletions
22
libs/test-helpers/src/training/events/build-training-mentor-assigned-event.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,22 @@ | ||
import { TrainingMentorAssignedEvent, TrainingMentorAssignedEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingMentorAssignedEventData['payload']> | ||
} | ||
|
||
export const buildTrainingMentorAssignedEvent = (args: Args): TrainingMentorAssignedEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-mentor-assigned', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
mentor: { id: 200000, name: 'Mentor Name' }, | ||
assignedBy: { id: 200200, name: 'Assigned By Name' }, | ||
...args.override | ||
} | ||
}) |
22 changes: 22 additions & 0 deletions
22
libs/test-helpers/src/training/events/build-training-mentor-reassigned-event.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,22 @@ | ||
import { TrainingMentorReassignedEvent, TrainingMentorReassignedEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingMentorReassignedEventData['payload']> | ||
} | ||
|
||
export const buildTrainingMentorReassignedEvent = (args: Args): TrainingMentorReassignedEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-mentor-reassigned', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
mentor: { id: 200000, name: 'Mentor Name' }, | ||
assignedBy: { id: 200200, name: 'Assigned By Name' }, | ||
...args.override | ||
} | ||
}) |
29 changes: 29 additions & 0 deletions
29
libs/test-helpers/src/training/events/build-training-session-performed-event.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,29 @@ | ||
import { TrainingSessionPerformedEvent, TrainingSessionPerformedEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingSessionPerformedEventData['payload']> | ||
} | ||
|
||
export const buildTrainingSessionPerformedEvent = (args: Args): TrainingSessionPerformedEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-session-performed', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
sessionId: 'session-id', | ||
mentor: { id: 200000, name: 'Mentor Name' }, | ||
report: { | ||
purpose: "cpt_ots", | ||
workload: "light", | ||
complexity: "routine", | ||
traffic: "light", | ||
comments: 'Session went well' | ||
}, | ||
...args.override | ||
} | ||
}) |
22 changes: 22 additions & 0 deletions
22
libs/test-helpers/src/training/events/build-training-session-scheduled-event.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,22 @@ | ||
import { TrainingSessionScheduledEvent, TrainingSessionScheduledEventData } from '@rovacc/training-events-types' | ||
|
||
type Args = { | ||
trainingId: string, | ||
eventId?: string, | ||
emittedAt?: Date, | ||
override?: Partial<TrainingSessionScheduledEventData['payload']> | ||
} | ||
|
||
export const buildTrainingSessionScheduledEvent = (args: Args): TrainingSessionScheduledEvent => ({ | ||
trainingId: args.trainingId, | ||
name: 'training-session-scheduled', | ||
eventId: args.eventId ?? 'event-id', | ||
emittedAt: args.emittedAt ?? new Date(), | ||
system: 'rovacc-system-id', | ||
correlationId: 'correlationId', | ||
payload: { | ||
sessionId: 'session-id', | ||
scheduledAt: new Date(), | ||
...args.override | ||
} | ||
}) |
Oops, something went wrong.