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): UI-driven plan creation + schema-editor DDL read fix
zchpeterc12b86764b4d
diff --git a/frontend/tests/e2e/framework/api-client.ts b/frontend/tests/e2e/framework/api-client.tsindex a930a436de..6fc8375c1b 100644--- a/frontend/tests/e2e/framework/api-client.ts+++ b/frontend/tests/e2e/framework/api-client.ts@@ -570,11 +570,15 @@ export class BytebaseApiClient {});}+ // `specs` carries each spec's id + targets. UI-created plans get product-+ // generated UUID spec ids, so callers asserting spec-scoped URLs must read+ // the real ids here rather than assuming the ids they would have chosen.async getPlan(planName: string): Promise<{name: string;hasRollout: boolean;issue: string;state: string;+ specs?: { id: string; changeDatabaseConfig?: { targets?: string[] } }[];}> {return this.request("GET", `/v1/${planName}`);}diff --git a/frontend/tests/e2e/framework/ui-create-plan.ts b/frontend/tests/e2e/framework/ui-create-plan.tsnew file mode 100644index 0000000000..7791c6ebb4--- /dev/null+++ b/frontend/tests/e2e/framework/ui-create-plan.ts@@ -0,0 +1,169 @@+import { expect, type Page } from "@playwright/test";++// UI-driven plan creation — drives the real create page so setup follows the+// SAME workflow a user does (plan + draft review issue created together). This+// stays correct across workflow changes: whatever the create page requires in+// future, this clicks through it, and drift surfaces as a loud selector failure+// rather than a silent wrong-state (which is how bare `api.createPlan` setups+// silently broke when issue-creation was coupled to plan creation).++export interface UiCreatePlanOptions {+ baseURL: string;+ projectId: string;+ /**+ * Full database resource name (instances/x/databases/y). Pass several to+ * build ONE spec targeting multiple databases (they share the single typed+ * statement) — e.g. a two-environment change that the rollout groups into two+ * stages. For N INDEPENDENT specs (distinct per-spec SQL) use+ * createMultiSpecChangePlanViaUI instead.+ */+ database: string | string[];+ title: string;+ /** Statement to enter; any non-empty SQL enables the Create button. */+ sql: string;+}++// Create a database-change plan through the UI create page. Returns the numeric+// plan id. On return the page sits on the created plan's detail (a draft review+// issue exists, so its header reads "Ready for Review").+export async function createDatabaseChangePlanViaUI(+ page: Page,+ opts: UiCreatePlanOptions,+): Promise<{ planId: string }> {+ const databaseList = Array.isArray(opts.database)+ ? opts.database.join(",")+ : opts.database;+ const q = new URLSearchParams({+ template: "bb.plan.change-database",+ databaseList,+ name: opts.title,+ });+ await page.goto(+ `${opts.baseURL}/projects/${opts.projectId}/plans/create/specs/placeholder?${q.toString()}`,+ );+ await page.locator(".monaco-editor").first().click();+ await page.keyboard.type(opts.sql);+ const createBtn = page.getByRole("button", { name: "Create", exact: true });+ await expect(createBtn).toBeEnabled({ timeout: 15_000 });+ await createBtn.click();+ await page.waitForURL(/\/plans\/\d+/, { timeout: 20_000 });+ const planId = page.url().match(/\/plans\/(\d+)/)?.[1] ?? "";+ return { planId };+}++export interface UiSpec {+ /** Full database resource name for this spec's single target (env.database). */+ database: string;+ /** Statement for this spec. */+ sql: string;+}++export interface UiMultiSpecOptions {+ baseURL: string;+ projectId: string;+ title: string;+ /**+ * One spec per entry. `createPlanSkeleton` emits one spec per target ONLY when+ * a sqlMap is present (otherwise a single spec carries all targets), so this+ * always passes a sqlMap. sqlMap is keyed by database name — two specs on the+ * SAME database would collapse to one key, so multi-spec callers must use+ * DISTINCT databases (e.g. hr_test + hr_prod). Single-entry works too (one+ * key → one spec).+ */+ specs: UiSpec[];+}++// Create an N-spec database-change plan through the UI create page. The SQL is+// pre-filled from the URL sqlMap (not typed), so no per-spec Monaco interaction+// is needed — the create page hydrates each spec's local sheet from the map.+// Works for one spec (single key) or many (distinct-database keys). Returns the+// numeric plan id; on return the page sits on the created plan's detail (a draft+// review issue exists).+export async function createMultiSpecChangePlanViaUI(+ page: Page,+ opts: UiMultiSpecOptions,+): Promise<{ planId: string }> {+ const sqlMap: Record<string, string> = {};+ for (const s of opts.specs) sqlMap[s.database] = s.sql;+ const q = new URLSearchParams({+ template: "bb.plan.change-database",+ databaseList: opts.specs.map((s) => s.database).join(","),+ name: opts.title,+ sqlMap: JSON.stringify(sqlMap),+ });+ await page.goto(+ `${opts.baseURL}/projects/${opts.projectId}/plans/create/specs/placeholder?${q.toString()}`,+ );+ const createBtn = page.getByRole("button", { name: "Create", exact: true });+ await expect(createBtn).toBeEnabled({ timeout: 15_000 });+ await createBtn.click();+ await page.waitForURL(/\/plans\/\d+/, { timeout: 20_000 });+ const planId = page.url().match(/\/plans\/(\d+)/)?.[1] ?? "";+ return { planId };+}++// Submit the current draft plan for review (draft issue → open/non-draft), the+// UI's "Ready for Review" flow. Call while on the created plan's detail page.+//+// The confirm dialog runs the plan checks and has TWO terminal states, both+// handled here so the helper is correct whether or not the plan has failing+// checks (review / rollout / plan-check callers deliberately attach ERROR-level+// rules):+// - checks pass → the Confirm button enables on its own.+// - checks fail → the product gates submission behind an explicit+// "Confirm anyway" acknowledgment checkbox; Confirm stays+// disabled until it is checked.+export async function submitDraftForReviewViaUI(page: Page): Promise<void> {+ await page.getByRole("button", { name: "Ready for Review" }).click();+ const dialog = page.getByRole("dialog");+ const confirm = dialog+ .getByRole("button", { name: /Ready for Review|Submit|Confirm/ })+ .first();+ const confirmAnyway = dialog+ .getByRole("checkbox", { name: "Confirm anyway" })+ .first();++ // Wait for the checks to settle into whichever terminal state applies: the+ // ack checkbox appears (failing) or Confirm becomes enabled (passing).+ await expect(async () => {+ const gated = await confirmAnyway.isVisible().catch(() => false);+ const enabled = await confirm.isEnabled().catch(() => false);+ expect(gated || enabled).toBe(true);+ }).toPass({ timeout: 45_000 });++ if (await confirmAnyway.isVisible().catch(() => false)) {+ await confirmAnyway.click();+ }+ await expect(confirm).toBeEnabled({ timeout: 10_000 });+ await confirm.click();+ // After submission the header advances out of the ready-for-review state.+ await expect(+ page.getByRole("button", { name: "Ready for Review" }),+ ).toHaveCount(0, { timeout: 15_000 });+}++// Create AND submit a database-change plan through the UI — the full "start a+// change and send it for review" workflow. The result is a plan with a+// submitted (non-draft) review issue, which is what makes a rollout auto-create+// under permissive project settings (the state bare api.createPlan ++// api.createIssue used to fabricate directly).+export async function createSubmittedDatabaseChangePlanViaUI(+ page: Page,+ opts: UiCreatePlanOptions,+): Promise<{ planId: string }> {+ const result = await createDatabaseChangePlanViaUI(page, opts);+ await submitDraftForReviewViaUI(page);+ return result;+}++// Multi-spec create + submit — the N-spec analogue of the single-spec submit+// helper. Used by the plan-check tests, which build one- and two-spec plans and+// need a submitted issue so checks run and a rollout auto-creates.+export async function createSubmittedMultiSpecChangePlanViaUI(+ page: Page,+ opts: UiMultiSpecOptions,+): Promise<{ planId: string }> {+ const result = await createMultiSpecChangePlanViaUI(page, opts);+ await submitDraftForReviewViaUI(page);+ return result;+}diff --git a/frontend/tests/e2e/plan-detail/plan-detail-checks.spec.ts b/frontend/tests/e2e/plan-detail/plan-detail-checks.spec.tsindex 74112ea7dd..6951442ca0 100644--- a/frontend/tests/e2e/plan-detail/plan-detail-checks.spec.ts+++ b/frontend/tests/e2e/plan-detail/plan-detail-checks.spec.ts@@ -25,6 +25,7 @@ import {} from "@playwright/test";import { loadTestEnv, type TestEnv } from "../framework/env";import { BytebaseApiClient } from "../framework/api-client";+import { createSubmittedMultiSpecChangePlanViaUI } from "../framework/ui-create-plan";import { PlanDetailPage } from "./plan-detail.page";import { waitForPlanChecksDone } from "./plan-helpers";@@ -32,6 +33,11 @@ test.setTimeout(180_000);let env: TestEnv & { api: BytebaseApiClient };let projectId: string;+// Two distinct sample databases for multi-spec plans. sqlMap in the UI create+// URL is keyed by database, so two specs must target two different DBs — both+// carry the same HR schema (employee), so the review SQL applies to either.+let testDb: string;+let prodDb: string;let sharedContext: BrowserContext;let page: Page;@@ -49,6 +55,14 @@ test.beforeAll(async ({ browser }) => {projectId = env.project.split("/").pop()!;await env.api.login(env.adminEmail, env.adminPassword);+ const hrTest = await env.api.findDatabaseByShortName("hr_test");+ const hrProd = await env.api.findDatabaseByShortName("hr_prod");+ if (!hrTest || !hrProd) {+ throw new Error("plan-check multi-spec setup needs hr_test + hr_prod sample dbs");+ }+ testDb = hrTest.database;+ prodDb = hrProd.database;+const project = await env.api.getProject(env.project);originalSettings = {requireIssueApproval: !!project.requireIssueApproval,@@ -108,30 +122,29 @@ async function attachReviewConfig(return cfg.name;}-// Poll the latest planCheckRun on `planName` until status === "DONE",-// then navigate to the plan detail page. Returns the planId.+// Create an N-spec change plan through the UI (create + "Ready for Review"),+// wait for its plan checks to finish, then navigate to the plan detail page.+// Returns the planId. Submitting the review issue is what makes checks run and+// (under permissive settings) a rollout auto-create — the same states the old+// bare api.createPlan + api.createIssue fabricated, now produced via the real+// user workflow so drift breaks loudly. Each spec is one DB; multi-spec callers+// pass distinct DBs (sqlMap is keyed by database).async function createPlanAndWaitForChecks(titlePrefix: string,- specs: { id: string; targets: string[]; sql: string }[],+ specs: { database: string; sql: string }[],): Promise<string> {const ts = Date.now();- const planSpecs = await Promise.all(- specs.map(async (s) => ({- id: s.id,- targets: s.targets,- sheet: await env.api.createSheet(env.project, s.sql),- })),- );- const plan = await env.api.createPlan(- env.project,- `${titlePrefix} ${ts}`,- planSpecs,- );- const planName = plan.name;- const planId = planName.split("/").pop()!;- await env.api.createIssue(env.project, `${titlePrefix} ${ts}`, planName);- await env.api.runPlanChecks(planName);-+ const { planId } = await createSubmittedMultiSpecChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ title: `${titlePrefix} ${ts}`,+ specs,+ });+ const planName = `${env.project}/plans/${planId}`;+ // Submitting the review issue already triggers the plan checks — no explicit+ // runPlanChecks (an API-only escape hatch outside the user workflow that also+ // contends with submit's rollout-creation transaction). Just wait for the+ // submit-triggered checks to settle before the assertions read the summary.await waitForPlanChecksDone(env.api, planName);await planPage.goto(projectId, planId);@@ -171,8 +184,7 @@ test.describe("WARNING-level review rule", () => {const ts = Date.now();await createPlanAndWaitForChecks("E2E Checks Warning", [{- id: `spec-${ts}`,- targets: [env.database],+ database: env.database,// Nullable TEXT with no default → trips COLUMN_NO_NULL.sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_warn_${ts} TEXT;`,},@@ -223,8 +235,7 @@ test.describe("ERROR-level review rule with requirePlanCheckNoError=true", () =>const ts = Date.now();await createPlanAndWaitForChecks("E2E Checks Error Gate-On", [{- id: `spec-${ts}`,- targets: [env.database],+ database: env.database,sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_err_on_${ts} TEXT;`,},]);@@ -259,8 +270,7 @@ test.describe("ERROR-level review rule with requirePlanCheckNoError=true", () =>const ts = Date.now();await createPlanAndWaitForChecks("E2E Checks Error Gate-Off", [{- id: `spec-${ts}`,- targets: [env.database],+ database: env.database,sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_err_off_${ts} TEXT;`,},]);@@ -303,13 +313,11 @@ test.describe("Per-spec check counts render plan-wide (BYT-9160)", () => {const ts = Date.now();await createPlanAndWaitForChecks("E2E Plan-Wide Checks", [{- id: `spec-a-${ts}`,- targets: [env.database],+ database: testDb,sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_pw_a_${ts} TEXT;`,},{- id: `spec-b-${ts}`,- targets: [env.database],+ database: prodDb,sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_pw_b_${ts} TEXT;`,},]);@@ -330,12 +338,14 @@ test.describe("Per-spec check counts render plan-wide (BYT-9160)", () => {// StatementSection / OptionsSection) each carried the SAME `key={selectedSpec// .id}` — duplicate React keys broke reconciliation. Fixed by consolidating// them under a single keyed wrapper `<div key={selectedSpec.id}>`. Guarded here-// as a static property: expanding CHANGES mounts exactly ONE statement editor-// (the selected spec's), never both stacked.+// by switching between the two spec tabs and asserting only the selected+// spec's statement is mounted at each step (never both stacked), alongside the+// spec-scoped URL / history contract (BYT-9805 / BYT-9913).//-// (The original version switched to spec tab 2 to check the OTHER spec's-// statement replaced the first; that path now hits the spec-switch collapse BUG-// below, so the stacking property is asserted directly on the first spec.)+// The plan is created through the UI with two DISTINCT target databases+// (hr_test / hr_prod): the UI create page keys per-spec SQL by database, so a+// two-spec plan needs two targets — which also makes each tab's label+// ("Change N: <db>") distinct.test.describe("Spec identity and resource routing stay synchronized (BYT-9794/BYT-9805/BYT-9913)",() => {@@ -345,23 +355,28 @@ test.describe(const ts = Date.now();const colA = `e2e_stale_a_${ts}`;const colB = `e2e_stale_b_${ts}`;- const specA = `spec-a-${ts}`;- const specB = `spec-b-${ts}`;const planId = await createPlanAndWaitForChecks("E2E Stale Spec Editor",[{- id: specA,- targets: [env.database],+ database: testDb,sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS ${colA} TEXT;`,},{- id: specB,- targets: [env.database],+ database: prodDb,sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS ${colB} TEXT;`,},],);+ // The plan was created through the UI, so the product assigned each+ // spec a generated id. Read the real ids (in spec order — spec 1 targets+ // testDb, spec 2 targets prodDb) for the spec-scoped URL assertions.+ const created = await env.api.getPlan(`${env.project}/plans/${planId}`);+ const specIds = (created.specs ?? []).map((sp) => sp.id);+ expect(specIds).toHaveLength(2);+ const [specA, specB] = specIds;+ const testDbId = testDb.split("/").pop()!;+ const prodDbId = prodDb.split("/").pop()!;await planPage.expandSection("Changes");@@ -396,12 +411,8 @@ test.describe(const tab1 = planPage.specTab(1);const tab2 = planPage.specTab(2);- await expect(tab1).toHaveAccessibleName(- `Change 1: ${env.databaseId}`,- );- await expect(tab2).toHaveAccessibleName(- `Change 2: ${env.databaseId}`,- );+ await expect(tab1).toHaveAccessibleName(`Change 1: ${testDbId}`);+ await expect(tab2).toHaveAccessibleName(`Change 2: ${prodDbId}`);await expect(page.getByRole("button", { name: /Database Change/ }),).toHaveCount(0);diff --git a/frontend/tests/e2e/plan-detail/plan-detail-lifecycle.spec.ts b/frontend/tests/e2e/plan-detail/plan-detail-lifecycle.spec.tsindex f69f927d07..db443db995 100644--- a/frontend/tests/e2e/plan-detail/plan-detail-lifecycle.spec.ts+++ b/frontend/tests/e2e/plan-detail/plan-detail-lifecycle.spec.ts@@ -60,6 +60,10 @@ import {seedReviewPlan,waitForApprovalStatus,} from "./plan-helpers";+import {+ createDatabaseChangePlanViaUI,+ createSubmittedDatabaseChangePlanViaUI,+} from "../framework/ui-create-plan";test.setTimeout(240_000);test.describe.configure({ mode: "serial" });@@ -615,7 +619,7 @@ test.describe("Review advance is persona-scoped (R1/R2)", () => {test.beforeAll(async () => {// allowSelfApproval → admin (creator) IS the candidate.await setApproval(true);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Hdr R1R2",sql: "SELECT 1;",runChecks: true,@@ -655,7 +659,7 @@ test.describe("Rejected review shows the Rejected pill + re-request (R3)", () =>test.beforeAll(async () => {await setApproval(true);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Hdr R3",sql: "SELECT 1;",runChecks: true,@@ -700,7 +704,7 @@ test.describe("Approved with a failing ERROR check shows the checks-failing pillrequirePlanCheckNoError: true,});const ts = Date.now();- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {// A nullable column trips COLUMN_NO_NULL at ERROR level.prefix: "E2E Hdr R4",sql: `ALTER TABLE employee ADD COLUMN e2e_r4_${ts} TEXT;`,@@ -731,7 +735,7 @@ test.describe("Running the frontier stage from the header reaches the Deployed stest.beforeAll(async () => {await setPermissive();const ts = Date.now();- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Hdr D1",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_d1_${ts} TEXT;`,runChecks: true,@@ -764,7 +768,7 @@ test.describe("A failed task surfaces Rerun in the header slot (D2)", () => {await setPermissive();const ts = Date.now();// A nonexistent target makes the task fail at execution.- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Hdr D2",sql: `ALTER TABLE nonexistent_e2e_hdr_${ts} ADD COLUMN c1 TEXT;`,runChecks: false,@@ -798,18 +802,17 @@ test.describe("A multi-stage rollout advances the header stage by stage to Deploif (!testDb || !prodDb) {throw new Error("multi-stage seed needs the hr_test + hr_prod E2E databases");}- const sheet = await env.api.createSheet(- env.project,- `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_d3_${ts} TEXT;`,- );// One spec targeting two environments → the rollout groups tasks into two- // stages (Test, Prod).- const plan = await env.api.createPlan(env.project, `E2E Hdr D3 ${ts}`, [- { id: `spec-${ts}`, targets: [testDb.database, prodDb.database], sheet },- ]);- await env.api.createIssue(env.project, `E2E Hdr D3 ${ts}`, plan.name);- planId = plan.name.split("/").pop()!;- await waitForRollout(plan.name);+ // stages (Test, Prod). Create + submit through the UI so the rollout+ // auto-creates under the permissive settings set above.+ ({ planId } = await createSubmittedDatabaseChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ database: [testDb.database, prodDb.database],+ title: `E2E Hdr D3 ${ts}`,+ sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_d3_${ts} TEXT;`,+ }));+ await waitForRollout(`${env.project}/plans/${planId}`);});test("the header Run advance walks each stage until the plan is Deployed", async () => {@@ -849,7 +852,7 @@ test.describe("Close and reopen the review from the ⋯ overflow menu (T1)", ()test.beforeAll(async () => {// Open review, no rollout yet (self-approval off → observer, unapproved).await setApproval(false);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: titlePrefix,sql: "SELECT 1;",runChecks: true,diff --git a/frontend/tests/e2e/plan-detail/plan-detail-review.spec.ts b/frontend/tests/e2e/plan-detail/plan-detail-review.spec.tsindex d2b76ddbd9..576edf84f1 100644--- a/frontend/tests/e2e/plan-detail/plan-detail-review.spec.ts+++ b/frontend/tests/e2e/plan-detail/plan-detail-review.spec.ts@@ -176,7 +176,7 @@ test.describe("Review action and approval flow (CUJ A)", () => {test.beforeAll(async () => {await setupApproval(ONE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review A",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_a_${Date.now()} TEXT;`,});@@ -203,7 +203,7 @@ test.describe("Approve via the Review popover (CUJ B)", () => {test.beforeAll(async () => {await setupApproval(ONE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review B",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_b_${Date.now()} TEXT;`,});@@ -234,7 +234,7 @@ test.describe("Reject requires a comment; banner + in-stream decision (CUJ C)",test.beforeAll(async () => {await setupApproval(ONE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review C",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_c_${Date.now()} TEXT;`,});@@ -274,7 +274,7 @@ test.describe("Creator re-requests review without changes (CUJ D)", () => {test.beforeAll(async () => {await setupApproval(ONE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review D",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_d_${Date.now()} TEXT;`,});@@ -301,7 +301,7 @@ test.describe("Comment composer: draft persistence + post (CUJ E)", () => {test.beforeAll(async () => {await setupApproval(ONE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review E",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_e_${Date.now()} TEXT;`,});@@ -340,7 +340,7 @@ test.describe("Long-history timeline fold (CUJ J)", () => {test.beforeAll(async () => {await setupApproval(ONE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review J",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_j_${Date.now()} TEXT;`,});@@ -385,7 +385,7 @@ test.describe("Permission boundary: non-candidate cannot review but can comment"test.beforeAll(async ({ browser }) => {await setupApproval(ONE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review Perm",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_perm_${Date.now()} TEXT;`,});@@ -438,7 +438,7 @@ test.describe("inline comment edit shows the edited marker in place (BYT-9746)",test.beforeAll(async () => {await setupApproval(ONE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review O7",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_o7_${Date.now()} TEXT;`,});@@ -485,7 +485,7 @@ test.describe("Bypass when approved but checks failed (CUJ F)", () => {"value.workspace_approval",);await attachErrorConfig();- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review F",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_f_${Date.now()} TEXT;`,runChecks: true,@@ -532,7 +532,7 @@ test.describe("Waiting-review bypass link is gated by requireIssueApproval (CUJ{ workspaceApproval: { rules: [ONE_STEP_RULE] } },"value.workspace_approval",);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review G",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_g_${Date.now()} TEXT;`,runChecks: true,@@ -578,7 +578,7 @@ test.describe("A mandatory project gate hard-blocks the bypass confirm", () => {"value.workspace_approval",);await attachErrorConfig();- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review Gate",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_gate_${Date.now()} TEXT;`,runChecks: true,@@ -627,7 +627,7 @@ test.describe("confirm sheet shows the skipped state in its review box (BYT-9745"value.workspace_approval",);await attachErrorConfig();- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review O5",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_o5_${Date.now()} TEXT;`,runChecks: true,@@ -656,7 +656,7 @@ test.describe("Long approval flow adaptive rendering (CUJ I)", () => {test.beforeAll(async () => {await setupApproval(FIVE_STEP_RULE);- const seeded = await seedReviewPlan(env.api, env.project, env.database, {+ const seeded = await seedReviewPlan(env, page, {prefix: "E2E Review Flow",sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_rev_flow_${Date.now()} TEXT;`,});diff --git a/frontend/tests/e2e/plan-detail/plan-detail-rollout.spec.ts b/frontend/tests/e2e/plan-detail/plan-detail-rollout.spec.tsindex 6a450b6e0c..71466ac7fe 100644--- a/frontend/tests/e2e/plan-detail/plan-detail-rollout.spec.ts+++ b/frontend/tests/e2e/plan-detail/plan-detail-rollout.spec.ts@@ -26,8 +26,9 @@ import {} from "@playwright/test";import { loadTestEnv, type TestEnv } from "../framework/env";import { BytebaseApiClient } from "../framework/api-client";+import { createSubmittedDatabaseChangePlanViaUI } from "../framework/ui-create-plan";import { PlanDetailPage } from "./plan-detail.page";-import { waitForPlanChecksDone } from "./plan-helpers";+import { resolveIssueName, waitForPlanChecksDone } from "./plan-helpers";test.setTimeout(180_000);@@ -108,34 +109,30 @@ test.afterAll(async () => {await sharedContext?.close();});-// Helper — create a plan + issue against env.database; run plan checks;-// wait for them to complete; navigate to the detail page. Returns the-// plan's resource name + id so callers can poll approval state.+// Helper — create + submit a plan against env.database through the UI (plan ++// draft review issue, then "Ready for Review"); wait for plan checks to+// complete; navigate to the detail page. Returns the plan's resource name + id+// + linked issue name (from the Plan proto's `issue` field) so callers can poll+// approval state / approve.async function createIssueWithChecks(titlePrefix: string,sql: string,): Promise<{ planName: string; planId: string; issueName: string }> {- const ts = Date.now();- const sheet = await env.api.createSheet(env.project, sql);- const plan = await env.api.createPlan(- env.project,- `${titlePrefix} ${ts}`,- [{ id: `spec-${ts}`, targets: [env.database], sheet }],- );- const planName = plan.name;- const planId = planName.split("/").pop()!;- const issue = await env.api.createIssue(- env.project,- `${titlePrefix} ${ts}`,- planName,- );- await env.api.runPlanChecks(planName);-+ const { planId } = await createSubmittedDatabaseChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ database: env.database,+ title: `${titlePrefix} ${Date.now()}`,+ sql,+ });+ const planName = `${env.project}/plans/${planId}`;+ const issueName = await resolveIssueName(env.api, planName);+ await env.api.runPlanChecks(planName).catch(() => {});await waitForPlanChecksDone(env.api, planName);await planPage.goto(projectId, planId);await planPage.dismissModals();- return { planName, planId, issueName: issue.name };+ return { planName, planId, issueName };}test.describe("Permissive settings", () => {diff --git a/frontend/tests/e2e/plan-detail/plan-detail-sections.spec.ts b/frontend/tests/e2e/plan-detail/plan-detail-sections.spec.tsindex c20fbfc1e8..4a576a6e03 100644--- a/frontend/tests/e2e/plan-detail/plan-detail-sections.spec.ts+++ b/frontend/tests/e2e/plan-detail/plan-detail-sections.spec.ts@@ -15,6 +15,7 @@ import {} from "@playwright/test";import { loadTestEnv, type TestEnv } from "../framework/env";import { BytebaseApiClient } from "../framework/api-client";+import { createSubmittedDatabaseChangePlanViaUI } from "../framework/ui-create-plan";import { PlanDetailPage } from "./plan-detail.page";test.setTimeout(120_000);@@ -49,25 +50,23 @@ test.beforeAll(async ({ browser }) => {requirePlanCheckNoError: false,});- const ts = Date.now();- const sheet = await env.api.createSheet(- env.project,- `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_sections_${ts} TEXT;`,- );- const plan = await env.api.createPlan(- env.project,- `E2E Sections ${ts}`,- [{ id: `spec-${ts}`, targets: [env.database], sheet }],- );- planId = plan.name.split("/").pop()!;- await env.api.createIssue(env.project, `E2E Sections ${ts}`, plan.name);-sharedContext = await browser.newContext({storageState: ".auth/state.json",});page = await sharedContext.newPage();planPage = new PlanDetailPage(page, env.baseURL);+ // Create + submit through the UI so a rollout auto-creates (permissive+ // settings), which is what makes CHANGES auto-collapse — the state under test.+ const ts = Date.now();+ ({ planId } = await createSubmittedDatabaseChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ database: env.database,+ title: `E2E Sections ${ts}`,+ sql: `ALTER TABLE employee ADD COLUMN IF NOT EXISTS e2e_sections_${ts} TEXT;`,+ }));+await planPage.goto(projectId, planId);await planPage.dismissModals();});diff --git a/frontend/tests/e2e/plan-detail/plan-detail-smoke.spec.ts b/frontend/tests/e2e/plan-detail/plan-detail-smoke.spec.tsindex 49fa8c0415..722adf80e8 100644--- a/frontend/tests/e2e/plan-detail/plan-detail-smoke.spec.ts+++ b/frontend/tests/e2e/plan-detail/plan-detail-smoke.spec.ts@@ -1,6 +1,7 @@import { test, expect } from "@playwright/test";import { loadTestEnv } from "../framework/env";import { PlanDetailPage } from "./plan-detail.page";+import { createDatabaseChangePlanViaUI } from "../framework/ui-create-plan";test.setTimeout(60_000);@@ -9,20 +10,22 @@ test("plan-detail page loads with title, changes section, and a spec tab", async}) => {const env = loadTestEnv();const projectId = env.project.split("/").pop()!;- await env.api.login(env.adminEmail, env.adminPassword);-- const planTitle = `smoke-${Date.now()}`;- const sheetName = await env.api.createSheet(env.project, "SELECT 1;");- const specId = `spec-${Date.now()}`;- const plan = await env.api.createPlan(env.project, planTitle, [- { id: specId, targets: [env.database], sheet: sheetName },- ]);- const planId = plan.name.split("/").pop()!;const context = await browser.newContext({ storageState: ".auth/state.json" });const page = await context.newPage();const planPage = new PlanDetailPage(page, env.baseURL);+ // Create the plan the way the UI does (plan + draft review issue together),+ // not a bare api.createPlan.+ const planTitle = `smoke-${Date.now()}`;+ const { planId } = await createDatabaseChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ database: env.database,+ title: planTitle,+ sql: "SELECT 1;",+ });+await planPage.goto(projectId, planId);await planPage.dismissModals();diff --git a/frontend/tests/e2e/plan-detail/plan-detail-tasks.spec.ts b/frontend/tests/e2e/plan-detail/plan-detail-tasks.spec.tsindex 57093f142f..96ed7171c6 100644--- a/frontend/tests/e2e/plan-detail/plan-detail-tasks.spec.ts+++ b/frontend/tests/e2e/plan-detail/plan-detail-tasks.spec.ts@@ -14,6 +14,7 @@ import {} from "@playwright/test";import { loadTestEnv, type TestEnv } from "../framework/env";import { BytebaseApiClient } from "../framework/api-client";+import { createSubmittedDatabaseChangePlanViaUI } from "../framework/ui-create-plan";import { PlanDetailPage } from "./plan-detail.page";test.setTimeout(180_000);@@ -61,21 +62,21 @@ test.afterAll(async () => {await sharedContext?.close();});-// Helper — create a plan + issue against env.database with the given SQL,-// navigate to its detail page. Returns the plan id for re-navigation.+// Helper — create + submit a plan against env.database with the given SQL+// through the UI (the real user workflow: plan + draft review issue, then+// "Ready for Review"), so a rollout auto-creates under the permissive settings+// this file sets. Navigate to its detail page; return the plan id.async function createPlanAndNavigate(titlePrefix: string,sql: string,): Promise<string> {- const ts = Date.now();- const sheet = await env.api.createSheet(env.project, sql);- const plan = await env.api.createPlan(- env.project,- `${titlePrefix} ${ts}`,- [{ id: `spec-${ts}`, targets: [env.database], sheet }],- );- const planId = plan.name.split("/").pop()!;- await env.api.createIssue(env.project, `${titlePrefix} ${ts}`, plan.name);+ const { planId } = await createSubmittedDatabaseChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ database: env.database,+ title: `${titlePrefix} ${Date.now()}`,+ sql,+ });await planPage.goto(projectId, planId);await planPage.dismissModals();return planId;diff --git a/frontend/tests/e2e/plan-detail/plan-helpers.ts b/frontend/tests/e2e/plan-detail/plan-helpers.tsindex da5e64f7b7..d0d59764e3 100644--- a/frontend/tests/e2e/plan-detail/plan-helpers.ts+++ b/frontend/tests/e2e/plan-detail/plan-helpers.ts@@ -1,7 +1,51 @@+import type { Page } from "@playwright/test";import type { BytebaseApiClient } from "../framework/api-client";+import type { TestEnv } from "../framework/env";+import { createSubmittedDatabaseChangePlanViaUI } from "../framework/ui-create-plan";const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));+// Bound a single polling request so a server-side stall can't block the whole+// poll past its deadline. Without this a hung fetch (e.g. the server holding a+// lock in the plan-check/rollout path) never returns, so the surrounding+// `while (Date.now() < deadline)` loop never re-checks the deadline and the test+// hangs for many minutes instead of failing at its intended timeout. The+// underlying request is left to settle in the background (ignored); the caller+// simply retries on the next tick.+function withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise<T> {+ return Promise.race([+ p,+ new Promise<T>((_, reject) =>+ setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms),+ ),+ ]);+}++// Recover a plan's linked review-issue name from the Plan proto's OUTPUT_ONLY+// `issue` field. A UI-created plan's draft review issue is created together with+// the plan, so this is usually populated immediately — but poll briefly to+// absorb any read-after-write lag before failing closed.+export async function resolveIssueName(+ api: BytebaseApiClient,+ planName: string,+ timeoutMs = 15_000,+): Promise<string> {+ const deadline = Date.now() + timeoutMs;+ while (Date.now() < deadline) {+ try {+ const issue = (await withTimeout(api.getPlan(planName), 10_000, "getPlan"))+ .issue;+ if (issue) return issue;+ } catch {+ /* transient read stall — keep polling until the deadline */+ }+ await sleep(500);+ }+ throw new Error(+ `plan ${planName} has no linked issue within ${timeoutMs}ms`,+ );+}+// Poll an issue's approvalStatus until it reaches one of `accept`. Approval-flow// generation is async after issue creation, so the status briefly sits at// CHECKING before settling on PENDING / APPROVED / SKIPPED / REJECTED. Fail@@ -24,32 +68,35 @@ export async function waitForApprovalStatus();}-// Seed a single-spec change plan + its issue against `database`, optionally-// running plan checks and waiting for them to finish. Returns the ids the-// review specs need. Creation only — the caller decides which approval state to-// wait for (PENDING vs SKIPPED) since that depends on the project/workspace-// settings the caller configured.+// Seed a single-spec change plan + its submitted review issue against+// env.database, optionally waiting for plan checks to finish. Returns the ids+// the review specs need. Driven through the UI (create + "Ready for Review") so+// setup follows the real user workflow and breaks loudly on drift, not silently+// — the same reason the schema-editor / scroll / smoke setups were migrated off+// bare api.createPlan. The issue name comes from the plan's OUTPUT_ONLY `issue`+// field (resolveIssueName). Submission only — the caller decides which approval+// state to wait for (PENDING vs SKIPPED) via the project/workspace settings it+// configured before calling.export async function seedReviewPlan(- api: BytebaseApiClient,- project: string,- database: string,+ env: TestEnv & { api: BytebaseApiClient },+ page: Page,opts: { prefix: string; sql: string; runChecks?: boolean },): Promise<{ planId: string; planName: string; issueName: string }> {const ts = `${Date.now()}-${Math.floor(Math.random() * 1e6)}`;- const sheet = await api.createSheet(project, opts.sql);- const plan = await api.createPlan(project, `${opts.prefix} ${ts}`, [- { id: `spec-${ts}`, targets: [database], sheet },- ]);- const issue = await api.createIssue(project, `${opts.prefix} ${ts}`, plan.name);+ const projectId = env.project.split("/").pop()!;+ const { planId } = await createSubmittedDatabaseChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ database: env.database,+ title: `${opts.prefix} ${ts}`,+ sql: opts.sql,+ });+ const planName = `${env.project}/plans/${planId}`;+ const issueName = await resolveIssueName(env.api, planName);if (opts.runChecks) {- await api.runPlanChecks(plan.name);- await waitForPlanChecksDone(api, plan.name);+ await waitForPlanChecksDone(env.api, planName);}- return {- planId: plan.name.split("/").pop()!,- planName: plan.name,- issueName: issue.name,- };+ return { planId, planName, issueName };}// Seed the same database-change shape as seedReviewPlan, but keep its linked@@ -103,13 +150,17 @@ export async function waitForPlanChecksDone(let lastStatus = "<none>";while (Date.now() < deadline) {try {- const run = await api.getPlanCheckRun(planName);+ const run = await withTimeout(+ api.getPlanCheckRun(planName),+ 10_000,+ "getPlanCheckRun",+ );lastStatus = run.status;if (run.status === "DONE") return;} catch {- /* check run not created yet — keep polling */+ /* check run not created yet, or the request stalled — keep polling */}- await new Promise((r) => setTimeout(r, 1500));+ await sleep(1500);}// Fail closed: returning silently here would let the caller assert against// an unfinished plan and fail far from the cause. Throw so the failurediff --git a/frontend/tests/e2e/schema-editor/schema-editor-columns.spec.ts b/frontend/tests/e2e/schema-editor/schema-editor-columns.spec.tsindex ce31909c71..0c4e9a6e9f 100644--- a/frontend/tests/e2e/schema-editor/schema-editor-columns.spec.ts+++ b/frontend/tests/e2e/schema-editor/schema-editor-columns.spec.ts@@ -42,10 +42,10 @@ let planId: string;test.beforeAll(async ({ browser }) => {env = loadTestEnv();await env.api.login(env.adminEmail, env.adminPassword);- ({ projectId, planId } = await createSchemaEditorPlan(env, "E2E SchemaEditor Columns"));ctx = await browser.newContext({ storageState: ".auth/state.json" });page = await ctx.newPage();se = new SchemaEditorPage(page, env.baseURL);+ ({ projectId, planId } = await createSchemaEditorPlan(env, page, "E2E SchemaEditor Columns"));});test.afterAll(async () => {@@ -185,7 +185,7 @@ test.describe("column editing", () => {// mockedMetadata memo (keyed on editStatus.version) never recomputes, so the// DDL Preview stays frozen at the table's creation state. Existing-table edits// DO refresh the preview (they mark the column "updated" → version bumps).-test.describe("created-table edit reactivity (BUG BYT-9802-preview)", () => {+test.describe("created-table edit reactivity (BYT-9802-preview)", () => {test.describe.configure({ mode: "serial" });test.beforeEach(async () => {@@ -198,21 +198,20 @@ test.describe("created-table edit reactivity (BUG BYT-9802-preview)", () => {await se.close();});- // Repro: create table (id integer) → change id's type → preview still shows- // "integer" even though the grid cell (and the inserted SQL) reflect "bigint".- test.fail("changing a column type updates the preview DDL", async () => {+ // BYT-9802-preview (FIXED): create table (id integer) → change id's type →+ // the preview DDL now reflects the new type ("bigint"). Previously the preview+ // stayed "integer" (stale) even though the grid cell + inserted SQL updated.+ // Was a test.fail() lock until the fix landed; now a normal passing guard.+ test("changing a column type updates the preview DDL", async () => {await newTable();- // Wait for the initial (async) preview to load, so the failure below is on- // the stale type, not a not-yet-rendered preview.+ // Wait for the initial (async) preview to load before mutating the type.await expect.poll(async () => await se.previewText()).toContain("integer");await se.selectColumnType(0, "bigint");await expect(se.columnTypeInputs().nth(0)).toHaveValue("bigint"); // control- // Bug: the preview should reflect the new type but stays "integer". Poll- // (don't read once) so that when the bug is fixed the preview's async- // schema-string refresh is given time to land — turning this into an- // *unexpected pass* that signals the fix, rather than racing the refresh.+ // The preview's async schema-string refresh now reflects the new type. Poll+ // (don't read once) to allow the refresh to land.await expect.poll(async () => await se.previewText()).toContain("bigint");diff --git a/frontend/tests/e2e/schema-editor/schema-editor-create-table.spec.ts b/frontend/tests/e2e/schema-editor/schema-editor-create-table.spec.tsindex 927a4233a7..c0bdd95e7a 100644--- a/frontend/tests/e2e/schema-editor/schema-editor-create-table.spec.ts+++ b/frontend/tests/e2e/schema-editor/schema-editor-create-table.spec.ts@@ -32,11 +32,10 @@ test.beforeAll(async ({ browser }) => {env = loadTestEnv();await env.api.login(env.adminEmail, env.adminPassword);- ({ projectId, planId } = await createSchemaEditorPlan(env, "E2E SchemaEditor CreateTable"));-ctx = await browser.newContext({ storageState: ".auth/state.json" });page = await ctx.newPage();se = new SchemaEditorPage(page, env.baseURL);+ ({ projectId, planId } = await createSchemaEditorPlan(env, page, "E2E SchemaEditor CreateTable"));await se.gotoPlan(projectId, planId);});diff --git a/frontend/tests/e2e/schema-editor/schema-editor-diff-insert.spec.ts b/frontend/tests/e2e/schema-editor/schema-editor-diff-insert.spec.tsindex e1fa2da554..9e79cf6d05 100644--- a/frontend/tests/e2e/schema-editor/schema-editor-diff-insert.spec.ts+++ b/frontend/tests/e2e/schema-editor/schema-editor-diff-insert.spec.ts@@ -31,10 +31,10 @@ let planId: string;test.beforeAll(async ({ browser }) => {env = loadTestEnv();await env.api.login(env.adminEmail, env.adminPassword);- ({ projectId, planId } = await createSchemaEditorPlan(env, "E2E SchemaEditor DiffInsert"));ctx = await browser.newContext({ storageState: ".auth/state.json" });page = await ctx.newPage();se = new SchemaEditorPage(page, env.baseURL);+ ({ projectId, planId } = await createSchemaEditorPlan(env, page, "E2E SchemaEditor DiffInsert"));});test.afterAll(async () => {diff --git a/frontend/tests/e2e/schema-editor/schema-editor-helpers.ts b/frontend/tests/e2e/schema-editor/schema-editor-helpers.tsindex e795e8cec1..d29a324492 100644--- a/frontend/tests/e2e/schema-editor/schema-editor-helpers.ts+++ b/frontend/tests/e2e/schema-editor/schema-editor-helpers.ts@@ -1,29 +1,36 @@+import type { Page } from "@playwright/test";import type { BytebaseApiClient } from "../framework/api-client";import type { TestEnv } from "../framework/env";+import { createDatabaseChangePlanViaUI } from "../framework/ui-create-plan";// Create a DATABASE_CHANGE plan whose spec targets the Postgres `hr_test`// sample database, so the plan's Statement section renders the "Schema editor"// button (schemaEditorEligible = target engine is MySQL/TiDB/Postgres). The// editor only generates SQL for insertion — it never applies to the DB — so// creating throwaway tables against hr_test in the editor is side-effect free.+//+// Created through the UI (plan + draft review issue together), the same way a+// user starts a change — no bare api.createPlan. The plan stays a draft (not+// submitted): the schema editor operates on the spec while the plan is a draft.export async function createSchemaEditorPlan(env: TestEnv & { api: BytebaseApiClient },+ page: Page,prefix: string): Promise<{ projectId: string; planId: string; planName: string }> {const pg = await env.api.findDatabaseByShortName("hr_test", env.project);if (!pg) throw new Error("hr_test Postgres database not found");- const ts = Date.now();- const sheet = await env.api.createSheet(- env.project,- "-- edit via schema editor\n"- );- const plan = await env.api.createPlan(env.project, `${prefix} ${ts}`, [- { id: `spec-${ts}`, targets: [pg.database], sheet },- ]);+ const projectId = env.project.split("/").pop()!;+ const { planId } = await createDatabaseChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ database: pg.database,+ title: `${prefix} ${Date.now()}`,+ sql: "SELECT 1;",+ });return {- projectId: env.project.split("/").pop()!,- planId: plan.name.split("/").pop()!,- planName: plan.name,+ projectId,+ planId,+ planName: `${env.project}/plans/${planId}`,};}diff --git a/frontend/tests/e2e/schema-editor/schema-editor-objects.spec.ts b/frontend/tests/e2e/schema-editor/schema-editor-objects.spec.tsindex c3419c1589..b8d1c6c79a 100644--- a/frontend/tests/e2e/schema-editor/schema-editor-objects.spec.ts+++ b/frontend/tests/e2e/schema-editor/schema-editor-objects.spec.ts@@ -38,10 +38,10 @@ let planId: string;test.beforeAll(async ({ browser }) => {env = loadTestEnv();await env.api.login(env.adminEmail, env.adminPassword);- ({ projectId, planId } = await createSchemaEditorPlan(env, "E2E SchemaEditor Objects"));ctx = await browser.newContext({ storageState: ".auth/state.json" });page = await ctx.newPage();se = new SchemaEditorPage(page, env.baseURL);+ ({ projectId, planId } = await createSchemaEditorPlan(env, page, "E2E SchemaEditor Objects"));});test.afterAll(async () => {diff --git a/frontend/tests/e2e/schema-editor/schema-editor-tree-nav.spec.ts b/frontend/tests/e2e/schema-editor/schema-editor-tree-nav.spec.tsindex b5106053f8..f8eec0ce7b 100644--- a/frontend/tests/e2e/schema-editor/schema-editor-tree-nav.spec.ts+++ b/frontend/tests/e2e/schema-editor/schema-editor-tree-nav.spec.ts@@ -29,10 +29,10 @@ let planId: string;test.beforeAll(async ({ browser }) => {env = loadTestEnv();await env.api.login(env.adminEmail, env.adminPassword);- ({ projectId, planId } = await createSchemaEditorPlan(env, "E2E SchemaEditor TreeNav"));ctx = await browser.newContext({ storageState: ".auth/state.json" });page = await ctx.newPage();se = new SchemaEditorPage(page, env.baseURL);+ ({ projectId, planId } = await createSchemaEditorPlan(env, page, "E2E SchemaEditor TreeNav"));});test.afterAll(async () => {diff --git a/frontend/tests/e2e/schema-editor/schema-editor.page.ts b/frontend/tests/e2e/schema-editor/schema-editor.page.tsindex 7521b283da..780480a65b 100644--- a/frontend/tests/e2e/schema-editor/schema-editor.page.ts+++ b/frontend/tests/e2e/schema-editor/schema-editor.page.ts@@ -267,9 +267,29 @@ export class SchemaEditorPage {await expect(this.sheet).toBeHidden({ timeout: 15_000 });}+ // Reads the plan's statement Monaco editor. That editor VIRTUALIZES and its+ // viewport is short, so only the top (rendered) lines live in the DOM. A+ // multi-statement DDL - e.g. a CREATE TABLE followed by a SEPARATE+ // `ALTER TABLE ... ADD CONSTRAINT ... PRIMARY KEY (...)` statement - puts its+ // trailing lines below the fold, and a naive `.view-lines` read silently+ // truncates them (this is why a created-table PK, emitted as that trailing+ // ALTER statement, appeared "missing"). Read the top, jump to the end so the+ // trailing lines render, then union both. Also normalize Monaco's rendered+ // non-breaking spaces to plain spaces so literal-space assertions match.async planStatementText(): Promise<string> {- const editor = this.page.locator(".monaco-editor .view-lines").first();- await expect(editor).toBeVisible({ timeout: 10_000 });- return (await editor.innerText()).replace(/ /g, " ");+ const lines = this.page.locator(".monaco-editor .view-lines").first();+ await expect(lines).toBeVisible({ timeout: 10_000 });+ const norm = (s: string) => s.replace(/\u00a0/g, " ");+ const top = norm(await lines.innerText());+ // Focus the editor and jump to document end so the last lines render.+ await this.page.locator(".monaco-editor").first().click();+ await this.page.keyboard.press("ControlOrMeta+End");+ await this.page.waitForTimeout(300); // let the scrolled-to lines render+ const bottom = norm(await lines.innerText());+ // Union preserves order: top lines first, then newly-revealed trailing+ // lines. Substring/regex assertions then see the whole statement.+ return Array.from(+ new Set([...top.split("\n"), ...bottom.split("\n")]),+ ).join("\n");}}diff --git a/frontend/tests/e2e/scroll-restoration/dashboard-scroll-restoration.spec.ts b/frontend/tests/e2e/scroll-restoration/dashboard-scroll-restoration.spec.tsindex dffa397582..a1eabd7d9f 100644--- a/frontend/tests/e2e/scroll-restoration/dashboard-scroll-restoration.spec.ts+++ b/frontend/tests/e2e/scroll-restoration/dashboard-scroll-restoration.spec.ts@@ -7,6 +7,10 @@ import {} from "@playwright/test";import { BytebaseApiClient } from "../framework/api-client";import { loadTestEnv, type TestEnv } from "../framework/env";+import {+ createDatabaseChangePlanViaUI,+ submitDraftForReviewViaUI,+} from "../framework/ui-create-plan";test.setTimeout(240_000);@@ -102,34 +106,33 @@ test.beforeAll(async ({ browser }) => {(setting?.value as { workspaceProfile?: { externalUrl?: string } })?.workspaceProfile?.externalUrl ?? "";- const sheet = await env.api.createSheet(env.project, "SELECT 1;");- for (let i = 0; i < ISSUE_COUNT; i++) {- const title = `${searchToken} issue ${i}`;- const plan = await env.api.createPlan(env.project, title, [- {- id: `scroll-restoration-${stamp}-${i}`,- targets: [env.database],- sheet,- },- ]);- const repeatedDescription = Array.from(- { length: (i % 4) + 1 },- () => `${searchToken} variable-height content`- ).join("\n");- await env.api.createIssue(- env.project,- title,- plan.name,- repeatedDescription- );- }-sharedContext = await browser.newContext({storageState: ".auth/state.json",// Below Tailwind's sm breakpoint, the banner CTA moves onto its own row.viewport: { width: 600, height: 720 },});page = await sharedContext.newPage();++ // Seed the way the UI does: each plan is created together with its draft+ // review issue (createPlanWithDraftReview), so every plan appears in the Plans+ // list — an issueless plan is not a reachable product state and never lists.+ // Submit the first ISSUE_COUNT for review so they also surface in the Issues+ // list (draft issues are hidden there). This exercises the real bulk-create ++ // submit workflow and stays correct if that workflow changes again.+ await page.setViewportSize({ width: 1280, height: 900 }); // the create page needs room+ for (let i = 0; i < PLAN_COUNT; i++) {+ await createDatabaseChangePlanViaUI(page, {+ baseURL: env.baseURL,+ projectId,+ database: env.database,+ title: `${searchToken} issue ${i}`,+ sql: "SELECT 1;",+ });+ if (i < ISSUE_COUNT) {+ await submitDraftForReviewViaUI(page);+ }+ }+ await page.setViewportSize({ width: 600, height: 720 });});test.afterAll(async () => {diff --git a/frontend/tests/e2e/sql-editor/sql-editor-workspace-gates.spec.ts b/frontend/tests/e2e/sql-editor/sql-editor-workspace-gates.spec.tsindex c353c264f7..a8145f17fc 100644--- a/frontend/tests/e2e/sql-editor/sql-editor-workspace-gates.spec.ts+++ b/frontend/tests/e2e/sql-editor/sql-editor-workspace-gates.spec.ts@@ -166,11 +166,13 @@ test.describe("disableCopyData hides the Copy button on results (M2)", () => {timeout: 10_000,});- // Copy button (rendered when !disallowCopyingData && rows.length > 0)- // must NOT be in the toolbar. Anchor exact-match so "Copy others"- // etc. don't bleed in.+ // The results-toolbar Copy button reads "Copy all" (SingleResultView — the+ // split-button main action, rendered when !disallowCopyingData && rows>0).+ // It must be gone. NB: the status bar has a SEPARATE, always-present+ // statement "Copy" button (ResultStatusBar) that this gate does not govern —+ // target "Copy all" exactly so it isn't mistaken for the results Copy.await expect(- page.getByRole("button", { name: "Copy", exact: true }),+ page.getByRole("button", { name: "Copy all", exact: true }),).toHaveCount(0);});@@ -185,7 +187,7 @@ test.describe("disableCopyData hides the Copy button on results (M2)", () => {});await expect(- page.getByRole("button", { name: "Copy", exact: true }).first(),+ page.getByRole("button", { name: "Copy all", exact: true }).first(),).toBeVisible({ timeout: 5_000 });});});