Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
test(e2e): run licence activation against the offline issuer
rcourtman5d96811f3b4e
diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.ymlindex a26187fcf4..3d8ccfb0d5 100644--- a/.github/workflows/test-e2e.yml+++ b/.github/workflows/test-e2e.yml@@ -199,12 +199,26 @@ jobs:node scripts/with-offline-entitlements.mjs node scripts/run-playwright.mjs--config=playwright.multi-tenant-diagnostic.config.ts--grep 'Scenario 1:|create, update, member manage' --workers=1 --retries=0+ # The same issuer's Pro key, pasted into Settings the way a customer+ # applies a purchase, then cleared back to Community.+ - name: Prove Settings licence activation and clear+ working-directory: tests/integration+ env:+ PULSE_E2E_USE_LOCAL_BACKEND: 'true'+ PULSE_E2E_SKIP_PLAYWRIGHT_INSTALL: 'true'+ PULSE_E2E_REPORT_DIR: playwright-report/license-activation+ PULSE_E2E_RESULTS_DIR: test-results/license-activation+ run: >-+ node scripts/with-offline-entitlements.mjs node scripts/run-playwright.mjs+ tests/10-v6-license-activation.spec.ts --project=chromium --workers=1 --retries=0- name: Upload offline provisioning failure reportif: failure()uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:name: offline-org-provisioning-report- path: tests/integration/playwright-report/multi-tenant-diagnostic/+ path: |+ tests/integration/playwright-report/multi-tenant-diagnostic/+ tests/integration/playwright-report/license-activation/retention-days: 3test-images:diff --git a/tests/integration/scripts/OFFLINE_ENTITLEMENTS.md b/tests/integration/scripts/OFFLINE_ENTITLEMENTS.mdindex 0512c863e0..aaa0fdfed9 100644--- a/tests/integration/scripts/OFFLINE_ENTITLEMENTS.md+++ b/tests/integration/scripts/OFFLINE_ENTITLEMENTS.md@@ -36,6 +36,21 @@ exclude Community's private `rbac`, and check the security contract'sbilling.json profile writer; there is no direct capability injection.No offline key means the existing unentitled and other test paths are unchanged.+The issuer also mints a second key, `PULSE_E2E_OFFLINE_PRO_ACTIVATION_KEY`,+whose grants carry the Pro plan. Each key binds its own installation per+fingerprint. `tests/10-v6-license-activation.spec.ts` pastes it into the+Settings plan page, checks the Pro state in the UI and API, and clears it+back to Community; without the wrapper it skips. The same CI job runs it:++```sh+PULSE_E2E_USE_LOCAL_BACKEND=true node scripts/with-offline-entitlements.mjs \+ node scripts/run-playwright.mjs tests/10-v6-license-activation.spec.ts \+ --project=chromium --workers=1 --retries=0+```++The managed backend is a community build, so the plan page also shows the+"Pro runtime missing" notice a public-build customer sees after activating.+The separate CI provisioning job runs two narrow scenarios and issuer boundarytests. It does not change stable/probation/quarantine membership. Passing it isnot Organization sharing acceptance, private-runtime RBAC coverage, full-suitediff --git a/tests/integration/scripts/offline-license-issuer.mjs b/tests/integration/scripts/offline-license-issuer.mjsindex 305d82e83a..e08026e28b 100644--- a/tests/integration/scripts/offline-license-issuer.mjs+++ b/tests/integration/scripts/offline-license-issuer.mjs@@ -5,7 +5,13 @@ import http from 'node:http';const encode = value => Buffer.from(JSON.stringify(value)).toString('base64url');export async function startOfflineLicenseIssuer() {const { publicKey, privateKey } = generateKeyPairSync('ed25519');+ // Each ephemeral key stands for one licence plan, as on the real server.const activationKey = `ppk_live_e2e_${randomUUID()}`;+ const proActivationKey = `ppk_live_e2e_${randomUUID()}`;+ const plans = new Map([+ [activationKey, { tier: 'msp', plan: 'msp_starter' }],+ [proActivationKey, { tier: 'pro', plan: 'pro_monthly' }],+ ]);const installations = new Map();const fingerprints = new Map();const grant = installation => {@@ -13,7 +19,7 @@ export async function startOfflineLicenseIssuer() {const jti = `grt_${randomUUID()}`;const claims = { iss: 'pulse-license', aud: 'pulse-relay', sub: installation.id,lid: installation.license, iid: installation.id, lv: 1, st: 'active',- tier: 'msp', plan: 'msp_starter', iat: now, nbf: now, exp: now + 3600,+ tier: installation.tier, plan: installation.plan, iat: now, nbf: now, exp: now + 3600,jti, email: '[email protected]' };const input = `${encode({ alg: 'EdDSA', typ: 'JWT' })}.${encode(claims)}`;return { jwt: `${input}.${sign(null, Buffer.from(input), privateKey).toString('base64url')}`,@@ -38,18 +44,20 @@ export async function startOfflineLicenseIssuer() {reply(400, { error: 'missing fixture fingerprint' }); return;}if (req.url === '/v1/activate') {- if (data.activation_key !== activationKey || data.runtime?.build !== 'community') {+ const plan = plans.get(data.activation_key);+ if (!plan || data.runtime?.build !== 'community') {reply(401, { error: 'invalid fixture activation' }); return;}- let installation = fingerprints.get(data.instance_fingerprint);+ const binding = `${data.activation_key}\n${data.instance_fingerprint}`;+ let installation = fingerprints.get(binding);if (!installation) {if (installations.size >= 1024) { reply(429, { error: 'fixture capacity reached' }); return; }installation = { id: `inst_${randomUUID()}`, license: `lic_${randomUUID()}`,- token: `pit_live_e2e_${randomUUID()}`, fingerprint: data.instance_fingerprint };+ token: `pit_live_e2e_${randomUUID()}`, fingerprint: data.instance_fingerprint, ...plan };installations.set(installation.id, installation);- fingerprints.set(installation.fingerprint, installation);+ fingerprints.set(binding, installation);}- reply(201, { license: { license_id: installation.license, state: 'active', tier: 'msp', license_version: 1 },+ reply(201, { license: { license_id: installation.license, state: 'active', tier: installation.tier, license_version: 1 },installation: { installation_id: installation.id, installation_token: installation.token, status: 'active' },grant: grant(installation) });return;@@ -73,6 +81,7 @@ export async function startOfflineLicenseIssuer() {url: `http://127.0.0.1:${server.address().port}`,publicKey: Buffer.from(publicKey.export({ format: 'jwk' }).x, 'base64url').toString('base64'),activationKey,+ proActivationKey,close: () => new Promise((resolve, reject) => {server.close(error => error ? reject(error) : resolve());server.closeAllConnections();diff --git a/tests/integration/scripts/offline-license-issuer.test.mjs b/tests/integration/scripts/offline-license-issuer.test.mjsindex 2ad0719d39..3a53600e86 100644--- a/tests/integration/scripts/offline-license-issuer.test.mjs+++ b/tests/integration/scripts/offline-license-issuer.test.mjs@@ -40,6 +40,26 @@ test('offline issuer signs scoped grants and binds status/refresh to each instalassert.deepEqual(repeated.installation, states[1].installation);});+test('offline issuer grants the Pro plan only for its own activation key', async t => {+ const issuer = await startOfflineLicenseIssuer(); t.after(() => issuer.close());+ assert.notEqual(issuer.proActivationKey, issuer.activationKey);+ const activate = key => post(issuer, '/v1/activate', {+ activation_key: key, instance_fingerprint: 'default', runtime: { build: 'community' },+ }).then(r => r.json());+ const pro = await activate(issuer.proActivationKey);+ const claims = JSON.parse(Buffer.from(pro.grant.jwt.split('.')[1], 'base64url'));+ assert.equal(pro.license.tier, 'pro');+ assert.equal(claims.tier, 'pro'); assert.equal(claims.plan, 'pro_monthly');+ assert.equal(claims.feat, undefined);+ const refreshed = await (await post(issuer, '/v1/grants/refresh',+ { installation_id: claims.iid, instance_fingerprint: 'default' }, pro.installation.installation_token)).json();+ assert.equal(JSON.parse(Buffer.from(refreshed.grant.jwt.split('.')[1], 'base64url')).tier, 'pro');+ // One fingerprint activating a different key is a different licence binding.+ const msp = await activate(issuer.activationKey);+ assert.notEqual(msp.installation.installation_id, pro.installation.installation_id);+ assert.equal(msp.license.tier, 'msp');+});+test('offline issuer rejects unsupported routes, bad activation and malformed input', async t => {const issuer = await startOfflineLicenseIssuer(); t.after(() => issuer.close());const data = { activation_key: issuer.activationKey, instance_fingerprint: 'default', runtime: { build: 'community' } };@@ -53,4 +73,5 @@ test('offline issuer rejects unsupported routes, bad activation and malformed inconst other = await startOfflineLicenseIssuer(); t.after(() => other.close());assert.notEqual(other.publicKey, issuer.publicKey);assert.notEqual(other.activationKey, issuer.activationKey);+ assert.notEqual(other.proActivationKey, issuer.proActivationKey);});diff --git a/tests/integration/scripts/with-offline-entitlements.mjs b/tests/integration/scripts/with-offline-entitlements.mjsindex 322eff214c..0b0da0ab1f 100644--- a/tests/integration/scripts/with-offline-entitlements.mjs+++ b/tests/integration/scripts/with-offline-entitlements.mjs@@ -27,6 +27,7 @@ try {PULSE_LICENSE_PUBLIC_KEY: issuer.publicKey, PULSE_LICENSE_SERVER_URL: issuer.url,PULSE_LICENSE_DEV_MODE: 'false', PULSE_MOCK_MODE: 'false', PULSE_MULTI_TENANT_ENABLED: 'true',PULSE_E2E_OFFLINE_ACTIVATION_KEY: issuer.activationKey,+ PULSE_E2E_OFFLINE_PRO_ACTIVATION_KEY: issuer.proActivationKey,} });const forward = signal => child.kill(signal);const term = () => forward('SIGTERM');diff --git a/tests/integration/scripts/with-offline-entitlements.test.mjs b/tests/integration/scripts/with-offline-entitlements.test.mjsindex c9354f4da3..5901c1a0b2 100644--- a/tests/integration/scripts/with-offline-entitlements.test.mjs+++ b/tests/integration/scripts/with-offline-entitlements.test.mjs@@ -19,6 +19,7 @@ test('wrapper keeps issuer alive for child and closes it after child failure', aconst assert = require('node:assert/strict');assert.equal(process.env.PULSE_LICENSE_DEV_MODE, 'false');assert.equal(process.env.PULSE_MOCK_MODE, 'false');+ assert.match(process.env.PULSE_E2E_OFFLINE_PRO_ACTIVATION_KEY, /^ppk_live_e2e_/);fetch(process.env.PULSE_LICENSE_SERVER_URL + '/v1/activate', {method: 'POST', body: JSON.stringify({activation_key: process.env.PULSE_E2E_OFFLINE_ACTIVATION_KEY,instance_fingerprint: 'test', runtime: {build: 'community'}})diff --git a/tests/integration/tests/10-v6-license-activation.spec.ts b/tests/integration/tests/10-v6-license-activation.spec.tsindex 9e2823e5e9..d04a625fff 100644--- a/tests/integration/tests/10-v6-license-activation.spec.ts+++ b/tests/integration/tests/10-v6-license-activation.spec.ts@@ -1,308 +1,175 @@-import { test, expect } from "@playwright/test";+import { test, expect, type Page } from "@playwright/test";import { apiRequest, ensureAuthenticated } from "./helpers";import { PATROL_ROUTE } from "./routes";/*** V6 License Activation E2E Test*- * Exercises the full v6 activation flow: issue a test license via the license- * server admin API, paste the activation key into the Pulse Settings UI,- * verify activation succeeds, and confirm the UI shows the correct tier/features.+ * Exercises the v6 activation flow a paying self-hosted customer takes: paste+ * an activation key into the Settings plan page, let the backend activate it+ * against the licence server, confirm the plan state in the UI and API, then+ * clear it back to Community.*- * Requires:- * PULSE_LICENSE_ADMIN_TOKEN — admin token for the license server- * PULSE_LICENSE_SERVER_URL — (optional) defaults to https://license.pulserelay.pro+ * The licence server is the in-memory Ed25519 issuer started by+ * scripts/with-offline-entitlements.mjs, which also points the source-built+ * backend's trust root at it. No production licence server, admin token or+ * signing material is involved. Without the wrapper every test skips:+ *+ * PULSE_E2E_USE_LOCAL_BACKEND=true node scripts/with-offline-entitlements.mjs \+ * node scripts/run-playwright.mjs tests/10-v6-license-activation.spec.ts \+ * --project=chromium --workers=1 --retries=0*/-const LICENSE_SERVER_URL = (- process.env.PULSE_LICENSE_SERVER_URL || "https://license.pulserelay.pro"-).replace(/\/+$/, "");--const ADMIN_TOKEN = process.env.PULSE_LICENSE_ADMIN_TOKEN || "";--type IssuedLicense = {- license: { license_id: string };- activation_key: { activation_key: string };-};+const ACTIVATION_KEY = process.env.PULSE_E2E_OFFLINE_PRO_ACTIVATION_KEY || "";+const BILLING_PLAN_ROUTE = "/settings/pulse-intelligence/billing/plan";+const RECOVERY_ROUTE = `${BILLING_PLAN_ROUTE}?details=recovery`;+// Shared by both offline issuer plans; the grant carries it as the licence email.+const LICENSED_EMAIL = "[email protected]";type EntitlementPayload = {subscription_state?: string;tier?: string;valid?: boolean;- is_lifetime?: boolean;licensed_email?: string;- days_remaining?: number;- limits?: Array<{- key: string;- limit: number;- current: number;- state: string;- }>;-};--type AISettingsPayload = {- enabled?: boolean;- model?: string;- patrol_model?: string;+ limits?: Array<{ key: string }>;};type PatrolStatusPayload = {runtime_state?: string;};-test.describe.serial("V6 license activation flow", () => {- /** Issued license ID — used for cleanup/revocation. */- let issuedLicenseId = "";- /** The activation key string (ppk_live_*). */- let activationKey = "";-- test.afterAll(async ({ browser }) => {- // Best-effort cleanup: clear license in Pulse and revoke on the server.- const context = await browser.newContext();- const page = await context.newPage();-- try {- await ensureAuthenticated(page);-- // Clear the license in Pulse (ignore errors — may already be cleared).- await apiRequest(page, "/api/license/clear", { method: "POST" }).catch(- () => {},- );- } catch {- // If Pulse is unreachable, nothing to clean up locally.- }+async function readEntitlements(page: Page): Promise<EntitlementPayload> {+ const res = await apiRequest(page, "/api/license/entitlements");+ expect(res.ok(), `Entitlements request failed: ${res.status()}`).toBeTruthy();+ return (await res.json()) as EntitlementPayload;+}- // Revoke the test license on the license server.- if (issuedLicenseId && ADMIN_TOKEN) {- try {- await page.request.fetch(- `${LICENSE_SERVER_URL}/v1/licenses/${issuedLicenseId}/revoke`,- {- method: "POST",- headers: {- "Content-Type": "application/json",- "X-API-Token": ADMIN_TOKEN,- },- data: { reason: "E2E test cleanup", reason_code: "test_cleanup" },- },- );- } catch {- // Best-effort — test license will expire in 1 day anyway.- }- }+function licenseRecovery(page: Page) {+ return page.locator("details").filter({ hasText: "Manual key recovery" });+}- await context.close();- });-- test("issues a v6 test license via admin API", async ({ page }, testInfo) => {+test.describe.serial("V6 license activation flow", () => {+ test.beforeEach(async ({}, testInfo) => {test.skip(- !ADMIN_TOKEN,- "PULSE_LICENSE_ADMIN_TOKEN not set — skipping v6 activation tests",+ !ACTIVATION_KEY,+ "PULSE_E2E_OFFLINE_PRO_ACTIVATION_KEY not set; run through scripts/with-offline-entitlements.mjs",);test.skip(testInfo.project.name.startsWith("mobile-"),"Desktop-only license workflow",);-- const response = await page.request.fetch(- `${LICENSE_SERVER_URL}/v1/licenses/issue`,- {- method: "POST",- headers: {- "Content-Type": "application/json",- "X-API-Token": ADMIN_TOKEN,- },- data: {- generation: "v6",- email: "[email protected]",- tier: "pro",- plan_key: "pro_monthly",- billing_model: "manual",- duration_days: 1,- max_monitored_systems: 0,- max_guests: 0,- max_installations: 3,- send_email: false,- },- },- );-- expect(- [200, 201].includes(response.status()),- `License issue failed: HTTP ${response.status()}`,- ).toBeTruthy();-- const body = (await response.json()) as IssuedLicense;- expect(body.license?.license_id).toBeTruthy();- expect(body.activation_key?.activation_key).toBeTruthy();- expect(body.activation_key.activation_key).toMatch(/^ppk_live_/);-- issuedLicenseId = body.license.license_id;- activationKey = body.activation_key.activation_key;});- test("clears any existing license for a clean slate", async ({- page,- }, testInfo) => {- test.skip(!ADMIN_TOKEN, "PULSE_LICENSE_ADMIN_TOKEN not set");- test.skip(testInfo.project.name.startsWith("mobile-"), "Desktop-only");+ test.afterAll(async ({ browser }) => {+ if (!ACTIVATION_KEY) return;+ // Leave the backend on Community for any later spec, even after a failure.+ const page = await browser.newPage();+ try {+ await ensureAuthenticated(page);+ await apiRequest(page, "/api/license/clear", { method: "POST" });+ } catch {+ // Nothing to clean up if the backend is gone.+ } finally {+ await page.close();+ }+ });+ test("clears any existing license for a clean slate", async ({ page }) => {await ensureAuthenticated(page);const clearRes = await apiRequest(page, "/api/license/clear", {method: "POST",});- expect(- clearRes.ok(),- `Clear license failed: ${clearRes.status()}`,- ).toBeTruthy();-- // Verify we're on the free tier now.- const entRes = await apiRequest(page, "/api/license/entitlements");- expect(entRes.ok()).toBeTruthy();- const ent = (await entRes.json()) as EntitlementPayload;- expect(ent.tier).toBe("free");+ expect(clearRes.ok(), `Clear license failed: ${clearRes.status()}`).toBeTruthy();+ expect((await readEntitlements(page)).tier).toBe("free");});- test("activates v6 license via the Settings UI", async ({- page,- }, testInfo) => {- test.skip(!ADMIN_TOKEN, "PULSE_LICENSE_ADMIN_TOKEN not set");- test.skip(testInfo.project.name.startsWith("mobile-"), "Desktop-only");- test.skip(!activationKey, "No activation key from previous step");-+ test("activates the key via the Settings UI", async ({ page }) => {await ensureAuthenticated(page);- await page.goto("/settings/system/billing/plan?details=recovery");- await expect(- page.getByRole("heading", { name: "Self-hosted plan" }).first(),- ).toBeVisible();+ await page.goto(RECOVERY_ROUTE);+ await expect(page.getByText("Current plan: Community")).toBeVisible({+ timeout: 30_000,+ });await expect(- page.getByRole("heading", { name: "Existing purchases" }),+ page.getByRole("heading", { name: "License recovery" }),).toBeVisible();- // Fill in the activation key.- const textarea = page.locator("#pulse-pro-license-key");- await expect(textarea).toBeVisible();- await textarea.fill(activationKey);-- // Click Activate.- const activateButton = page.getByRole("button", {- name: "Activate Key",- });- await expect(activateButton).toBeEnabled();- await activateButton.click();-- // Wait for activation to complete: poll entitlements until active, which is- // more reliable than matching a transient toast.+ // ?details=recovery opens the manual key disclosure without a click.+ const recovery = licenseRecovery(page);+ await expect(recovery).toHaveAttribute("open", "");+ const keyField = page.locator("#pulse-pro-license-key");+ await expect(keyField).toBeVisible();+ await expect(recovery.getByRole("button", { name: "Clear key" })).toBeDisabled();+ await keyField.fill(ACTIVATION_KEY);++ const applyButton = recovery.getByRole("button", { name: "Apply key" });+ await expect(applyButton).toBeEnabled();+ await applyButton.click();++ // On a community runtime the success summary confirms the licence and+ // points at the private runtime instead of announcing Pro features.+ const summary = page.getByRole("status").filter({ hasText: "Pulse Pro license is active" });+ await expect(summary).toBeVisible({ timeout: 30_000 });+ await expect(summary.getByText(/^The license key was accepted\./)).toBeVisible();await expect- .poll(- async () => {- const res = await apiRequest(page, "/api/license/entitlements");- if (!res.ok()) return "";- const ent = (await res.json()) as EntitlementPayload;- return ent.subscription_state;- },- { timeout: 30_000, message: "License did not activate within timeout" },- )+ .poll(async () => (await readEntitlements(page)).subscription_state, {+ timeout: 30_000,+ message: "License did not activate within timeout",+ }).toBe("active");});- test("verifies activated license in UI and API", async ({- page,- }, testInfo) => {- test.skip(!ADMIN_TOKEN, "PULSE_LICENSE_ADMIN_TOKEN not set");- test.skip(testInfo.project.name.startsWith("mobile-"), "Desktop-only");- test.skip(!activationKey, "No activation key from previous step");-+ test("shows the activated plan in UI and API", async ({ page }) => {await ensureAuthenticated(page);- await page.goto("/settings/system/billing");- await expect(- page.getByRole("heading", { name: "Self-hosted plan" }).first(),- ).toBeVisible();- await expect(- page.getByRole("heading", { name: "Current plan" }),- ).toBeVisible();- await expect(page.getByText("Current plan: Pulse Pro")).toBeVisible();- await expect(page.getByText(/^Active$/).first()).toBeVisible({- timeout: 10_000,+ await page.goto(BILLING_PLAN_ROUTE);+ await expect(page.getByText("Current plan: Pulse Pro")).toBeVisible({+ timeout: 30_000,});- await expect(page.getByText("No Pro license is active.")).toHaveCount(0);- await expect(page.getByText("90-day metric history")).toBeVisible();-- // Verify entitlements API agrees.- const entRes = await apiRequest(page, "/api/license/entitlements");- expect(- entRes.ok(),- `Entitlements request failed: ${entRes.status()}`,- ).toBeTruthy();-- const ent = (await entRes.json()) as EntitlementPayload;+ await expect(page.getByText("Current plan: Community")).toHaveCount(0);+ await expect(page.getByText(/^Active$/).first()).toBeVisible();+ await expect(page.getByText("90-day metric history").first()).toBeVisible();+ // The managed backend is a community build: the licence is accepted, and+ // the page says which runtime the Pro-only hooks need.+ await expect(page.getByText("Pro runtime missing").first()).toBeVisible();+ await expect(page.getByText(LICENSED_EMAIL, { exact: true })).toBeVisible();++ const ent = await readEntitlements(page);expect(ent.tier).toBe("pro");expect(ent.subscription_state).toBe("active");expect(ent.valid).toBe(true);- expect(ent.licensed_email).toBe("[email protected]");+ expect(ent.licensed_email).toBe(LICENSED_EMAIL);- // Core monitoring is unlimited for self-hosted v6 plans.- const agentLimit = ent.limits?.find(- (l) => l.key === "max_monitored_systems",- );- expect(agentLimit).toBeUndefined();-- // Self-hosted v6 plans do not gate child resources like guests either.- const guestLimit = ent.limits?.find((l) => l.key === "max_guests");- expect(guestLimit).toBeUndefined();+ // Self-hosted v6 plans meter neither monitored systems nor guests.+ expect(ent.limits?.find((l) => l.key === "max_monitored_systems")).toBeUndefined();+ expect(ent.limits?.find((l) => l.key === "max_guests")).toBeUndefined();});test("keeps activated installs on BYOK or local AI setup without quickstart", async ({page,- }, testInfo) => {- test.skip(!ADMIN_TOKEN, "PULSE_LICENSE_ADMIN_TOKEN not set");- test.skip(testInfo.project.name.startsWith("mobile-"), "Desktop-only");- test.skip(!activationKey, "No activation key from previous step");-+ }) => {await ensureAuthenticated(page);-- const entRes = await apiRequest(page, "/api/license/entitlements");- expect(- entRes.ok(),- `Entitlements request failed: ${entRes.status()}`,- ).toBeTruthy();- const ent = (await entRes.json()) as EntitlementPayload;- expect(ent.subscription_state).toBe("active");+ expect((await readEntitlements(page)).subscription_state).toBe("active");++ const settingsRes = await apiRequest(page, "/api/settings/ai");+ expect(settingsRes.ok(), `AI settings request failed: ${settingsRes.status()}`).toBeTruthy();+ const settings = await settingsRes.json();+ for (const key of [+ "quickstart_credits_available",+ "quickstart_credits_total",+ "quickstart_credits_remaining",+ "quickstart_blocked_reason",+ ]) {+ expect(settings).not.toHaveProperty(key);+ }await page.goto("/settings/system-ai");await expect(page.getByRole("heading", { name: "Provider & Models" }).first(),).toBeVisible();-- const preSettingsRes = await apiRequest(page, "/api/settings/ai");- expect(- preSettingsRes.ok(),- `AI settings request failed: ${preSettingsRes.status()}`,- ).toBeTruthy();- const preSettings = (await preSettingsRes.json()) as AISettingsPayload;- expect(preSettings).not.toHaveProperty("quickstart_credits_available");- expect(preSettings).not.toHaveProperty("quickstart_credits_total");- expect(preSettings).not.toHaveProperty("quickstart_credits_remaining");- expect(preSettings).not.toHaveProperty("quickstart_blocked_reason");-- const enableAI = page.getByRole("button", {- name: "Enable Assistant and Patrol",- });- await expect(enableAI).toBeVisible();- if (await page.getByText(/^Disabled$/).isVisible()) {- await enableAI.click();- }-- await expect(- page.getByText("Connect a provider to power Pulse Assistant and Patrol."),- ).toBeVisible();await expect(page.getByText(/Patrol quickstart/i)).toHaveCount(0);await page.goto(PATROL_ROUTE);- await expect(- page.getByRole("heading", { name: "Patrol" }).first(),- ).toBeVisible();+ await expect(page.getByRole("heading", { name: "Patrol" }).first()).toBeVisible();await expect(page.getByText(/Patrol quickstart/i)).toHaveCount(0);const patrolStatusRes = await apiRequest(page, "/api/ai/patrol/status");@@ -316,52 +183,28 @@ test.describe.serial("V6 license activation flow", () => {expect(patrolStatus).not.toHaveProperty("quickstart_credits_remaining");});- test("clears license via UI and verifies free tier", async ({- page,- }, testInfo) => {- test.skip(!ADMIN_TOKEN, "PULSE_LICENSE_ADMIN_TOKEN not set");- test.skip(testInfo.project.name.startsWith("mobile-"), "Desktop-only");- test.skip(!activationKey, "No activation key from previous step");-+ test("clears the license via the Settings UI back to Community", async ({ page }) => {await ensureAuthenticated(page);- await page.goto("/settings/system/billing/plan?details=recovery");- await expect(- page.getByRole("heading", { name: "Self-hosted plan" }).first(),- ).toBeVisible();- await expect(- page.getByRole("heading", { name: "Existing purchases" }),- ).toBeVisible();+ await page.goto(RECOVERY_ROUTE);+ await expect(page.getByText("Current plan: Pulse Pro")).toBeVisible({+ timeout: 30_000,+ });- // Set up one-shot dialog handler for the native confirm() prompt.+ // Clearing asks for a native confirm() first.page.once("dialog", (dialog) => dialog.accept());-- // Click Clear License.- const clearButton = page.getByRole("button", { name: "Clear Key" });- await expect(clearButton).toBeEnabled({ timeout: 5_000 });+ const clearButton = licenseRecovery(page).getByRole("button", { name: "Clear key" });+ await expect(clearButton).toBeEnabled();await clearButton.click();- // Wait for success toast.- await expect(page.locator("text=/License cleared/i").first()).toBeVisible({- timeout: 10_000,- });-- // Verify entitlements API reverts to free tier.+ await expect(page.getByText(/License cleared/i).first()).toBeVisible();await expect- .poll(- async () => {- const res = await apiRequest(page, "/api/license/entitlements");- if (!res.ok()) return "";- const ent = (await res.json()) as EntitlementPayload;- return ent.tier;- },- { timeout: 10_000 },- )+ .poll(async () => (await readEntitlements(page)).tier, { timeout: 10_000 }).toBe("free");- // Verify UI shows "No Pro license is active" or free-tier state.await page.reload();- await expect(- page.locator("text=/No Pro license is active/i").first(),- ).toBeVisible({ timeout: 10_000 });+ await expect(page.getByText("Current plan: Community")).toBeVisible({+ timeout: 30_000,+ });+ await expect(page.getByText("Current plan: Pulse Pro")).toHaveCount(0);});});diff --git a/tests/integration/tests/11-first-session.spec.ts b/tests/integration/tests/11-first-session.spec.tsindex d61b5bcaaa..89c1b0b7c1 100644--- a/tests/integration/tests/11-first-session.spec.ts+++ b/tests/integration/tests/11-first-session.spec.ts@@ -465,9 +465,7 @@ test.describe.serial("First-session experience", () => {// content. Scope assertions to main content, not the settings sidebar.const licenseContent = page.getByRole("main")- .getByText(- /Current plan|Existing purchases|Use existing key|activation key/i,- )+ .getByText(/Current plan|License recovery/i).first();await expect(licenseContent,