Skip to content
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

feat(tools/risk-form-filler): automate filling out carleton's risk assessment form #179

Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fdf5b8b
feat(tools/risk-form-filler): create script
JeremyFriesenGitHub Nov 21, 2024
78a961a
chore(config/commitlint): add tools scope
JeremyFriesenGitHub Dec 4, 2024
9678f78
docs(tooling): update event risk management form filler demo
MFarabi619 Dec 10, 2024
b457a7e
refactor(tools/risk-form-filler): apply design patterns
MFarabi619 Dec 10, 2024
7e85dcc
refactor(tools/risk-form-filler): disable conditional and expect ESLi…
JeremyFriesenGitHub Dec 12, 2024
155edd8
refactor(tools/risk-form-filler): commented out eventParticipantsNumb…
JeremyFriesenGitHub Dec 12, 2024
e8dfbd7
refactor(tools/risk-form-filler): add online information config data
JeremyFriesenGitHub Dec 12, 2024
04ebde4
refactor(tools/risk-form-filler): add humanRights to sharedSections
JeremyFriesenGitHub Dec 12, 2024
2f6a5fc
refactor(risk-form-filler): commented out sharedSections fields and a…
JeremyFriesenGitHub Dec 12, 2024
1faa816
refactor(tools/risk-form-filler): comment out sharedSections actions …
JeremyFriesenGitHub Dec 12, 2024
f4f16eb
refactor(tools/risk-form-filler): add contractsInsurance to sharedSec…
JeremyFriesenGitHub Dec 12, 2024
8efaf3f
refactor(tools/risk-form-filler): distribute shared section actions a…
JeremyFriesenGitHub Dec 12, 2024
0250a74
style(tools/risk-form-filler): update comments on old pom
JeremyFriesenGitHub Dec 12, 2024
dd69a03
refactor(tools/risk-form-filler): specify shared vs non-shared action…
JeremyFriesenGitHub Dec 12, 2024
6580883
refactor(tools/risk-form-filler): uncomment humanRights otherRisks da…
JeremyFriesenGitHub Dec 12, 2024
af49898
refactor(tools/risk-form-filler): uncomment non-shared action fields …
JeremyFriesenGitHub Dec 12, 2024
b1a7015
refactor(tools/risk-form-filler): add speaker to shared actions
JeremyFriesenGitHub Dec 13, 2024
7c3eb4c
refactor(tools/risk-form-filler): add config data for speaker
JeremyFriesenGitHub Dec 13, 2024
420c3df
refactor(tools/risk-form-filler): fix errant speaker actions
JeremyFriesenGitHub Dec 13, 2024
645ece3
refactor(tools/risk-form-filler): create shared actions as base
JeremyFriesenGitHub Dec 13, 2024
f75bd8b
refactor(tools/risk-form-filler): fix errant actions for online infor…
JeremyFriesenGitHub Dec 13, 2024
8a1ffa0
refactor(tools/risk-form-filler): add proper locator names for online…
JeremyFriesenGitHub Dec 13, 2024
e7a538a
refactor(tools/risk-form-filler): split up classes into component files
MFarabi619 Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ icon: Braces
A number of tools developed internally are used to eliminate manual, repetitive work for other teams.

## Community Engagement
### Carleton University Room Booking
### [Event Risk Management Form](https://stuapps.carleton.ca/sarms/event-risk) Filler

[PR #197](https://github.com/cuhacking/2025/pull/179) in-progress by Jeremy Friesen.
Originally authored by [Jeremy Friesen](https://github.com/JeremyFriesenGitHub).

```
pnpm nx run risk-form-filler:e2e --ui
```

<video className="w-max h-[240px]" controls>
<source src="https://github.com/user-attachments/assets/8d01f3fc-d593-4830-98ae-c50cdb65c612" type="video/mp4" />
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const Configuration: UserConfig = {
'web-e2e',
'portal',
'portal-e2e',
'tools',
]],
// 'scope-empty': [2, 'never'], // Scope should always be provided

Expand Down
15 changes: 15 additions & 0 deletions tools/risk-form-filler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Workflow Execution Guide

To run the script, use either one of these commands in the CLI to run a specific workflow:

1. `pnpm nx run risk-form-filler:online` --> for submitting online events
2. `pnpm nx run risk-form-filler:in-person` --> for submitting in-person events
3. `pnpm nx run risk-form-filler:hybrid` --> for submitting hybrid events

This will compile and automatically run a workflow for that specifc type of form.

Be sure to change the input for that according workflow (for instance, change your hybrid input answers in src/input/hybrid-input.ts to something that is to your liking)

Note that although these forms automate answers, please make a review to ensure that all the information on the form is filled completely and accurate before submission.

Don't forget to end your session by pressing `CTRL C`.
19 changes: 19 additions & 0 deletions tools/risk-form-filler/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import playwright from 'eslint-plugin-playwright'
import baseConfigPromise from '../../eslint.config.js'

export default (async () => {
const baseConfig = await baseConfigPromise

return [
playwright.configs['flat/recommended'],
...baseConfig,
{
files: ['**/*.ts', '**/*.js'],
// Override or add rules here
rules: {
'playwright/no-conditional-in-test': 'off',
'playwright/expect-expect': 'off',
},
},
]
})()
8 changes: 8 additions & 0 deletions tools/risk-form-filler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "risk-form-filler",
"type": "module",
"description": "",
"license": "",
"sideEffects": false,
"scripts": {}
}
45 changes: 45 additions & 0 deletions tools/risk-form-filler/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// TODO: Investigate node global process usage

