-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tools): create script to spam submissions
This commit is to be removed when merging into main.
- Loading branch information
1 parent
b2d72fd
commit 552f6f9
Showing
9 changed files
with
188 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,16 @@ | ||
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: {}, | ||
}, | ||
] | ||
})() |
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,8 @@ | ||
{ | ||
"name": "risk-form-filler", | ||
"type": "module", | ||
"description": "", | ||
"license": "", | ||
"sideEffects": false, | ||
"scripts": {} | ||
} |
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,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'] }, | ||
}, | ||
], | ||
}) |
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,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" | ||
} | ||
} | ||
} | ||
} |
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,6 @@ | ||
export interface ScheduleOnlineParams { | ||
name: string | ||
email: string | ||
subject: string | ||
message: string | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,9 @@ | ||
import type { ScheduleOnlineParams } from './input/schedule-online-params' | ||
|
||
import type { FormsLayout } from './pom' | ||
|
||
export async function scheduleOnline(params: ScheduleOnlineParams, formLayout: FormsLayout) { | ||
await formLayout.goto() | ||
await formLayout.fillContactPage(formLayout, params.name, params.email, params.subject, params.message) | ||
await formLayout.submitButton.click() | ||
} |
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,38 @@ | ||
import type { Locator, Page } from '@playwright/test' | ||
|
||
export class FormsLayout { | ||
// Page object | ||
readonly page: Page | ||
|
||
// textboxes | ||
readonly nameTextBox: Locator | ||
readonly emailTextBox: Locator | ||
readonly subjectTextBox: Locator | ||
readonly messageTextBox: Locator | ||
|
||
// buttons | ||
readonly submitButton: Locator | ||
|
||
constructor(page: Page) { | ||
this.page = page | ||
|
||
this.nameTextBox = page.getByPlaceholder('Your Name') | ||
this.emailTextBox = page.getByPlaceholder('Your Email') | ||
this.subjectTextBox = page.getByPlaceholder('Subject') | ||
this.messageTextBox = page.getByPlaceholder('Your Message') | ||
|
||
this.submitButton = page.getByRole('button', { name: 'Send Message' }) | ||
} | ||
|
||
// goto | ||
async goto() { | ||
await this.page.goto('http://localhost:3000/#contactpage') | ||
} | ||
|
||
async fillContactPage(formLayout: FormsLayout, NAME: string, EMAIL: string, SUBJECT: string, MESSAGE: string) { | ||
await formLayout.nameTextBox.fill(NAME) | ||
await formLayout.emailTextBox.fill(EMAIL) | ||
await formLayout.subjectTextBox.fill(SUBJECT) | ||
await formLayout.messageTextBox.fill(MESSAGE) | ||
} | ||
} |
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": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"outDir": "../../dist/out-tsc", | ||
"esModuleInterop": true | ||
}, | ||
"include": [ | ||
"**/*.ts", | ||
"**/*.js", | ||
"playwright.config.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.spec.js", | ||
"src/**/*.test.ts", | ||
"src/**/*.test.js", | ||
"src/**/*.d.ts" | ||
] | ||
} |