Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions quarto-cli.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"deno.enable": true,
"deno.unstable": true,
"deno.path": "./package/dist/bin/tools/deno",
"deno.disablePaths": ["./tests/integration/playwright"],
"deno.suggest.imports.hosts": {
"https://deno.land": true,
"https://den.o.land": false
Expand Down
14 changes: 0 additions & 14 deletions tests/integration/playwright-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ for (const { path: fileName } of globOutput) {
fileNames.push(fileName);
}

// start a web server
// This is attempt #3
// attempt #1 through Deno.server causes hangs on repeated requests
// attempt #2 through http/server causes a deno vendor crash: https://github.com/denoland/deno/issues/16861

// we'll just use python :facepalm:

const proc = Deno.run({
cmd: ["python", "-m", "http.server", "8080"],
cwd: "docs/playwright",
});

try {
// run playwright
Expand All @@ -62,9 +51,6 @@ try {
cwd: "integration/playwright",
});
} finally {
// cleanup
proc.kill();
proc.close();
for (const fileName of fileNames) {
cleanoutput(fileName, "html");
}
Expand Down
38 changes: 15 additions & 23 deletions tests/integration/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { PlaywrightTestConfig } from "@playwright/test";
import { devices } from "@playwright/test";
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
Expand All @@ -10,7 +9,8 @@ import { devices } from "@playwright/test";
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
export default defineConfig({
/* Look for test files in the "tests" directory, relative to this configuration file. */
testDir: "./tests",
/* Maximum time one test can run for. */
timeout: 30 * 1000,
Expand All @@ -33,36 +33,27 @@ const config: PlaywrightTestConfig = {
reporter: [["html", { open: "never" }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',
baseURL: 'http://127.0.0.1:8080',

/* 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"],
},
use: { ...devices['Desktop Chrome'] },
},

{
name: "firefox",
use: {
...devices["Desktop Firefox"],
},
use: {...devices["Desktop Firefox"] },
},

{
name: "webkit",
use: {
...devices["Desktop Safari"],
},
use: { ...devices["Desktop Safari"] },
},
/* Test against mobile viewports. */
// {
Expand Down Expand Up @@ -96,10 +87,11 @@ const config: PlaywrightTestConfig = {
// outputDir: 'test-results/',

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// port: 3000,
// },
};

export default config;
/* We use python for this but we could also try using another tool */
webServer: {
command: 'python -m http.server 8080',
url: 'http://127.0.0.1:8080',
reuseExistingServer: !process.env.CI,
cwd: '../../docs/playwright',
},
});
8 changes: 3 additions & 5 deletions tests/integration/playwright/tests/blog-simple-blog.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { expect, test } from "@playwright/test";

import { getUrl } from "../src/utils.js";

test('List.js is correctly patch to allow searching with lowercase and uppercase',
async ({ page }) => {
await page.goto(getUrl('blog/simple-blog/_site/'));
await page.goto('./blog/simple-blog/_site/');
await page.getByPlaceholder('Filter').click();
await page.getByPlaceholder('Filter').fill('Code');
await page.getByPlaceholder('Filter').press('Enter');
Expand All @@ -23,11 +21,11 @@ test('List.js is correctly patch to allow searching with lowercase and uppercase
});

test('Categories link are clickable', async ({ page }) => {
await page.goto(getUrl('blog/simple-blog/_site/posts/welcome/'));
await page.goto('./blog/simple-blog/_site/posts/welcome/');
await page.locator('div').filter({ hasText: /^news$/ }).click();
await expect(page).toHaveURL(/_site\/index\.html#category=news$/);
await expect(page.locator('div.category[data-category="news"]')).toHaveClass(/active/);
await page.goto(getUrl('blog/simple-blog/_site/posts/welcome/#img-lst'));
await page.goto('./blog/simple-blog/_site/posts/welcome/#img-lst');
await page.locator('div').filter({ hasText: /^news$/ }).click();
await expect(page).toHaveURL(/_site\/index\.html#category=news$/);
await expect(page.locator('div.category[data-category="news"]')).toHaveClass(/active/);
Expand Down
Loading