-
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
05a2732
commit c071089
Showing
20 changed files
with
290 additions
and
83 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 |
---|---|---|
@@ -1,31 +1,31 @@ | ||
/** @type { import("eslint").Linter.Config } */ | ||
module.exports = { | ||
root: true, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:svelte/recommended', | ||
'prettier' | ||
], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint'], | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaVersion: 2020, | ||
extraFileExtensions: ['.svelte'] | ||
}, | ||
env: { | ||
browser: true, | ||
es2017: true, | ||
node: true | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.svelte'], | ||
parser: 'svelte-eslint-parser', | ||
parserOptions: { | ||
parser: '@typescript-eslint/parser' | ||
} | ||
} | ||
] | ||
}; | ||
root: true, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:svelte/recommended", | ||
"prettier", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint"], | ||
parserOptions: { | ||
sourceType: "module", | ||
ecmaVersion: 2020, | ||
extraFileExtensions: [".svelte"], | ||
}, | ||
env: { | ||
browser: true, | ||
es2017: true, | ||
node: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["*.svelte"], | ||
parser: "svelte-eslint-parser", | ||
parserOptions: { | ||
parser: "@typescript-eslint/parser", | ||
}, | ||
}, | ||
], | ||
} |
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,51 @@ | ||
name: E2E Tests | ||
|
||
env: | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
POSTMARK_API_TOKEN: ${{ secrets.POSTMARK_API_TOKEN }} | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
playwright-tests: | ||
runs-on: ubuntu-latest | ||
env: | ||
POSTMARK_API_TOKEN: ${{ secrets.POSTMARK_API_TOKEN }} | ||
PUBLIC_UUID_NAMESPACE: ${{ secrets.PUBLIC_UUID_NAMESPACE }} | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
SHOW_PRIVATE_DATA_PARAM: ${{ secrets.SHOW_PRIVATE_DATA_PARAM }} | ||
EMAIL: ${{ secrets.EMAIL }} | ||
MOBILE_NUMBER: ${{ secrets.MOBILE_NUMBER }} | ||
ADDRESS: ${{ secrets.ADDRESS }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v1 | ||
|
||
- name: Install dependencies | ||
run: bun install | ||
|
||
- name: Install Playwright Browsers | ||
run: bunx playwright install --with-deps | ||
|
||
- name: Run Playwright tests | ||
run: bun test:e2e | ||
|
||
- name: Install Wrangler CLI | ||
if: always() | ||
run: npm install -g wrangler | ||
|
||
- name: Publish Playwright Report to Cloudflare Pages | ||
if: always() | ||
run: wrangler pages deploy ./playwright-report --project-name=dm-portfolio-e2e-status |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"semi": false, | ||
"trailingComma": "es5", | ||
"printWidth": 100, | ||
"plugins": ["prettier-plugin-svelte"], | ||
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] | ||
"semi": false, | ||
"trailingComma": "es5", | ||
"printWidth": 100, | ||
"plugins": ["prettier-plugin-svelte"], | ||
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] | ||
} |
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,41 @@ | ||
import { test, expect } from "@playwright/test" | ||
|
||
test("allows a user to submit a contact form", async ({ page }) => { | ||
await page.goto("/") | ||
|
||
await page.getByRole("link", { name: "Contact" }).click() | ||
|
||
await page.getByRole("textbox", { name: "Name", exact: true }).click() | ||
await page.getByRole("textbox", { name: "Name", exact: true }).fill("Joe Bloggs") | ||
await page.getByLabel("Email").click() | ||
await page.getByLabel("Email").fill("joe@bloggs.example") | ||
await page.getByLabel("Message").click() | ||
await page.getByLabel("Message").fill("Ah hey man, love your site.") | ||
await page.getByRole("button", { name: "Send message" }).click() | ||
|
||
await expect(page.getByText("Thank you for your message.")).toBeVisible() | ||
await expect(page.getByTestId("honeypot")).not.toBeVisible() | ||
}) | ||
|
||
test("pretends the form is submitted when a honeypot field is filled", async ({ page }) => { | ||
await page.goto("/") | ||
|
||
await page.getByRole("link", { name: "Contact" }).click() | ||
|
||
await page.getByRole("textbox", { name: "Name", exact: true }).click() | ||
await page.getByRole("textbox", { name: "Name", exact: true }).fill("Joe Bloggs") | ||
await page.getByLabel("Email").click() | ||
await page.getByLabel("Email").fill("joe@bloggs.example") | ||
await page.getByLabel("Message").click() | ||
await page | ||
.getByLabel("Message") | ||
.fill("Ah hey man, love your site. I'm definitely not a bot ... heh") | ||
await page.getByLabel("First name").fill("I'm a bot") | ||
await page.getByRole("button", { name: "Send message" }).click() | ||
|
||
// Pretend message is sent | ||
await expect(page.getByText("Thank you for your message.")).toBeVisible() | ||
|
||
// Honeypot testid is visible | ||
await expect(page.getByTestId("honeypot")).toBeVisible() | ||
}) |
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
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,46 @@ | ||
import dotenv from "dotenv" | ||
import { defineConfig, devices } from "@playwright/test" | ||
|
||
dotenv.config({ path: ".env.test" }) | ||
|
||
const port = 7777 | ||
|
||
export default defineConfig({ | ||
testDir: "./__tests__", | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: [["html", { outputDir: "./playwright-report" }]], | ||
use: { trace: "on" }, | ||
projects: [ | ||
{ | ||
name: "chromium", | ||
use: { | ||
...devices["Desktop Chrome"], | ||
contextOptions: { reducedMotion: "reduce" }, | ||
}, | ||
}, | ||
{ | ||
name: "firefox", | ||
use: { | ||
...devices["Desktop Firefox"], | ||
contextOptions: { reducedMotion: "reduce" }, | ||
}, | ||
}, | ||
{ | ||
name: "webkit", | ||
use: { | ||
...devices["Desktop Safari"], | ||
contextOptions: { reducedMotion: "reduce" }, | ||
}, | ||
}, | ||
], | ||
webServer: { | ||
command: process.env.CI | ||
? `bun run build && bunx vite preview --port ${port}` | ||
: `VITE_PORT=${port} bun dev`, | ||
port, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}) |
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
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
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
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
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
Oops, something went wrong.