import { fileURLToPath } from 'node:url'
import { nxE2EPreset } from '@nx/playwright/preset'

import { defineConfig, devices } from '@playwright/test'

const __filename = fileURLToPath(import.meta.url)

// // For CI, you may want to set BASE_URL to the deployed application.
// const baseURL = process.env.BASE_URL || 'http://127.0.0.1:3000'

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
...nxE2EPreset(__filename, { testDir: './src' }),
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
retries: 2,
use: {
// baseURL,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'pnpm nx start risk-form-filler',
// // url: 'http://127.0.0.1:3000',
// // reuseExistingServer: !process.env.CI,
// cwd: workspaceRoot,
// timeout: 120 * 1000,
// },
projects: [
{
name: 'chromium (desktop)',
use: { ...devices['Desktop Chrome'] },
},
],
})
Comment on lines +22 to +45
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Configuration needs alignment with repository standards

The current Playwright configuration in tools/risk-form-filler needs adjustments to better align with established patterns in the repository:

  • Missing baseURL configuration which is present in other configs
  • Limited browser coverage compared to other configs (only Chrome)
  • Commented out webServer section needs proper configuration like other configs
  • Missing timeout in webServer configuration (present in docs-e2e)
🔗 Analysis chain

Verify configuration consistency across tools

Let's ensure this Playwright configuration aligns with other testing setups in the repository.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other Playwright configurations
fd -g 'playwright.config.*' . --exclude tools/risk-form-filler

# Check for other testing configurations
fd -g '*test*config*' . --exclude tools/risk-form-filler

Length of output: 232


Script:

#!/bin/bash
# Check the content of other Playwright configurations for comparison
echo "=== apps/docs-e2e/playwright.config.ts ==="
cat apps/docs-e2e/playwright.config.ts

echo -e "\n=== apps/website-e2e/playwright.config.ts ==="
cat apps/website-e2e/playwright.config.ts

Length of output: 4008

