diff --git a/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.test.tsx b/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.test.tsx index 59f1182ac7..09737c1e98 100644 --- a/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.test.tsx +++ b/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.test.tsx @@ -1,6 +1,7 @@ import { MockLicenseResponse } from "testHelpers/entities"; import { render } from "testHelpers/renderHelpers"; import { screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; import { LicenseCard } from "./LicenseCard"; describe("LicenseCard", () => { @@ -40,6 +41,44 @@ describe("LicenseCard", () => { await screen.findByText("Enterprise"); }); + it("shows expired removal message for expired licenses", async () => { + const user = userEvent.setup(); + render( + null} + isRemoving={false} + />, + ); + + const removeButton = await screen.findByRole("button", { name: /remove/i }); + await user.click(removeButton); + + await screen.findByText(/This license has already expired/); + }); + + it("shows disabling features warning for active licenses", async () => { + const user = userEvent.setup(); + render( + null} + isRemoving={false} + />, + ); + + const removeButton = await screen.findByRole("button", { name: /remove/i }); + await user.click(removeButton); + + await screen.findByText( + /Removing this license will disable all Premium features/, + ); + }); + it("renders license's user_limit when it is available instead of using the default", async () => { const licenseUserLimit = 3; const license = { diff --git a/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.tsx b/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.tsx index 0a22317d75..15edcf5da4 100644 --- a/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.tsx +++ b/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.tsx @@ -29,6 +29,10 @@ export const LicenseCard: FC = ({ const currentUserLimit = license.claims.features.user_limit || userLimitLimit; + const isExpired = dayjs + .unix(license.claims.license_expires) + .isBefore(dayjs()); + const licenseType = license.claims.trial ? "Trial" : license.claims.feature_set?.toLowerCase() === "premium" @@ -57,7 +61,11 @@ export const LicenseCard: FC = ({ title="Confirm License Removal" confirmLoading={isRemoving} confirmText="Remove" - description="Removing this license will disable all Premium features. You add a new license at any time." + description={ + isExpired + ? "This license has already expired and is not providing any features. Removing it will not affect your current entitlements." + : "Removing this license will disable all Premium features. You can add a new license at any time." + } /> = ({ )} - {dayjs(license.claims.license_expires * 1000).isBefore(dayjs()) ? ( + {isExpired ? ( Expired