Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
test(e2e): build the e2e server with SQL review V1, as release builds ship (#21658)
zchpetera9ce945f61b2
diff --git a/.claude/skills/e2e-routine/SKILL.md b/.claude/skills/e2e-routine/SKILL.mdindex e939dacb4e..5020374a1e 100644--- a/.claude/skills/e2e-routine/SKILL.md+++ b/.claude/skills/e2e-routine/SKILL.md@@ -43,8 +43,10 @@ issue body is `references/issue-template.md`; the ledger format isonly additions. The one edit allowed is putting the uploaded screenshot intothe description of an issue created in this run. Search before creating;one issue per mechanism.-- **Build**: `-tags embed_frontend` without `release`, so the dev-signed license- validates.+- **Build**: `frontend/tests/e2e/build-server.sh`: `-tags embed_frontend` without+ `release`, so the dev-signed license validates, with dev-only product switches+ (SQL review V2) set to their release values. The suite tests what release+ builds ship.- **Evidence before claims**: every class cites the attempt error line, thescreenshot you opened and what it shows (or that the attempt has none) and,for SPEC-ROT or PRODUCT, a commit. A gate without pasted evidence is notdiff --git a/.claude/skills/e2e-routine/scripts/build.sh b/.claude/skills/e2e-routine/scripts/build.shindex 3309a168f9..839514d998 100755--- a/.claude/skills/e2e-routine/scripts/build.sh+++ b/.claude/skills/e2e-routine/scripts/build.sh@@ -3,10 +3,11 @@## build.sh [results-dir]#-# Skips the work when ./bytebase-build/bytebase already matches HEAD (stamp-# file) and the tree is clean. Builds WITHOUT the `release` tag on purpose: the-# dev license in frontend/.env.dev is signed with the dev key, which only a-# non-release build accepts. Records timings in <results-dir>/build-timing.txt.+# Skips the work when ./bytebase-build/bytebase already matches HEAD and the+# server build script (stamp file) and the tree is clean. The Go step is+# frontend/tests/e2e/build-server.sh: a dev build, so the dev license in+# frontend/.env.dev validates, with dev-only product switches set to their+# release values. Records timings in <results-dir>/build-timing.txt.set -eusource "$(dirname "${BASH_SOURCE[0]}")/lib.sh"cd "$REPO_ROOT"@@ -15,15 +16,17 @@ RESULTS="${1:-$E2E_RESULTS_ROOT/build}"mkdir -p "$RESULTS" bytebase-buildSTAMP=bytebase-build/.built-shaBIN=bytebase-build/bytebase-head="$(git rev-parse HEAD)"+SERVER_BUILD=frontend/tests/e2e/build-server.sh+# A change to the server build script changes the binary without a commit.+stamp="$(git rev-parse HEAD) $(git hash-object "$SERVER_BUILD")"# Any uncommitted change that can reach the binary invalidates the cached# build: the whole frontend tree (package.json, lockfile, Tailwind and Vite# config, plugins), not only frontend/src. The e2e specs do not reach it.dirty="$(git status --porcelain -- frontend backend proto go.mod go.sum ':!frontend/tests/e2e' | head -1)"timing="$RESULTS/build-timing.txt"-if [ -x "$BIN" ] && [ -f "$STAMP" ] && [ "$(cat "$STAMP")" = "$head" ] && [ -z "$dirty" ] && [ "${FORCE_BUILD:-0}" != 1 ]; then- log "binary already built from $head; skipping (FORCE_BUILD=1 to rebuild)"+if [ -x "$BIN" ] && [ -f "$STAMP" ] && [ "$(cat "$STAMP")" = "$stamp" ] && [ -z "$dirty" ] && [ "${FORCE_BUILD:-0}" != 1 ]; then+ log "binary already built from $stamp; skipping (FORCE_BUILD=1 to rebuild)"# Every run directory gets a timing record, a reused binary included.printf '%-16s %5ss\n' "cached" 0 >"$timing"exit 0@@ -41,6 +44,6 @@ phase() { # phase <name> <cmd...>phase pnpm-install pnpm --dir frontend install --frozen-lockfilephase pnpm-release pnpm --dir frontend release-phase go-build go build -tags embed_frontend -ldflags "-w -s" -p="$(cpu_count)" -o "$BIN" ./backend/bin/server/main.go-echo "$head" >"$STAMP"-log "built $BIN from $head"+phase go-build bash "$SERVER_BUILD" "$BIN"+echo "$stamp" >"$STAMP"+log "built $BIN from $stamp"diff --git a/.claude/skills/verify/SKILL.md b/.claude/skills/verify/SKILL.mdindex 2b84a5da42..5f8387e7be 100644--- a/.claude/skills/verify/SKILL.md+++ b/.claude/skills/verify/SKILL.md@@ -13,12 +13,15 @@ or changing tests, read [the E2E instructions](../../../frontend/tests/e2e/AGENT## Build```bash-pnpm --dir frontend release-go build -tags embed_frontend -ldflags "-w -s" -p=16 -o ./bytebase-build/bytebase ./backend/bin/server/main.go+(cd frontend && pnpm release)+bash frontend/tests/e2e/build-server.sh```-The `embed_frontend` tag is required to serve the UI. Rebuild the affected-frontend bundle/backend binary after code changes so the test exercises the fix.+`build-server.sh` builds with the `embed_frontend` tag, which serves the UI,+and without `release`, so the dev license validates; it sets dev-only product+switches to their release values, so SQL review runs V1 (see the E2E README).+Rebuild the affected frontend bundle/backend binary after code changes so the+test exercises the fix.## Run the affected scenariodiff --git a/frontend/tests/e2e/README.md b/frontend/tests/e2e/README.mdindex 53ca4e4a7b..2099133b2f 100644--- a/frontend/tests/e2e/README.md+++ b/frontend/tests/e2e/README.md@@ -4,11 +4,15 @@ Playwright-based end-to-end tests for Bytebase. Starts a disposable Bytebase ser## Prerequisites-1. **Bytebase binary with embedded frontend:**+1. **Bytebase binary with embedded frontend**, from the repository root:```bash- pnpm --dir frontend release- go build -tags embed_frontend -ldflags "-w -s" -p=16 -o ./bytebase-build/bytebase ./backend/bin/server/main.go+ (cd frontend && pnpm release)+ bash frontend/tests/e2e/build-server.sh```+ `build-server.sh` builds a dev binary, so the dev license validates, with+ dev-only product switches set to their release values: the suite tests what+ release builds ship. Today that switch is SQL review V2, which a plain dev+ build turns on; the suite covers SQL review V1.2. **`psql` client** on PATH — required for DDL setup (the Bytebase query API is read-only; tests connect directly to the sample Postgres via Unix socket).diff --git a/frontend/tests/e2e/build-server.sh b/frontend/tests/e2e/build-server.shnew file mode 100755index 0000000000..5796bf8aa6--- /dev/null+++ b/frontend/tests/e2e/build-server.sh@@ -0,0 +1,36 @@+#!/usr/bin/env bash+# Build the Bytebase server binary the e2e suite boots.+#+# frontend/tests/e2e/build-server.sh [output] # default ./bytebase-build/bytebase+#+# The suite tests what release builds ship, but a release build only accepts+# a license signed with the production key, and the suite uses the dev+# license. So this builds a dev binary (no `release` tag) and, through Go's+# -overlay, sets each dev-only product switch in profile_dev.go back to its+# release value. The source tree is not modified. Embed the frontend first:+# `(cd frontend && pnpm release)`.+set -euo pipefail++repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"+out="${1:-$repo/bytebase-build/bytebase}"+profile="$repo/backend/bin/server/cmd/profile_dev.go"++overlay_dir="$(mktemp -d)"+trap 'rm -rf "$overlay_dir"' EXIT++# SQL review V2 is under development and on only in dev builds; release+# builds run V1. A missing line means the switch moved: fail rather than+# silently testing V2.+if [ "$(grep -c '^[[:space:]]*p\.SQLReviewV2 = true$' "$profile")" != 1 ]; then+ echo "build-server.sh: expected one 'p.SQLReviewV2 = true' line in $profile; update this script" >&2+ exit 1+fi+sed 's/^\([[:space:]]*\)p\.SQLReviewV2 = true$/\1p.SQLReviewV2 = false/' "$profile" >"$overlay_dir/profile_dev.go"+node -e 'require("fs").writeFileSync(process.argv[3], JSON.stringify({ Replace: { [process.argv[1]]: process.argv[2] } }))' \+ "$profile" "$overlay_dir/profile_dev.go" "$overlay_dir/overlay.json"++cpus="$(nproc 2>/dev/null || sysctl -n hw.ncpu)"+mkdir -p "$(dirname "$out")"+cd "$repo"+go build -overlay="$overlay_dir/overlay.json" -tags embed_frontend -ldflags "-w -s" -p="$cpus" \+ -o "$out" ./backend/bin/server/main.godiff --git a/frontend/tests/e2e/framework/mode-start-new-bytebase.ts b/frontend/tests/e2e/framework/mode-start-new-bytebase.tsindex 5932f32cde..f91c2eea5e 100644--- a/frontend/tests/e2e/framework/mode-start-new-bytebase.ts+++ b/frontend/tests/e2e/framework/mode-start-new-bytebase.ts@@ -188,9 +188,9 @@ function findServerBinary(): string {const binPath = candidates.find((p) => fs.existsSync(p));if (!binPath) {throw new Error(- `Bytebase binary not found. Build it with:\n` +- ` pnpm --dir frontend build\n` +- ` go build -tags embed_frontend -ldflags "-w -s" -p=16 -o ./bytebase-build/bytebase ./backend/bin/server/main.go\n` ++ `Bytebase binary not found. Build it from the repository root with:\n` ++ ` (cd frontend && pnpm release)\n` ++ ` bash frontend/tests/e2e/build-server.sh\n` +`Or set BYTEBASE_BIN to the binary path.`);}diff --git a/frontend/tests/e2e/sql-editor/sql-editor-admin-mode.spec.ts b/frontend/tests/e2e/sql-editor/sql-editor-admin-mode.spec.tsindex 8863027084..e50ee6ef05 100644--- a/frontend/tests/e2e/sql-editor/sql-editor-admin-mode.spec.ts+++ b/frontend/tests/e2e/sql-editor/sql-editor-admin-mode.spec.ts@@ -94,26 +94,21 @@ test.describe("Vertical display preserves the admin-mode dark theme", () => {"SELECT emp_no, first_name, last_name FROM employee LIMIT 3;",);- // Wait for the result panel to render (a "Vertical display" toggle- // only appears once a result is on screen).- await page- .getByText("Vertical display", { exact: true })- .first()- .waitFor({ timeout: 15_000 });-- // Find the Vertical display switch in the result panel header.- // The Switch primitive (Base UI) renders as `role="switch"` — we- // scope to the row containing the "Vertical display" label so we- // don't accidentally toggle the noSQL "table-view" switch above it.- const verticalRow = page- .locator("div.flex.items-center.gap-x-1")- .filter({ hasText: "Vertical display" })+ // The result toolbar's view switch (Table / Vertical display / Plan,+ // #21646) appears once a result is on screen. Each option is a label+ // wrapping a visually hidden radio, so click the label.+ const viewSwitch = page+ .getByRole("radiogroup", { name: "Result view mode" }).first();- await expect(verticalRow).toBeVisible({ timeout: 10_000 });- const verticalSwitch = verticalRow.getByRole("switch");- await expect(verticalSwitch).toBeVisible({ timeout: 5000 });- await verticalSwitch.click();- await page.waitForTimeout(500);+ await expect(viewSwitch).toBeVisible({ timeout: 15_000 });+ const verticalOption = viewSwitch+ .locator("label")+ .filter({ hasText: "Vertical display" });+ await verticalOption.click();+ await expect(verticalOption.getByRole("radio")).toHaveAttribute(+ "aria-checked",+ "true",+ );// After toggle, the result body switches from VirtualDataTable to// VirtualDataBlock. Each VirtualDataBlock row is wrapped in a