From 4885c94b720351d48b08778ac05591e170b537f2 Mon Sep 17 00:00:00 2001 From: Firehose Bot Date: Mon, 13 Jul 2026 15:01:19 +0100 Subject: [PATCH] old conflicts and version update --- app/assets/package-lock.json | 66 ++++++++++++++++++++++++++++- app/assets/package.json | 3 +- app/playwright.config.ts | 58 ------------------------- app/test/e2e/auth-helpers.ts | 41 ------------------ app/test/e2e/auth.spec.ts | 33 --------------- app/test/e2e/fixtures.ts | 28 ------------ app/test/e2e/smoke.spec.ts | 29 ------------- blogex/lib/blogex/blog.ex | 4 +- blogex/lib/blogex/link_validator.ex | 1 - 9 files changed, 70 insertions(+), 193 deletions(-) delete mode 100644 app/playwright.config.ts delete mode 100644 app/test/e2e/auth-helpers.ts delete mode 100644 app/test/e2e/auth.spec.ts delete mode 100644 app/test/e2e/fixtures.ts delete mode 100644 app/test/e2e/smoke.spec.ts diff --git a/app/assets/package-lock.json b/app/assets/package-lock.json index ceb8f73..bc6fc07 100644 --- a/app/assets/package-lock.json +++ b/app/assets/package-lock.json @@ -9,7 +9,41 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "highlight.js": "^11.11.1" + "highlight.js": "^11.11.1", + "playwright": "^1.61.1" + }, + "devDependencies": { + "@playwright/test": "^1.60.0" + } + }, + "node_modules/@playwright/test": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.61.1.tgz", + "integrity": "sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.61.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, "node_modules/highlight.js": { @@ -20,6 +54,36 @@ "engines": { "node": ">=12.0.0" } + }, + "node_modules/playwright": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.61.1.tgz", + "integrity": "sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ==", + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.61.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.61.1.tgz", + "integrity": "sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg==", + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } } } } diff --git a/app/assets/package.json b/app/assets/package.json index 80cdbdb..92307e7 100644 --- a/app/assets/package.json +++ b/app/assets/package.json @@ -16,6 +16,7 @@ "@playwright/test": "^1.60.0" }, "dependencies": { - "highlight.js": "^11.11.1" + "highlight.js": "^11.11.1", + "playwright": "^1.61.1" } } diff --git a/app/playwright.config.ts b/app/playwright.config.ts deleted file mode 100644 index 0c37a96..0000000 --- a/app/playwright.config.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { defineConfig, devices } from "@playwright/test"; - -// Default Playwright e2e configuration. -// -// Uses Firefox by default (Playwright Chromium crashes on macOS 15 -// due to Crashpad permission restrictions). -// -// ## Usage -// -// make playwright # run with default browser (Firefox) -// PLAYWRIGHT_BROWSER=chromium make playwright -// PLAYWRIGHT_BROWSER=webkit make playwright -// -// # Run a single test file: -// PLAYWRIGHT_BROWSERS_PATH=assets/node_modules/playwright-core/.local-browsers \ -// npx playwright test --config=playwright.config.ts test/e2e/smoke.spec.ts -// -// ## Docker Chrome (alternative) -// -// Use playwright.docker.config.ts instead of this config: -// -// docker compose -f docker-compose.chrome.yml up -d -// npx playwright test --config=playwright.docker.config.ts - -const browserEnv = process.env.PLAYWRIGHT_BROWSER || "firefox"; - -const deviceFor = (name: string) => { - switch (name) { - case "chromium": return devices["Desktop Chrome"]; - case "firefox": return devices["Desktop Firefox"]; - case "webkit": return devices["Desktop Safari"]; - default: - console.warn(`Unknown browser "${name}", falling back to Firefox`); - return devices["Desktop Firefox"]; - } -}; - -export default defineConfig({ - testDir: "./test/e2e", - fullyParallel: true, - forbidOnly: !!process.env.CI, - retries: process.env.CI ? 2 : 0, - workers: process.env.CI ? 1 : undefined, - reporter: "list", - - use: { - baseURL: process.env.PLAYWRIGHT_BASE_URL || "http://localhost:8056", - trace: "on-first-retry", - headless: process.env.PLAYWRIGHT_HEADLESS !== "false", - }, - - projects: [ - { - name: browserEnv, - use: { ...deviceFor(browserEnv) }, - }, - ], -}); \ No newline at end of file diff --git a/app/test/e2e/auth-helpers.ts b/app/test/e2e/auth-helpers.ts deleted file mode 100644 index 9f21b62..0000000 --- a/app/test/e2e/auth-helpers.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Auth helpers for Playwright e2e tests. - * - * Provides utilities for logging in as a test user. - * The app uses email-only registration (magic-link flow for initial confirmation) - * and email+password for subsequent logins. - */ - -import { Page } from "@playwright/test"; - -export const TEST_USER = { - email: process.env.PLAYWRIGHT_EMAIL || "test@firehose.test", - password: process.env.PLAYWRIGHT_PASSWORD || "testpassword123!", -}; - -/** - * Navigate to the login page, fill in credentials, and submit. - * Returns the page after successful login (redirected to home). - */ -export async function loginAsTestUser(page: Page) { - await page.goto("/users/log-in"); - // Use the password-based login form - await page.getByLabel("Email").fill(TEST_USER.email); - await page.getByLabel("Password").fill(TEST_USER.password); - // Click "Log in and stay logged in" - await page.getByRole("button", { name: /log in and stay logged in/i }).click(); - await page.waitForURL("/"); -} - -/** - * Navigate to the registration page, fill in email, and submit. - * Note: In dev mode, registration is invite-only by default. Set - * `PLAYWRIGHT_ALLOW_REGISTRATION=true` to run tests against a server - * with open registration enabled. - */ -export async function registerTestUser(page: Page) { - await page.goto("/users/register"); - await page.getByLabel("Email").fill(TEST_USER.email); - await page.getByRole("button", { name: /create an account/i }).click(); - await page.waitForURL("/users/log-in"); -} \ No newline at end of file diff --git a/app/test/e2e/auth.spec.ts b/app/test/e2e/auth.spec.ts deleted file mode 100644 index 605903c..0000000 --- a/app/test/e2e/auth.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { test, expect } from "./fixtures"; -import { loginAsTestUser } from "./auth-helpers"; - -test.describe("Authenticated pages", () => { - test("redirects unauthenticated users to login page", async ({ page }) => { - const response = await page.goto("/editor/dashboard"); - // Should redirect to login - expect(response?.url()).toContain("/users/log-in"); - }); - - test("can log in and access the editor dashboard", async ({ page }) => { - await loginAsTestUser(page); - - // After login, we should be on the home page - await expect(page).toHaveURL("/"); - await expect(page.locator("body")).not.toBeEmpty(); - }); - - test("can log out", async ({ page }) => { - await loginAsTestUser(page); - - // Now log out - await page.goto("/users/log-out"); - - // Should redirect to home - await expect(page).toHaveURL("/"); - - // Try accessing an authenticated page - await page.goto("/editor/dashboard"); - // Should redirect to login - await expect(page).toHaveURL(/\/users\/log-in/); - }); -}); \ No newline at end of file diff --git a/app/test/e2e/fixtures.ts b/app/test/e2e/fixtures.ts deleted file mode 100644 index 7c411c9..0000000 --- a/app/test/e2e/fixtures.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Custom Playwright test fixtures. - * - * Provides a `test` function that connects to a remote Chrome via CDP - * when PLAYWRIGHT_CDP_URL is set (Docker Chrome mode). - * Falls back to the default local browser otherwise. - */ - -import { test as base, chromium } from "@playwright/test"; - -type Fixtures = { - // Browser is provided by Playwright Test by default. - // We only override it when connecting to remote Docker Chrome. -}; - -const cdpUrl = process.env.PLAYWRIGHT_CDP_URL; - -export const test = cdpUrl - ? base.extend({ - browser: async ({}, use) => { - const browser = await chromium.connectOverCDP(cdpUrl); - await use(browser); - await browser.close(); - }, - }) - : base; - -export { expect } from "@playwright/test"; \ No newline at end of file diff --git a/app/test/e2e/smoke.spec.ts b/app/test/e2e/smoke.spec.ts deleted file mode 100644 index 241528e..0000000 --- a/app/test/e2e/smoke.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { test, expect } from "./fixtures"; - -test.describe("Connectivity smoke test", () => { - test("visits the homepage and verifies it loads", async ({ page }) => { - const response = await page.goto("/"); - expect(response?.ok()).toBeTruthy(); - - // Verify the page has content - await expect(page).toHaveTitle(/Firehose/); - }); - - test("visits the contact page", async ({ page }) => { - const response = await page.goto("/contact"); - expect(response?.ok()).toBeTruthy(); - await expect(page.locator("body")).not.toBeEmpty(); - }); - - test("visits the blog engineering index", async ({ page }) => { - const response = await page.goto("/blog/engineering"); - expect(response?.ok()).toBeTruthy(); - await expect(page.locator("body")).not.toBeEmpty(); - }); - - test("visits the blog releases index", async ({ page }) => { - const response = await page.goto("/blog/releases"); - expect(response?.ok()).toBeTruthy(); - await expect(page.locator("body")).not.toBeEmpty(); - }); -}); \ No newline at end of file diff --git a/blogex/lib/blogex/blog.ex b/blogex/lib/blogex/blog.ex index 7741d70..c74fd48 100644 --- a/blogex/lib/blogex/blog.ex +++ b/blogex/lib/blogex/blog.ex @@ -153,7 +153,9 @@ defmodule Blogex.Blog do def _validate_links(posts, blog_id) do Enum.each(posts, fn post -> case Blogex.LinkValidator.validate_body(post.body, blog_id, post_id: post.id) do - :ok -> :ok + :ok -> + :ok + {:error, errors} -> raise Blogex.LinkError, blog: blog_id, diff --git a/blogex/lib/blogex/link_validator.ex b/blogex/lib/blogex/link_validator.ex index 48c0779..36e6ef5 100644 --- a/blogex/lib/blogex/link_validator.ex +++ b/blogex/lib/blogex/link_validator.ex @@ -174,7 +174,6 @@ defmodule Blogex.LinkValidator do end end - # --- Private helpers --- @doc false