mirror of
https://github.com/penpot/penpot.git
synced 2026-11-20 17:11:15 +00:00
Move the pure subscription rules out of the browser specs and into unit tests, then keep only the cases a browser can prove. - Extract show-manage-subscription-link? and show-main-menu-power-up? from the dashboard team panel and the workspace main menu, and use them at both call sites. A new subscription_dashboard_test.cljs covers which plan a subscription reads to, including unpaid and canceled demotion, the owner and enterprise sides of both affordances, and the banner and members-CTA boundaries: four editors over the seats, no usage data, and the demoted plans. - Add get-versions-stored-days tests to workspace_versions_test.cljs: an active nitrate or enterprise license keeps 90 days, a canceled one lets the team plan decide, a license without the admin console does not count, and unlimited, enterprise, professional and planless teams keep 30, 90 and 7 days. - Rewrite the profile usage tests as async tests with mock/with-mocks* and an async transport double: the editors from the usage call reach [:props :subscription :editors], a failing call leaves the profile untouched and logs once, and the call is skipped without the subscriptions flag. - Cut the e2e suite from 13 cases to 7. Five dashboard cases keep the menu icon, the two sidebar plan names, the owner-only settings link and the members CTA; two workspace cases keep the translated days warning with the upsell step and the enterprise menu with no upsell. Assert the unlimited glyph and drop the CTA count. - Drop the three get-team-info mocks the dashboard never calls and six unreferenced subscription fixtures, reusing the invitations fixture. - Sort the subscription test requires in runner.cljs: cljfmt's :sort-ns-references? wants subscription-dashboard-test first. Closes #13005 AI-assisted-by: deepseek-v4.1-flash
99 lines
2.7 KiB
JavaScript
99 lines
2.7 KiB
JavaScript
import { test, expect } from "@playwright/test";
|
|
import { WasmWorkspacePage } from "../pages/WasmWorkspacePage";
|
|
|
|
// The stored-days rule and the plan the menu reads are pure functions with
|
|
// unit tests of their own. These specs prove the workspace passes the
|
|
// computed days into the translated warning and gates the upsell entry.
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await WasmWorkspacePage.init(page);
|
|
await WasmWorkspacePage.mockConfigFlags(page, [
|
|
"enable-subscriptions",
|
|
"disable-onboarding",
|
|
]);
|
|
});
|
|
|
|
test.describe("Subscriptions: workspace", () => {
|
|
test("An unlimited team keeps 30 days of autosaved versions", async ({
|
|
page,
|
|
}) => {
|
|
const workspacePage = new WasmWorkspacePage(page);
|
|
await workspacePage.setupEmptyFile();
|
|
|
|
await WasmWorkspacePage.mockRPC(
|
|
page,
|
|
"get-profile",
|
|
"subscription/get-profile-unlimited-subscription.json",
|
|
);
|
|
|
|
await WasmWorkspacePage.mockRPC(
|
|
page,
|
|
"get-subscription-usage",
|
|
"subscription/get-subscription-usage.json",
|
|
);
|
|
|
|
await WasmWorkspacePage.mockRPC(
|
|
page,
|
|
"get-teams",
|
|
"subscription/get-teams-unlimited-one-team.json",
|
|
);
|
|
|
|
await workspacePage.mockRPC(
|
|
"push-audit-events",
|
|
"workspace/audit-event-empty.json",
|
|
);
|
|
await workspacePage.goToWorkspace();
|
|
|
|
await workspacePage.mockRPC(
|
|
"get-file-snapshots?file-id=*",
|
|
"workspace/versions-snapshot-1.json",
|
|
);
|
|
|
|
await page.getByLabel("History").click();
|
|
|
|
await expect(
|
|
page.getByText("Autosaved versions will be kept for 30 days."),
|
|
).toBeVisible();
|
|
|
|
await test.step("the main menu offers the plan upsell", async () => {
|
|
await page.getByRole("button", { name: "Main menu" }).click();
|
|
await expect(
|
|
page.getByRole("menuitem", { name: "Power up your plan" }),
|
|
).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test("An enterprise team has no plan upsell in the main menu", async ({
|
|
page,
|
|
}) => {
|
|
const workspacePage = new WasmWorkspacePage(page);
|
|
await workspacePage.setupEmptyFile();
|
|
|
|
await WasmWorkspacePage.mockRPC(
|
|
page,
|
|
"get-profile",
|
|
"subscription/get-profile-enterprise-subscription.json",
|
|
);
|
|
|
|
await WasmWorkspacePage.mockRPC(
|
|
page,
|
|
"get-subscription-usage",
|
|
"subscription/get-subscription-usage.json",
|
|
);
|
|
|
|
await workspacePage.mockRPC(
|
|
"push-audit-events",
|
|
"workspace/audit-event-empty.json",
|
|
);
|
|
await workspacePage.goToWorkspace();
|
|
|
|
await page.getByRole("button", { name: "Main menu" }).click();
|
|
|
|
// The menu is open, so the absence below means something.
|
|
await expect(page.getByTestId("help-info")).toBeVisible();
|
|
await expect(
|
|
page.getByRole("menuitem", { name: "Power up your plan" }),
|
|
).toHaveCount(0);
|
|
});
|
|
});
|