-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
26 changed files
with
423 additions
and
65 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 +1 @@ | ||
NODE_ENV=development | ||
BUILD_TYPE=development |
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 +1,2 @@ | ||
VITE_SENTRY_DSN="https://0b9cdcee8d8040edb9cc9586ecb52a14@o1296550.ingest.sentry.io/6556279" | ||
BUILD_TYPE="production" |
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 @@ | ||
BUILD_TYPE=test |
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,27 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- name: Install dependencies | ||
run: npm install -g pnpm && pnpm install | ||
- name: Install Playwright Browsers | ||
run: pnpm exec playwright install --with-deps | ||
- name: Run Playwright tests | ||
run: pnpm exec playwright test | ||
- uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
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,4 +1,4 @@ | ||
{ | ||
"plugins": ["prettier-plugin-svelte"], | ||
"plugins": ["prettier-plugin-svelte", "prettier-plugin-organize-imports"], | ||
"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,124 @@ | ||
import { test, expect, Page } from "@playwright/test"; | ||
|
||
test("Options page", async ({ page }) => { | ||
await test.step("Navigate to options page", async () => { | ||
await page.goto("/options-mock.html"); | ||
}); | ||
|
||
await test.step("Check useful UI elements", async () => { | ||
await testUsefulUI(page); | ||
}); | ||
|
||
await test.step("Test pinned tabs inputs", async () => { | ||
await testPinnedTabsInputs(page); | ||
}); | ||
|
||
await test.step("Test auto-open tabs toggle", async () => { | ||
await testAutoOpenTabsToggle(page); | ||
}); | ||
}); | ||
|
||
async function testUsefulUI(page: Page) { | ||
await expect(page).toHaveTitle("Pin-It Extension Options"); | ||
await expect(page.getByRole("heading", { name: "Options" })).toBeVisible(); | ||
await expect( | ||
page.getByRole("link", { name: "Learn more here" }), | ||
).toBeVisible(); | ||
await expect(page.getByLabel("Buy me a coffee")).toBeVisible(); | ||
} | ||
|
||
async function testPinnedTabsInputs(page: Page) { | ||
const loading = await page.getByText("Loading"); | ||
await expect(loading).not.toBeVisible(); | ||
|
||
const firstInputElement = await page.getByPlaceholder("Enter a URL").nth(0); | ||
await expect(firstInputElement).toBeVisible(); | ||
const firstDeleteButton = await page | ||
.getByRole("button", { name: "Delete" }) | ||
.nth(0); | ||
await expect(firstDeleteButton).toBeVisible(); | ||
|
||
const addURLButton = await page.getByRole("button", { name: "Add URL" }); | ||
await expect(addURLButton).toBeVisible(); | ||
|
||
// Check initial state | ||
await expect(firstInputElement).toHaveValue(""); | ||
await expect(firstDeleteButton).toBeDisabled(); | ||
|
||
// Test adding some text to first input | ||
await firstInputElement.fill("https://www.gaunt.dev"); | ||
await expect(firstInputElement).toHaveValue("https://www.gaunt.dev"); | ||
await expect(firstDeleteButton).toBeEnabled(); | ||
|
||
// Test deleting the text | ||
await firstDeleteButton.click(); | ||
await expect(firstInputElement).toHaveValue(""); | ||
|
||
// Test adding some text and keeping it | ||
await firstInputElement.fill("https://www.gaunt.dev"); | ||
await expect(firstInputElement).toHaveValue("https://www.gaunt.dev"); | ||
await expect(firstDeleteButton).toBeEnabled(); | ||
await expect(loading).toBeVisible(); | ||
|
||
// Test adding a second input | ||
await addURLButton.click(); | ||
|
||
const secondInputElement = await page.getByPlaceholder("Enter a URL").nth(1); | ||
await expect(secondInputElement).toBeVisible(); | ||
|
||
const secondDeleteButton = await page | ||
.getByRole("button", { name: "Delete" }) | ||
.nth(1); | ||
await expect(secondDeleteButton).toBeVisible(); | ||
|
||
// Test filling the second input | ||
await secondInputElement.fill("https://www.gaunt.dev/projects/pin-it/"); | ||
await expect(loading).toBeHidden({ timeout: 5000 }); | ||
|
||
// Test deleting the first input | ||
await firstDeleteButton.click(); | ||
|
||
// Only one input should be shown | ||
await expect(firstInputElement).toBeVisible(); | ||
await expect(firstDeleteButton).toBeVisible(); | ||
await expect(secondInputElement).not.toBeVisible(); | ||
await expect(secondInputElement).not.toBeVisible(); | ||
|
||
await expect(firstInputElement).toHaveValue( | ||
"https://www.gaunt.dev/projects/pin-it/", | ||
); | ||
await expect(firstDeleteButton).toBeEnabled(); | ||
|
||
// Test deleting the first input | ||
await firstDeleteButton.click(); | ||
await expect(firstInputElement).toBeVisible(); | ||
await expect(firstDeleteButton).toBeVisible(); | ||
await expect(firstInputElement).toHaveValue(""); | ||
await expect(firstDeleteButton).toBeDisabled(); | ||
await expect(loading).toBeHidden({ timeout: 5000 }); | ||
} | ||
|
||
async function testAutoOpenTabsToggle(page: Page) { | ||
const loading = await page.getByText("Loading"); | ||
await expect(loading).not.toBeVisible(); | ||
|
||
const toggleLabel = await page.getByText( | ||
"Automatically open tabs when a new window is opened", | ||
); | ||
await expect(toggleLabel).toBeVisible(); | ||
|
||
const checkbox = await page.getByTestId("auto-open-tabs-checkbox"); | ||
await expect(checkbox).not.toBeChecked(); | ||
|
||
await toggleLabel.click(); | ||
await expect(checkbox).toBeChecked(); | ||
|
||
await expect(loading).toBeVisible(); | ||
await expect(loading).toBeHidden({ timeout: 5000 }); | ||
|
||
await toggleLabel.click(); | ||
await expect(checkbox).not.toBeChecked(); | ||
|
||
await expect(loading).toBeVisible(); | ||
await expect(loading).toBeHidden({ timeout: 5000 }); | ||
} |
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,80 @@ | ||
import { defineConfig, devices } from "@playwright/test"; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// import path from 'path'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: "./e2e", | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: "html", | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: "http://127.0.0.1:3000", | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: "on-first-retry", | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: "chromium", | ||
use: { ...devices["Desktop Chrome"] }, | ||
}, | ||
|
||
{ | ||
name: "firefox", | ||
use: { ...devices["Desktop Firefox"] }, | ||
}, | ||
|
||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: "pnpm run test:server", | ||
url: "http://127.0.0.1:3000", | ||
reuseExistingServer: !process.env.CI, | ||
timeout: 30 * 1000, | ||
}, | ||
}); |
Oops, something went wrong.