From d6e816daa045146f5e8c919ceed0aa0ec375662f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 20 Nov 2026 13:45:59 +0100 Subject: [PATCH] :sparkles: Cover subscription rules with unit tests and trim e2e specs (#13006) 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 --- ...file-enterprise-canceled-subscription.json | 25 -- .../get-team-info-subscription.json | 4 - .../get-team-members-more-than-8.json | 128 -------- .../get-team-members-subscription-member.json | 44 --- .../get-teams-enterprise-one-team.json | 28 -- ...teams-professional-subscription-owner.json | 53 ---- .../ui/specs/subscriptions-dashboard.spec.js | 284 ++++-------------- .../ui/specs/subscriptions-workspace.spec.js | 126 ++------ .../app/main/ui/dashboard/subscription.cljs | 17 +- .../src/app/main/ui/workspace/main_menu.cljs | 7 +- .../frontend_tests/data/profile_test.cljs | 57 +++- .../data/workspace_versions_test.cljs | 52 ++++ frontend/test/frontend_tests/runner.cljs | 2 + .../ui/subscription_dashboard_test.cljs | 195 ++++++++++++ 14 files changed, 405 insertions(+), 617 deletions(-) delete mode 100644 frontend/playwright/data/subscription/get-profile-enterprise-canceled-subscription.json delete mode 100644 frontend/playwright/data/subscription/get-team-info-subscription.json delete mode 100644 frontend/playwright/data/subscription/get-team-members-more-than-8.json delete mode 100644 frontend/playwright/data/subscription/get-team-members-subscription-member.json delete mode 100644 frontend/playwright/data/subscription/get-teams-enterprise-one-team.json delete mode 100644 frontend/playwright/data/subscription/get-teams-professional-subscription-owner.json create mode 100644 frontend/test/frontend_tests/ui/subscription_dashboard_test.cljs diff --git a/frontend/playwright/data/subscription/get-profile-enterprise-canceled-subscription.json b/frontend/playwright/data/subscription/get-profile-enterprise-canceled-subscription.json deleted file mode 100644 index 4273ee2012..0000000000 --- a/frontend/playwright/data/subscription/get-profile-enterprise-canceled-subscription.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "~:email": "foo@example.com", - "~:is-demo": false, - "~:auth-backend": "penpot", - "~:fullname": "Princesa Leia", - "~:modified-at": "~m1713533116365", - "~:is-active": true, - "~:default-project-id": "~uc7ce0794-0992-8105-8004-38e630f7920b", - "~:id": "~uc7ce0794-0992-8105-8004-38e630f29a9b", - "~:is-muted": false, - "~:default-team-id": "~uc7ce0794-0992-8105-8004-38e630f40f6d", - "~:created-at": "~m1713533116365", - "~:is-blocked": false, - "~:props": { - "~:subscription": { - "~:quantity": 2, - "~:status": "canceled", - "~:type": "enterprise", - "~start-date": "~m1746444667" - }, - "~:v2-info-shown": true, - "~:viewed-tutorial?": false, - "~:viewed-walkthrough?": false - } -} diff --git a/frontend/playwright/data/subscription/get-team-info-subscription.json b/frontend/playwright/data/subscription/get-team-info-subscription.json deleted file mode 100644 index c3ea011ec0..0000000000 --- a/frontend/playwright/data/subscription/get-team-info-subscription.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "~:id": "~uc7ce0794-0992-8105-8004-38e630f7920a", - "~:is-default": false -} diff --git a/frontend/playwright/data/subscription/get-team-members-more-than-8.json b/frontend/playwright/data/subscription/get-team-members-more-than-8.json deleted file mode 100644 index 5679420fb1..0000000000 --- a/frontend/playwright/data/subscription/get-team-members-more-than-8.json +++ /dev/null @@ -1,128 +0,0 @@ -[ - { - "~:is-admin": true, - "~:email": "bar@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Han Solo", - "~:fullname": "Han Solo", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u1e162163-87b7-805b-8005-5fd05514b6d3", - "~:profile-id": "~u1e162163-87b7-805b-8005-5fd05514b6d3", - "~:created-at": "~m1733324626956" - }, - { - "~:is-admin": true, - "~:email": "foo@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Princesa Leia", - "~:fullname": "Princesa Leia", - "~:is-owner": true, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~uc7ce0794-0992-8105-8004-38e630f29a9b", - "~:profile-id": "~uf56647eb-19a7-8115-8003-b6bc939ecd1b", - "~:created-at": "~m1713533116365" - }, - { - "~:is-admin": false, - "~:email": "luke@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Luke Skywalker", - "~:fullname": "Luke Skywalker", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u3a1b2c3d-1234-5678-8001-abcdefabcdef", - "~:profile-id": "~u3a1b2c3d-1234-5678-8001-abcdefabcdef", - "~:created-at": "~m1713533116365" - }, - { - "~:is-admin": false, - "~:email": "chewie@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Chewbacca", - "~:fullname": "Chewbacca", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u4b2c3d4e-2345-6789-8002-bcdefabcdefa", - "~:profile-id": "~u4b2c3d4e-2345-6789-8002-bcdefabcdefa", - "~:created-at": "~m1713533116365" - }, - { - "~:is-admin": false, - "~:email": "lando@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Lando Calrissian", - "~:fullname": "Lando Calrissian", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u5c3d4e5f-3456-7890-8003-cdefabcdefab", - "~:profile-id": "~u5c3d4e5f-3456-7890-8003-cdefabcdefab", - "~:created-at": "~m1713533116365" - }, - { - "~:is-admin": false, - "~:email": "r2d2@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "R2-D2", - "~:fullname": "R2-D2", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u6d4e5f6a-4567-8901-8004-defabcdefabc", - "~:profile-id": "~u6d4e5f6a-4567-8901-8004-defabcdefabc", - "~:created-at": "~m1713533116365" - }, - { - "~:is-admin": false, - "~:email": "c3po@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "C-3PO", - "~:fullname": "C-3PO", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u7e5f6a7b-5678-9012-8005-efabcdefabcd", - "~:profile-id": "~u7e5f6a7b-5678-9012-8005-efabcdefabcd", - "~:created-at": "~m1713533116365" - }, - { - "~:is-admin": false, - "~:email": "ben@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Ben Kenobi", - "~:fullname": "Ben Kenobi", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u8f6a7b8c-6789-0123-8006-fabcdefabcde", - "~:profile-id": "~u8f6a7b8c-6789-0123-8006-fabcdefabcde", - "~:created-at": "~m1713533116365" - }, - { - "~:is-admin": false, - "~:email": "yoda@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Yoda", - "~:fullname": "Yoda", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u9a7b8c9d-7890-1234-8007-abcdefabcdef", - "~:profile-id": "~u9a7b8c9d-7890-1234-8007-abcdefabcdef", - "~:created-at": "~m1713533116365" - } -] diff --git a/frontend/playwright/data/subscription/get-team-members-subscription-member.json b/frontend/playwright/data/subscription/get-team-members-subscription-member.json deleted file mode 100644 index 6296730aa5..0000000000 --- a/frontend/playwright/data/subscription/get-team-members-subscription-member.json +++ /dev/null @@ -1,44 +0,0 @@ -[ - { - "~:is-admin": true, - "~:email": "bar@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Han Solo", - "~:fullname": "Han Solo", - "~:is-owner": true, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u1e162163-87b7-805b-8005-5fd05514b6d3", - "~:profile-id": "~u1e162163-87b7-805b-8005-5fd05514b6d3", - "~:created-at": "~m1733324626956" - }, - { - "~:is-admin": true, - "~:email": "foo@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Princesa Leia", - "~:fullname": "Princesa Leia", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~uc7ce0794-0992-8105-8004-38e630f29a9b", - "~:profile-id": "~uf56647eb-19a7-8115-8003-b6bc939ecd1b", - "~:created-at": "~m1713533116365" - }, - { - "~:is-admin": false, - "~:email": "luke@example.com", - "~:team-id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:name": "Luke Skywalker", - "~:fullname": "Luke Skywalker", - "~:is-owner": false, - "~:modified-at": "~m1713533116365", - "~:can-edit": true, - "~:is-active": true, - "~:id": "~u123456789-0000-0000-0000-abcdefabcdef", - "~:profile-id": "~u123456789-0000-0000-0000-abcdefabcdef", - "~:created-at": "~m1713533116365" - } -] diff --git a/frontend/playwright/data/subscription/get-teams-enterprise-one-team.json b/frontend/playwright/data/subscription/get-teams-enterprise-one-team.json deleted file mode 100644 index e920218115..0000000000 --- a/frontend/playwright/data/subscription/get-teams-enterprise-one-team.json +++ /dev/null @@ -1,28 +0,0 @@ -[{ - "~:features": { - "~#set": [ - "layout/grid", - "styles/v2", - "fdata/pointer-map", - "fdata/objects-map", - "components/v2", - "fdata/shape-data-type" - ] - }, - "~:permissions": { - "~:type": "~:membership", - "~:is-owner": true, - "~:is-admin": true, - "~:can-edit": true - }, - "~:subscription": { - "~:type": "enterprise", - "~:status": "trialing", - "~:seats": null - }, - "~:name": "Default", - "~:modified-at": "~m1713533116375", - "~:id": "~uc7ce0794-0992-8105-8004-38e630f7920a", - "~:created-at": "~m1713533116375", - "~:is-default": true -}] diff --git a/frontend/playwright/data/subscription/get-teams-professional-subscription-owner.json b/frontend/playwright/data/subscription/get-teams-professional-subscription-owner.json deleted file mode 100644 index ff228ab2f3..0000000000 --- a/frontend/playwright/data/subscription/get-teams-professional-subscription-owner.json +++ /dev/null @@ -1,53 +0,0 @@ -[ - { - "~:features": { - "~#set": [ - "layout/grid", - "styles/v2", - "fdata/pointer-map", - "fdata/objects-map", - "components/v2", - "fdata/shape-data-type" - ] - }, - "~:permissions": { - "~:type": "~:owner", - "~:is-owner": true, - "~:is-admin": true, - "~:can-edit": true - }, - "~:name": "Default", - "~:modified-at": "~m1713533116375", - "~:id": "~uc7ce0794-0992-8105-8004-38e630f40f6d", - "~:created-at": "~m1713533116375", - "~:is-default": true - }, - { - "~:features": { - "~#set": [ - "layout/grid", - "styles/v2", - "fdata/pointer-map", - "fdata/objects-map", - "components/v2", - "fdata/shape-data-type" - ] - }, - "~:permissions": { - "~:type": "~:membership", - "~:is-owner": true, - "~:is-admin": true, - "~:can-edit": true - }, - "~:subscription": { - "~:type": "professional", - "~:status": "active", - "~:seats": null - }, - "~:name": "Second team", - "~:modified-at": "~m1701164272671", - "~:id": "~udd33ff88-f4e5-8033-8003-8096cc07bdf3", - "~:created-at": "~m1701164272671", - "~:is-default": false - } -] diff --git a/frontend/playwright/ui/specs/subscriptions-dashboard.spec.js b/frontend/playwright/ui/specs/subscriptions-dashboard.spec.js index 15f312bbd5..c1bf25ed50 100644 --- a/frontend/playwright/ui/specs/subscriptions-dashboard.spec.js +++ b/frontend/playwright/ui/specs/subscriptions-dashboard.spec.js @@ -1,6 +1,11 @@ import { test, expect } from "@playwright/test"; import DashboardPage from "../pages/DashboardPage"; +// These specs prove the wiring between the mocked RPC data and what the +// dashboard renders: the plan icon, the sidebar plan name, the team +// settings link and the members CTAs. The rules themselves are pure +// functions with unit tests of their own. + test.beforeEach(async ({ page }) => { await DashboardPage.init(page); await DashboardPage.mockConfigFlags(page, [ @@ -9,6 +14,37 @@ test.beforeEach(async ({ page }) => { ]); }); +async function setupTeamSettings(page, { profile, teams, members }) { + await DashboardPage.mockRPC(page, "get-profile", profile); + + await DashboardPage.mockRPC( + page, + "get-subscription-usage", + "subscription/get-subscription-usage.json", + ); + + const dashboardPage = new DashboardPage(page); + await dashboardPage.setupDashboardFull(); + await DashboardPage.mockRPC(page, "get-teams", teams); + + await DashboardPage.mockRPC( + page, + "get-projects?team-id=*", + "dashboard/get-projects-second-team.json", + ); + + await DashboardPage.mockRPC(page, "get-team-members?team-id=*", members); + await dashboardPage.setupTeamSettings(); + + await dashboardPage.mockRPC( + "push-audit-events", + "workspace/audit-event-empty.json", + ); + + await dashboardPage.goToSecondTeamSettingsSection(); + return dashboardPage; +} + test("Team with unlimited subscription has specific icon in menu", async ({ page, }) => { @@ -24,12 +60,6 @@ test("Team with unlimited subscription has specific icon in menu", async ({ "subscription/get-subscription-usage.json", ); - await DashboardPage.mockRPC( - page, - "get-team-info", - "subscription/get-team-info-subscriptions.json", - ); - const dashboardPage = new DashboardPage(page); await dashboardPage.setupDashboardFull(); await DashboardPage.mockRPC( @@ -48,7 +78,12 @@ test("Team with unlimited subscription has specific icon in menu", async ({ "workspace/audit-event-empty.json", ); await dashboardPage.goToSecondTeamDashboard(); - await expect(page.getByTestId("subscription-icon")).toBeVisible(); + const icon = page.getByTestId("subscription-icon"); + await expect(icon).toBeVisible(); + await expect(icon.locator("use")).toHaveAttribute( + "href", + "#icon-character-u", + ); }); test("The Unlimited subscription has its name in the sidebar dropdown", async ({ @@ -66,12 +101,6 @@ test("The Unlimited subscription has its name in the sidebar dropdown", async ({ "subscription/get-subscription-usage-one-editor.json", ); - await DashboardPage.mockRPC( - page, - "get-team-info", - "subscription/get-team-info-subscriptions.json", - ); - const dashboardPage = new DashboardPage(page); await dashboardPage.setupDashboardFull(); await DashboardPage.mockRPC( @@ -91,7 +120,7 @@ test("The Unlimited subscription has its name in the sidebar dropdown", async ({ ); }); -test("The sidebar dropdown displays the correct subscription name when status is Unpaid", async ({ +test("An unpaid subscription reads as professional in the sidebar dropdown", async ({ page, }) => { await DashboardPage.mockRPC( @@ -106,12 +135,6 @@ test("The sidebar dropdown displays the correct subscription name when status is "subscription/get-subscription-usage.json", ); - await DashboardPage.mockRPC( - page, - "get-team-info", - "subscription/get-team-info-subscriptions.json", - ); - const dashboardPage = new DashboardPage(page); await dashboardPage.setupDashboardFull(); await DashboardPage.mockRPC( @@ -131,106 +154,37 @@ test("The sidebar dropdown displays the correct subscription name when status is ); }); -test("The sidebar dropdown displays the correct subscription name when status is cancelled", async ({ +test("Team settings shows the plan and hides the manage link from members", async ({ page, }) => { - await DashboardPage.mockRPC( - page, - "get-profile", - "subscription/get-profile-enterprise-canceled-subscription.json", - ); + const dashboardPage = await setupTeamSettings(page, { + profile: "logged-in-user/get-profile-logged-in.json", + teams: "subscription/get-teams-unlimited-subscription-member.json", + members: "dashboard/get-team-members-admin.json", + }); - await DashboardPage.mockRPC( - page, - "get-subscription-usage", - "subscription/get-subscription-usage.json", - ); + await expect(page.getByText("Unlimited (trial)")).toBeVisible(); + await expect(page.getByTestId("manage-subscription-link")).toHaveCount(0); - await DashboardPage.mockRPC( - page, - "get-team-info", - "subscription/get-team-info-subscriptions.json", - ); - - const dashboardPage = new DashboardPage(page); - await dashboardPage.setupDashboardFull(); + // The same team read as an owner shows the link, so the component gets + // the permission from the team and not from a constant. await DashboardPage.mockRPC( page, "get-teams", "subscription/get-teams-unlimited-subscription-owner.json", ); - - await dashboardPage.mockRPC( - "push-audit-events", - "workspace/audit-event-empty.json", - ); - await dashboardPage.goToDashboard(); - - await expect(page.getByTestId("subscription-name")).toHaveText( - "Professional plan", - ); -}); - -test("Team settings has susbscription name and no manage subscription link when is member", async ({ - page, -}) => { - await DashboardPage.mockRPC( - page, - "get-profile", - "logged-in-user/get-profile-logged-in.json", - ); - - await DashboardPage.mockRPC( - page, - "get-subscription-usage", - "subscription/get-subscription-usage.json", - ); - - await DashboardPage.mockRPC( - page, - "get-team-info", - "subscription/get-team-info-subscriptions.json", - ); - - const dashboardPage = new DashboardPage(page); - await dashboardPage.setupDashboardFull(); - await DashboardPage.mockRPC( - page, - "get-teams", - "subscription/get-teams-unlimited-subscription-member.json", - ); - - await DashboardPage.mockRPC( - page, - "get-projects?team-id=*", - "dashboard/get-projects-second-team.json", - ); - await DashboardPage.mockRPC( page, "get-team-members?team-id=*", - "subscription/get-team-members-subscription-member.json", + "dashboard/get-team-members-owner.json", ); - - await DashboardPage.mockRPC( - page, - "get-team-stats?team-id=*", - "dashboard/get-team-stats.json", - ); - - await dashboardPage.mockRPC( - "push-audit-events", - "workspace/audit-event-empty.json", - ); - await dashboardPage.goToSecondTeamSettingsSection(); + await expect(page.getByText("Unlimited (trial)")).toBeVisible(); - await expect( - page.getByRole("button", { name: "Manage your subscription" }), - ).not.toBeVisible(); + await expect(page.getByTestId("manage-subscription-link")).toBeVisible(); }); -test("Team settings has susbscription name and manage subscription link when is owner", async ({ +test("Members and Invitations tabs warn when editors exceed seats", async ({ page, }) => { await DashboardPage.mockRPC( @@ -245,72 +199,6 @@ test("Team settings has susbscription name and manage subscription link when is "subscription/get-subscription-usage.json", ); - await DashboardPage.mockRPC( - page, - "get-team-info", - "subscription/get-team-info-subscriptions.json", - ); - - const dashboardPage = new DashboardPage(page); - await dashboardPage.setupDashboardFull(); - await DashboardPage.mockRPC( - page, - "get-teams", - "subscription/get-teams-unlimited-subscription-owner.json", - ); - - await DashboardPage.mockRPC( - page, - "get-projects?team-id=*", - "dashboard/get-projects-second-team.json", - ); - - await DashboardPage.mockRPC( - page, - "get-team-members?team-id=*", - "subscription/get-team-members-subscription-owner.json", - ); - - await DashboardPage.mockRPC( - page, - "get-team-stats?team-id=*", - "dashboard/get-team-stats.json", - ); - - await dashboardPage.mockRPC( - "push-audit-events", - "workspace/audit-event-empty.json", - ); - - await dashboardPage.goToSecondTeamSettingsSection(); - - await expect(page.getByText("Unlimited (trial)")).toBeVisible(); - await expect( - page.getByRole("button", { name: "Manage your subscription" }), - ).toBeVisible(); -}); - -test("Members tab has warning message when user has more seats than editors", async ({ - page, -}) => { - await DashboardPage.mockRPC( - page, - "get-profile", - "subscription/get-profile-unlimited-subscription.json", - ); - - await DashboardPage.mockRPC( - page, - "get-subscription-usage", - "subscription/get-subscription-usage.json", - ); - - await DashboardPage.mockRPC( - page, - "get-team-info", - "subscription/get-team-info-subscriptions.json", - ); - const dashboardPage = new DashboardPage(page); await dashboardPage.setupDashboardFull(); await DashboardPage.mockRPC( @@ -338,70 +226,24 @@ test("Members tab has warning message when user has more seats than editors", as await dashboardPage.goToSecondTeamMembersSection(); - const ctas = page.getByTestId("cta"); - await expect(ctas).toHaveCount(2); + // The sidebar banner and the members CTA, in that order. + await expect( + page.getByText("Your team keeps growing!", { exact: false }), + ).toBeVisible(); await expect( page.getByText("Inviting people while on the unlimited plan"), ).toBeVisible(); -}); - -test("Invitations tab has warning message when user has more seats than editors", async ({ - page, -}) => { - await DashboardPage.mockRPC( - page, - "get-profile", - "subscription/get-profile-unlimited-subscription.json", - ); - - await DashboardPage.mockRPC( - page, - "get-subscription-usage", - "subscription/get-subscription-usage.json", - ); - - await DashboardPage.mockRPC( - page, - "get-team-info", - "subscription/get-team-info-subscriptions.json", - ); - - const dashboardPage = new DashboardPage(page); - await dashboardPage.setupDashboardFull(); - await DashboardPage.mockRPC( - page, - "get-teams", - "subscription/get-teams-unlimited-subscription-owner.json", - ); - - await DashboardPage.mockRPC( - page, - "get-projects?team-id=*", - "dashboard/get-projects-second-team.json", - ); - - await DashboardPage.mockRPC( - page, - "get-team-members?team-id=*", - "subscription/get-team-members-subscription-eight-member.json", - ); + await expect(page.getByTestId("cta")).toHaveCount(2); await DashboardPage.mockRPC( page, "get-team-invitations?team-id=*", "subscription/get-team-invitations.json", ); - - await dashboardPage.mockRPC( - "push-audit-events", - "workspace/audit-event-empty.json", - ); - await dashboardPage.goToSecondTeamInvitationsSection(); - const ctas = page.getByTestId("cta"); - await expect(ctas).toHaveCount(2); await expect( page.getByText("Inviting people while on the unlimited plan"), ).toBeVisible(); + await expect(page.getByTestId("cta")).toHaveCount(2); }); diff --git a/frontend/playwright/ui/specs/subscriptions-workspace.spec.js b/frontend/playwright/ui/specs/subscriptions-workspace.spec.js index 765481d1f3..bca91dc745 100644 --- a/frontend/playwright/ui/specs/subscriptions-workspace.spec.js +++ b/frontend/playwright/ui/specs/subscriptions-workspace.spec.js @@ -1,6 +1,10 @@ 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, [ @@ -10,99 +14,7 @@ test.beforeEach(async ({ page }) => { }); test.describe("Subscriptions: workspace", () => { - test("Unlimited team should have 'Power up your plan' link in main menu", 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 workspacePage.mockRPC( - "push-audit-events", - "workspace/audit-event-empty.json", - ); - await workspacePage.goToWorkspace(); - await page.getByRole("button", { name: "Main menu" }).click(); - - await expect(page.getByText("Power up your plan")).toBeVisible(); - }); - - test("Enterprise team should not have 'Power up your plan' link in 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(); - - await expect(page.getByText("Power up your plan")).not.toBeVisible(); - }); - - test("Professional team should have 7 days autosaved versions", 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 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 7 days."), - ).toBeVisible(); - }); - - test("Unlimited team should have 30 days autosaved versions", async ({ + test("An unlimited team keeps 30 days of autosaved versions", async ({ page, }) => { const workspacePage = new WasmWorkspacePage(page); @@ -142,9 +54,16 @@ test.describe("Subscriptions: workspace", () => { 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("Unlimited team should have 90 days autosaved versions", async ({ + test("An enterprise team has no plan upsell in the main menu", async ({ page, }) => { const workspacePage = new WasmWorkspacePage(page); @@ -162,27 +81,18 @@ test.describe("Subscriptions: workspace", () => { "subscription/get-subscription-usage.json", ); - await WasmWorkspacePage.mockRPC( - page, - "get-teams", - "subscription/get-teams-enterprise-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 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.getByText("Autosaved versions will be kept for 90 days."), - ).toBeVisible(); + page.getByRole("menuitem", { name: "Power up your plan" }), + ).toHaveCount(0); }); }); diff --git a/frontend/src/app/main/ui/dashboard/subscription.cljs b/frontend/src/app/main/ui/dashboard/subscription.cljs index d983f789ac..3880f7844a 100644 --- a/frontend/src/app/main/ui/dashboard/subscription.cljs +++ b/frontend/src/app/main/ui/dashboard/subscription.cljs @@ -50,6 +50,21 @@ (not (contains? #{"enterprise" "nitrate"} (get-subscription-type (:subscription team)))))) +(defn show-manage-subscription-link? + "Only the owner of a plan other than professional manages the subscription + from the team settings; a professional plan has its own upgrade path." + [is-owner subscription] + (and (boolean is-owner) + (not= "professional" (get-subscription-type subscription)))) + +(defn show-main-menu-power-up? + "The workspace menu offers the plan upsell on every plan but enterprise; + the admin console keeps it as the way into the subscription settings." + [flags subscription-type] + (or (and (contains? flags :subscriptions) + (not= "enterprise" subscription-type)) + (contains? flags :admin-console))) + (mf/defc cta-power-up* [{:keys [top-title top-description bottom-description bottom-button bottom-button-href has-dropdown is-highlighted]}] (let [show-data* (mf/use-state false) @@ -362,7 +377,7 @@ (tr "subscription.settings.unlimited")) "enterprise" (tr "subscription.settings.enterprise"))] - (when (and is-owner (not= subscription-type "professional")) + (when (show-manage-subscription-link? is-owner subscription) [:button {:class (stl/css :manage-subscription-link) :on-click go-to-manage-subscription :data-testid "manage-subscription-link"} diff --git a/frontend/src/app/main/ui/workspace/main_menu.cljs b/frontend/src/app/main/ui/workspace/main_menu.cljs index e851919fe4..6439de6ef5 100644 --- a/frontend/src/app/main/ui/workspace/main_menu.cljs +++ b/frontend/src/app/main/ui/workspace/main_menu.cljs @@ -37,7 +37,8 @@ dropdown-menu-item*]] [app.main.ui.context :as ctx] [app.main.ui.dashboard.subscription :refer [get-subscription-type - main-menu-power-up*]] + main-menu-power-up* + show-main-menu-power-up?]] [app.main.ui.ds.buttons.icon-button :refer [icon-button*]] [app.main.ui.ds.foundations.assets.icon :as i :refer [icon*]] [app.main.ui.hooks.resize :as r] @@ -1126,9 +1127,7 @@ [:> icon* {:icon-id i/arrow-right :class (stl/css :item-arrow)}]] - (when (or (and (contains? cf/flags :subscriptions) - (not= "enterprise" subscription-type)) - (contains? cf/flags :admin-console)) + (when (show-main-menu-power-up? cf/flags subscription-type) [:> main-menu-power-up* {:close-sub-menu close-sub-menu}])] (case selected-sub-menu diff --git a/frontend/test/frontend_tests/data/profile_test.cljs b/frontend/test/frontend_tests/data/profile_test.cljs index f24c2d87f2..5562f9c630 100644 --- a/frontend/test/frontend_tests/data/profile_test.cljs +++ b/frontend/test/frontend_tests/data/profile_test.cljs @@ -7,8 +7,13 @@ (ns frontend-tests.data.profile-test (:require [app.common.uuid :as uuid] + [app.config :as cf] [app.main.data.profile :as dprof] - [cljs.test :as t :include-macros true])) + [app.main.repo :as rp] + [beicon.v2.core :as rx] + [cljs.test :as t :include-macros true] + [frontend-tests.helpers.async :as async] + [frontend-tests.helpers.mock :as mock])) (t/deftest profile-update-params-omits-nil-values (t/is (= {:fullname "Updated Name"} @@ -28,3 +33,53 @@ (t/is (some? (dprof/update-profile {:id uuid/zero :fullname "Updated Name" :theme nil})))) + +;; The editors from the usage call reach the profile so the dashboard +;; predicates can count them; a failure must leave the profile untouched. + +(defn- authenticated-profile + [subscription] + {:id (uuid/next) + :props {:subscription subscription}}) + +(t/deftest ^:async fetching-the-profile-copies-the-editors-from-the-usage-call + (let [editors [{:id (uuid/next) :name "Leia"}] + profile (authenticated-profile {:quantity 2}) + result (await + (mock/with-mocks* + {cf/flags (conj cf/flags :subscriptions) + rp/cmd! (mock/stub + (fn [_ _] + (->> (rx/of {:editors editors}) + (rx/observe-on :async))))} + (await (async/->promise (dprof/on-fetch-profile-success profile)))))] + (t/is (= editors (get-in result [:props :subscription :editors]))))) + +(t/deftest ^:async a-failing-usage-call-keeps-the-profile + (let [profile (authenticated-profile {:quantity 2}) + errors (atom 0) + previous-error (.-error js/console)] + (try + (set! (.-error js/console) (fn [& _] (swap! errors inc))) + (let [result (await + (mock/with-mocks* + {cf/flags (conj cf/flags :subscriptions) + rp/cmd! (mock/stub + (fn [_ _] + (->> (rx/throw (ex-info "boom" {})) + (rx/observe-on :async))))} + (await (async/->promise (dprof/on-fetch-profile-success profile)))))] + (t/is (= profile result)) + (t/is (= 1 @errors))) + (finally + (set! (.-error js/console) previous-error))))) + +(t/deftest ^:async without-the-subscriptions-flag-the-usage-call-is-skipped + (let [profile (authenticated-profile {:quantity 2}) + result (await + (mock/with-mocks* + {cf/flags (disj cf/flags :subscriptions) + rp/cmd! mock/rpc-cmd-mock} + (await (async/->promise (dprof/on-fetch-profile-success profile)))))] + (t/is (empty? @mock/rpc-calls)) + (t/is (= profile result)))) diff --git a/frontend/test/frontend_tests/data/workspace_versions_test.cljs b/frontend/test/frontend_tests/data/workspace_versions_test.cljs index 0bac593c0b..011a78dc2f 100644 --- a/frontend/test/frontend_tests/data/workspace_versions_test.cljs +++ b/frontend/test/frontend_tests/data/workspace_versions_test.cljs @@ -8,6 +8,7 @@ (:require [app.common.time :as ct] [app.common.uuid :as uuid] + [app.config :as cf] [app.main.data.changes :as dch] [app.main.data.notifications :as ntf] [app.main.data.persistence :as dps] @@ -69,6 +70,57 @@ (t/is (not (versions/repair-snapshot? {:label "My version" :created-by "user"}))) (t/is (not (versions/repair-snapshot? {:created-by "user"})))) +(defn- stored-days + [flags team profile] + (with-redefs [cf/flags flags] + (#'versions-ui/get-versions-stored-days team profile))) + +(def ^:private admin-console-flags + (conj cf/flags :admin-console)) + +(def ^:private no-admin-console-flags + (disj cf/flags :admin-console)) + +(t/deftest an-active-nitrate-license-keeps-ninety-days + (t/is (= 90 (stored-days admin-console-flags + {:subscription {:type "unlimited" :status "active"}} + {:subscription {:type "nitrate" :status "active"}})))) + +(t/deftest an-active-enterprise-license-keeps-ninety-days + (t/is (= 90 (stored-days admin-console-flags + {:subscription {:type "unlimited" :status "active"}} + {:subscription {:type "enterprise" :status "active"}})))) + +(t/deftest a-canceled-license-leaves-the-team-plan-in-charge + (t/is (= 30 (stored-days admin-console-flags + {:subscription {:type "unlimited" :status "active"}} + {:subscription {:type "nitrate" :status "canceled"}})))) + +(t/deftest a-license-without-the-admin-console-does-not-count + (t/is (= 30 (stored-days no-admin-console-flags + {:subscription {:type "unlimited" :status "active"}} + {:subscription {:type "nitrate" :status "active"}})))) + +(t/deftest an-unlimited-team-keeps-thirty-days + (t/is (= 30 (stored-days no-admin-console-flags + {:subscription {:type "unlimited" :status "active"}} + {:subscription {:type "professional" :status "active"}})))) + +(t/deftest an-enterprise-team-keeps-ninety-days + (t/is (= 90 (stored-days no-admin-console-flags + {:subscription {:type "enterprise" :status "active"}} + {:subscription {:type "professional" :status "active"}})))) + +(t/deftest a-professional-team-keeps-seven-days + (t/is (= 7 (stored-days no-admin-console-flags + {:subscription {:type "professional" :status "active"}} + {:subscription {:type "professional" :status "active"}})))) + +(t/deftest a-team-without-a-plan-keeps-seven-days + (t/is (= 7 (stored-days no-admin-console-flags + {:subscription {:type nil :status "active"}} + {:subscription {:type "professional" :status "active"}})))) + ;; Scenario: on one day the backend kept two autosaves and the copy from ;; before a repair. Proves: the history shows the repair copy as its own ;; entry, above the day's autosaves, so it can be found by its label. diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index ecf1236cde..15343eaffc 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -194,6 +194,7 @@ [frontend-tests.ui.sortable-auto-scroll-test] [frontend-tests.ui.static-test] [frontend-tests.ui.stroke-menu-test] + [frontend-tests.ui.subscription-dashboard-test] [frontend-tests.ui.subscription-test] [frontend-tests.ui.team-container-test] [frontend-tests.ui.text-attrs-multiple-test] @@ -431,6 +432,7 @@ 'frontend-tests.ui.sortable-auto-scroll-test 'frontend-tests.ui.static-test 'frontend-tests.ui.stroke-menu-test + 'frontend-tests.ui.subscription-dashboard-test 'frontend-tests.ui.subscription-test 'frontend-tests.ui.team-container-test 'frontend-tests.ui.text-attrs-multiple-test diff --git a/frontend/test/frontend_tests/ui/subscription_dashboard_test.cljs b/frontend/test/frontend_tests/ui/subscription_dashboard_test.cljs new file mode 100644 index 0000000000..465299af22 --- /dev/null +++ b/frontend/test/frontend_tests/ui/subscription_dashboard_test.cljs @@ -0,0 +1,195 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns frontend-tests.ui.subscription-dashboard-test + "The rules behind the subscription affordances: which plan a + subscription reads as, when the dashboard shows the upgrade banner or + the members CTA instead of the plan selector, who gets the billing link + in the team settings, and when the workspace menu offers the upsell. + + The fixtures copy the shape the browser sees: the profile carries the + seats as `:quantity` and the editors under + `[:props :subscription :editors]`, where `get-subscription-usage` leaves + them, while the team carries `:seats`." + (:require + [app.main.ui.dashboard.subscription :as subscription] + [cljs.test :as t :include-macros true])) + +(defn- profile + ([subscription] + {:props {:subscription subscription}}) + ([subscription editors] + {:props {:subscription (assoc subscription :editors (vec (range editors)))}})) + +(t/deftest a-professional-subscription-reads-as-professional + (t/is (= "professional" + (subscription/get-subscription-type + {:type "professional" :status "active"})))) + +(t/deftest a-trialing-unlimited-subscription-reads-as-unlimited + (t/is (= "unlimited" + (subscription/get-subscription-type + {:type "unlimited" :status "trialing"})))) + +(t/deftest an-active-enterprise-subscription-reads-as-enterprise + (t/is (= "enterprise" + (subscription/get-subscription-type + {:type "enterprise" :status "active"})))) + +(t/deftest a-past-due-subscription-keeps-its-type + ;; Only `unpaid` and `canceled` demote a plan. + (t/is (= "unlimited" + (subscription/get-subscription-type + {:type "unlimited" :status "past_due"})))) + +(t/deftest an-unpaid-subscription-reads-as-professional + (t/is (= "professional" + (subscription/get-subscription-type + {:type "unlimited" :status "unpaid"})))) + +(t/deftest a-canceled-subscription-reads-as-professional + (t/is (= "professional" + (subscription/get-subscription-type + {:type "enterprise" :status "canceled"})))) + +(t/deftest a-subscription-without-a-type-reads-as-professional + (t/is (= "professional" + (subscription/get-subscription-type {:status "active"})))) + +(t/deftest a-nil-subscription-reads-as-professional + (t/is (= "professional" (subscription/get-subscription-type nil)))) + +(t/deftest the-owner-of-an-unlimited-team-sees-the-manage-subscription-link + (t/is (true? (subscription/show-manage-subscription-link? + true {:type "unlimited" :status "active"})))) + +(t/deftest the-owner-of-an-enterprise-team-sees-the-manage-subscription-link + (t/is (true? (subscription/show-manage-subscription-link? + true {:type "enterprise" :status "active"})))) + +(t/deftest the-owner-of-a-professional-team-has-no-manage-subscription-link + (t/is (false? (subscription/show-manage-subscription-link? + true {:type "professional" :status "active"})))) + +(t/deftest a-member-of-an-unlimited-team-has-no-manage-subscription-link + (t/is (false? (subscription/show-manage-subscription-link? + false {:type "unlimited" :status "active"})))) + +(t/deftest an-unlimited-plan-offers-the-upsell-in-the-main-menu + (t/is (true? (subscription/show-main-menu-power-up? + #{:subscriptions} "unlimited")))) + +(t/deftest a-professional-plan-offers-the-upsell-in-the-main-menu + (t/is (true? (subscription/show-main-menu-power-up? + #{:subscriptions} "professional")))) + +(t/deftest an-enterprise-plan-hides-the-upsell-in-the-main-menu + (t/is (false? (subscription/show-main-menu-power-up? + #{:subscriptions} "enterprise")))) + +(t/deftest without-the-subscriptions-flag-the-upsell-is-hidden + (t/is (false? (subscription/show-main-menu-power-up? + #{} "unlimited")))) + +(t/deftest the-admin-console-offers-the-upsell-on-an-enterprise-plan + (t/is (true? (subscription/show-main-menu-power-up? + #{:admin-console} "enterprise")))) + +(t/deftest a-professional-plan-shows-the-banner-above-eight-editors + ;; Nine editors do not fit the eight the plan allows. + (t/is (true? (subscription/show-subscription-dashboard-banner? + (profile {:type "professional" :status "active"} 9))))) + +(t/deftest a-professional-plan-at-eight-editors-does-not-show-the-banner + (t/is (false? (subscription/show-subscription-dashboard-banner? + (profile {:type "professional" :status "active"} 8))))) + +(t/deftest a-professional-plan-without-usage-data-does-not-show-the-banner + ;; The editors arrive with the usage call; until then the count is zero. + (t/is (false? (subscription/show-subscription-dashboard-banner? + (profile {:type "professional" :status "active"}))))) + +(t/deftest an-unlimited-plan-with-four-editors-over-the-seats-shows-the-banner + (t/is (true? (subscription/show-subscription-dashboard-banner? + (profile {:type "unlimited" :status "active" :quantity 20} 24))))) + +(t/deftest an-unlimited-plan-with-three-editors-over-the-seats-does-not-show-the-banner + (t/is (false? (subscription/show-subscription-dashboard-banner? + (profile {:type "unlimited" :status "active" :quantity 20} 23))))) + +(t/deftest an-unlimited-plan-at-the-seat-limit-does-not-show-the-banner + (t/is (false? (subscription/show-subscription-dashboard-banner? + (profile {:type "unlimited" :status "active" :quantity 25} 30))))) + +(t/deftest an-unlimited-plan-with-25-editors-over-24-seats-shows-the-banner + ;; The editors already passed the size the plan prices per seat. + (t/is (true? (subscription/show-subscription-dashboard-banner? + (profile {:type "unlimited" :status "active" :quantity 24} 25))))) + +(t/deftest an-unlimited-plan-with-editors-within-the-seats-does-not-show-the-banner + (t/is (false? (subscription/show-subscription-dashboard-banner? + (profile {:type "unlimited" :status "active" :quantity 24} 24))))) + +(t/deftest a-canceled-enterprise-plan-is-judged-as-a-professional-plan + ;; Nine editors on thirty seats fit the enterprise plan; only the + ;; demotion to professional makes the banner show. + (t/is (true? (subscription/show-subscription-dashboard-banner? + (profile {:type "enterprise" :status "canceled" :quantity 30} 9))) + "canceled reads as professional, so the professional rule applies") + (t/is (false? (subscription/show-subscription-dashboard-banner? + (profile {:type "enterprise" :status "canceled" :quantity 30} 8))))) + +(t/deftest an-unpaid-unlimited-plan-is-judged-as-a-professional-plan + ;; Six editors on two seats trip the unlimited rule (four or more over + ;; the seats); only the demotion keeps the banner away. + (t/is (false? (subscription/show-subscription-dashboard-banner? + (profile {:type "unlimited" :status "unpaid" :quantity 2} 6))))) + +(t/deftest an-enterprise-plan-does-not-show-the-banner + (t/is (false? (subscription/show-subscription-dashboard-banner? + (profile {:type "enterprise" :status "active" :quantity 30} 30))))) + +(t/deftest the-owner-of-an-unlimited-team-shows-the-members-banner + (t/is (true? (subscription/show-subscription-members-banner? + {:permissions {:is-owner true} + :subscription {:type "unlimited" :status "active" :seats 2}} + (profile {:type "unlimited"} 8))))) + +(t/deftest a-member-of-an-unlimited-team-does-not-show-the-members-banner + (t/is (false? (subscription/show-subscription-members-banner? + {:permissions {:is-owner false} + :subscription {:type "unlimited" :status "active" :seats 2}} + (profile {:type "unlimited"} 8))))) + +(t/deftest the-owner-with-four-editors-over-the-seats-shows-the-members-banner + (t/is (true? (subscription/show-subscription-members-banner? + {:permissions {:is-owner true} + :subscription {:type "unlimited" :status "active" :seats 20}} + (profile {:type "unlimited"} 24))))) + +(t/deftest the-owner-with-three-editors-over-the-seats-does-not-show-the-members-banner + (t/is (false? (subscription/show-subscription-members-banner? + {:permissions {:is-owner true} + :subscription {:type "unlimited" :status "active" :seats 20}} + (profile {:type "unlimited"} 23))))) + +(t/deftest the-owner-at-the-seat-limit-does-not-show-the-members-banner + (t/is (false? (subscription/show-subscription-members-banner? + {:permissions {:is-owner true} + :subscription {:type "unlimited" :status "active" :seats 25}} + (profile {:type "unlimited"} 40))))) + +(t/deftest the-owner-of-an-enterprise-team-does-not-show-the-members-banner + (t/is (false? (subscription/show-subscription-members-banner? + {:permissions {:is-owner true} + :subscription {:type "enterprise" :status "active" :seats 2}} + (profile {:type "enterprise"} 40))))) + +(t/deftest a-members-banner-without-usage-data-does-not-show + (t/is (false? (subscription/show-subscription-members-banner? + {:permissions {:is-owner true} + :subscription {:type "unlimited" :status "active" :seats 2}} + (profile {:type "unlimited"})))))