28 changes: 28 additions & 0 deletions tools/risk-form-filler/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "risk-form-filler",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "tools/risk-form-filler",
"projectType": "application",
"tags": [],
"// targets": "to see all targets run: nx show project risk-form-filler --web",
"targets": {
"online": {
"command": "npx tsx src/input/online-input.ts",
"options": {
"cwd": "tools/risk-form-filler"
}
},
"in-person": {
"command": "npx tsx src/input/in-person-input.ts",
"options": {
"cwd": "tools/risk-form-filler"
}
},
"hybrid": {
"command": "npx tsx src/input/hybrid-input.ts",
"options": {
"cwd": "tools/risk-form-filler"
}
}
}
}
324 changes: 324 additions & 0 deletions tools/risk-form-filler/src/action.spec.ts

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions tools/risk-form-filler/src/data/config.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
export class Config {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider converting the class to a plain object or namespace.

Classes with only static members are an anti-pattern in TypeScript. Consider refactoring this to either a plain object or namespace for better maintainability.

-export class Config {
+export const Config = {
   // ... rest of the code
-}
+} as const;

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Biome (1.9.4)

[error] 1-112: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

static LINK = {
BASE: 'https://stuapps.carleton.ca/sarms/event-risk',
IN_PERSON: 'in-person',
HYBRID: 'hybrid',
ONLINE: 'online',
}

static testData = {
primaryOrganizer: {
firstName: 'Raef',
lastName: 'Sarofiem',
carletonId: '101152872',
position: 'Community Engagement Lead',
role: 'Student',
email: '[email protected]',
emailConfirm: '[email protected]',
phone: '123-456-7890',
},
secondaryOrganizer: {
firstName: 'Ajaan',
lastName: 'Nalliah',
carletonId: '101151873',
position: 'Community Engagement',
role: 'Student',
email: '[email protected]',
phone: '123-456-7891',
},
generalEvent: {
eventTitle: 'cuHacking Weekly General Meeting',
eventDate: '2024-12-15',
eventStartTime: '18:00',
eventEndTime: '23:00',
eventDescription: 'cuHacking Weekly General Meeting',
eventLocation: 'NN 374',
eventLocationReserved: 'Yes',
eventParticipantsNumber: '20',
eventAudience: ['Carleton University Students', 'Staff and Faculty'],
eventFood: 'Yes',
eventFoodDetail: 'None',
eventHealthInsurance: 'No',
eventPhotoID: 'No',
eventMinors: 'No',
eventVIP: 'No',
},
riskManagement: {
alcohol: 'Yes',
smartServe: 'Yes',
entranceTicket: 'No',
food: 'Yes',
volunteers: {
volunteer1: 'Alice',
volunteer2: 'Bob',
volunteer3: 'Charlie',
},
campusSafety: 'Yes',
privateSecurity: 'No',
speaker: 'Yes',
topics: 'cuHacking',
names: 'Raef Sarofiem',
website: 'https://cuhacking.ca/',
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Move sensitive operational details to environment variables.

Risk management configuration contains sensitive details about security measures and alcohol service that shouldn't be in version control.

Consider using environment variables:

export const Config = {
  riskManagement: {
    alcohol: process.env.RISK_ALCOHOL ?? 'No',
    smartServe: process.env.RISK_SMART_SERVE ?? 'No',
    // ... other fields
  }
};

emergencyPreparedness: {
firstAid: 'Yes',
hospitalAwareness: 'Yes',
evacuationPlan: 'Yes',
openFlames: 'No',
},
safetyRiskAssessment: {
crowdControl: 'Yes',
crowdControlDetails: 'Monitors will control entrance/exit points.',
specialCircumstances: 'No',
additionalRisks: 'No',
},
contractsInsurance: {
vendorContracts: 'No',
liabilityInsurance: 'Yes',
insuranceInRental: 'Not Applicable',
insuranceCertificate: 'Yes',
},
travel: {
transportationRequired: 'Yes',
groupTransportation: 'No',
rentingVehicles: 'Yes',
insurance: 'Yes',
rentalDetails: {
companyName: 'Rent-A-Van Inc.',
companyAddress: '123 Main St, Ottawa, ON',
companyPhone: '123-456-7892',
additionalInfo: 'Insurance is fully covered in the rental fee.',
},
personalVehicles: 'No',
timesCommunicated: 'Yes',
contingencyPlan: 'Yes',
contingencyDetails: 'Plan includes backup transportation via taxis.',
alcoholOnboard: 'No',
intoxicatedIndividuals: 'No',
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Secure vendor information and transportation details

The travel section contains sensitive vendor information and detailed transportation plans that should not be in version control.

Consider using a secure configuration pattern:

interface VendorConfig {
  companyName: string;
  companyAddress: string;
  companyPhone: string;
  additionalInfo: string;
}

// Load from environment or secure config service
const getVendorConfig = (): VendorConfig => ({
  companyName: process.env.VENDOR_NAME ?? 'Test Vendor',
  companyAddress: process.env.VENDOR_ADDRESS ?? 'Test Address',
  companyPhone: process.env.VENDOR_PHONE ?? '000-000-0000',
  additionalInfo: process.env.VENDOR_INFO ?? 'Test Info'
});

outOfProvinceEvents: {
outOfProvince: 'Yes',
healthCoverage: 'Yes',
documentsAdvised: 'Yes',
},
maintenanceServices: {
garbageProvision: 'Yes',
cleanupCrew: 'Yes',
cleanupDetails: 'Volunteer group will clean up after the event.',
overnightSetup: 'No',
},
humanRights: {
rightsImplications: 'Yes',
rightsRisks: 'No',
otherRisks: 'None identified.',
},
onlineInformation: {
onlinePlatform: 'Zoom',
onlineTopic: 'cuHacking Weekly General Meeting',
onlineLocation: 'NN 374',
onlinePeople: '10',
onlineOriginAttendance: '5',
},
}
}
Loading
Loading