Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpgreen2 committed Dec 11, 2024
1 parent c2647d4 commit 5b08863
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions web-admin/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const config: PlaywrightTestConfig = {
webServer: {
command: "npm run build && npm run preview",
port: 4173,
timeout: 120_000,
},
};

Expand Down
32 changes: 24 additions & 8 deletions web-admin/tests/setup/test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import { test as base } from "@playwright/test";
import { waitUntil } from "@rilldata/web-common/lib/waitUtils";
import { spawn } from "node:child_process";
import path from "path";
import treeKill from "tree-kill";
import { fileURLToPath } from "url";

// Global setup
base.beforeAll(async () => {
console.log("Starting cloud services...");
const cloudProcess = spawn("rill", ["devtool", "start", "e2e", "--reset"], {
stdio: "pipe",
});
const timeout = 120_000;
base.setTimeout(timeout);

// Get the repository root directory, the only place from which `rill devtool` is allowed to be run
const currentDir = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(currentDir, "../../../");

// Start the cloud services (except for the UI, which is run by Playwright)
const cloudProcess = spawn(
"rill",
["devtool", "start", "e2e", "--reset", "--except", "ui"],
{
stdio: "pipe",
cwd: repoRoot,
},
);

// Capture output
let logBuffer = "";
Expand All @@ -22,16 +36,18 @@ base.beforeAll(async () => {
console.error(data.toString());
});

// Wait for services
await waitUntil(() => {
// Wait for services to be ready
const ready = await waitUntil(() => {
return logBuffer.includes("All services ready");
}, 1000);
}, timeout);
if (!ready) {
throw new Error("Cloud services did not start in time");
}

process.env.CLOUD_PID = cloudProcess.pid?.toString();
});

base.afterAll(() => {
console.log("Stopping cloud services...");
const pid = process.env.CLOUD_PID;
if (pid) {
treeKill(parseInt(pid));
Expand Down
4 changes: 3 additions & 1 deletion web-admin/tests/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import { test } from "./setup/test";

test("Unauthenticated user can see the login page", async ({ page }) => {
await page.goto("http://localhost:3000/");
await expect(page.getByText("Log in to Rill")).toBeVisible();
await expect(page.getByText("Log in to Rill")).toBeVisible({
timeout: 30_000, // TODO: It's slow because it's the vite dev server, not the built version
});
});

0 comments on commit 5b08863

Please sign in to comment.