* Rust backend: initial setup and space primitives implementation + tests * Rust: initial basic server setup * Rust server: auth layer * Rust: added specific auth layers * Rust: shell and proxy endpoints * Rust: SSR and Prometheus metrics * Rust: runtime API * Rust: basic working silverbullet binary server * Rust: fix client file caching * Rust: in dev mode, update version number dynamically * Rust: build-rs Makefile target * Rust: auth and start of 'sb' CLI * Rust: headless Chrome runtime runner * Rust: basic e2e tests for Rust build * Rust: docker builds * Rust: forgot to commit silverbullet-bin code * Rust: cross compile and chrome driver fixes * Rust: waiting for ready status fixes * Rust: sb-CLI port * Rust: use native build toolchain * Rust: fix build chain * Rust: edge release builds * Rust: FreeBSD and armv7 builds * Rust: edge-upgrade from edge-rust release * Rust: fix FreeBSD build * Rust: fix FreeBSD build * Rust: get rid of Go code * refactor: rename library crates to server- prefix convention * Rust: refactoring, moving crypto around * Rust: more refactoring * Runtime: internal renaming * Fix: cursor placement after paste on Webkit browsers * Tweak how version numbers are generated and consumed * Cleanup CI situation * Fix CI * Fix e2e * ci: website image uses :edge channel (was :v2) post-merge * Rust: restore manifest.json endpoint * Rust: ready to merge
92 lines
3.3 KiB
TypeScript
92 lines
3.3 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { type ReleaseServer, startReleaseServer } from "./release-fixtures.ts";
|
|
|
|
/**
|
|
* These tests run against the standalone `target/release/silverbullet` binary,
|
|
* which serves the client and plug assets from the rust-embed embedded base
|
|
* filesystem. They therefore validate that the *embedded* bundle boots and
|
|
* that the browser login flow works. A release binary must be built first
|
|
* (`make build-rs`); see the `test-e2e-release` Makefile target.
|
|
*/
|
|
test.describe("Release binary: embedded bundle", () => {
|
|
let server: ReleaseServer | undefined;
|
|
|
|
test.afterEach(async () => {
|
|
await server?.stop();
|
|
server = undefined;
|
|
});
|
|
|
|
test("embedded bundle boots and the editor works", async ({ page }) => {
|
|
server = await startReleaseServer();
|
|
|
|
await page.goto(`${server.url}/index?headless=1`);
|
|
await page.locator("#sb-editor .cm-editor").waitFor({
|
|
state: "visible",
|
|
timeout: 30_000,
|
|
});
|
|
await page.waitForFunction(
|
|
() => (globalThis as any).sbRuntime?.ready === true,
|
|
undefined,
|
|
{ timeout: 30_000 },
|
|
);
|
|
|
|
// The embedded bundle ships the welcome content on an empty space.
|
|
const editor = page.locator("#sb-editor .cm-content");
|
|
await expect(editor).toBeVisible();
|
|
await expect(editor).toContainText(
|
|
"Welcome to the wondrous world of SilverBullet",
|
|
);
|
|
|
|
// Type some text and confirm it persists across a reload.
|
|
await editor.click();
|
|
await page.keyboard.press("End");
|
|
await page.keyboard.press("Enter");
|
|
await page.keyboard.type("Hello from the embedded bundle");
|
|
await expect(editor).toContainText("Hello from the embedded bundle");
|
|
|
|
// Wait for the save round-trip to the server, then read it back via the
|
|
// filesystem API to prove the edit was persisted by the release binary.
|
|
const pageNameSel = "#sb-current-page";
|
|
await page.locator(`${pageNameSel}.sb-unsaved`).waitFor({
|
|
state: "attached",
|
|
timeout: 10_000,
|
|
});
|
|
await page.locator(`${pageNameSel}.sb-saved`).waitFor({
|
|
state: "attached",
|
|
timeout: 10_000,
|
|
});
|
|
|
|
const resp = await fetch(`${server.url}/.fs/index.md`);
|
|
expect(resp.ok).toBe(true);
|
|
const content = await resp.text();
|
|
expect(content).toContain("Hello from the embedded bundle");
|
|
});
|
|
|
|
test("browser login flow", async ({ page }) => {
|
|
server = await startReleaseServer({ SB_USER: "alice:s3cret" });
|
|
|
|
// An unauthenticated browser hitting a protected page is redirected to
|
|
// the login page.
|
|
await page.goto(`${server.url}/`);
|
|
await expect(page.locator("#username")).toBeVisible({ timeout: 30_000 });
|
|
await expect(page.locator("#password")).toBeVisible();
|
|
|
|
// Log in with the configured credentials.
|
|
await page.locator("#username").fill("alice");
|
|
await page.locator("#password").fill("s3cret");
|
|
await page.locator("#login").getByRole("button", { name: "Login" }).click();
|
|
|
|
// On success the login script redirects into the app; the editor should
|
|
// become visible once the client has booted (first-load indexing of the
|
|
// bundled Library can take a few seconds).
|
|
await page.locator("#sb-editor .cm-editor").waitFor({
|
|
state: "visible",
|
|
timeout: 45_000,
|
|
});
|
|
|
|
// Logging out lands us back on the login page.
|
|
await page.goto(`${server.url}/.logout`);
|
|
await expect(page.locator("#username")).toBeVisible({ timeout: 30_000 });
|
|
});
|
|
});
|