Skip to content

Commit

Permalink
Merge pull request #13077 from albertkol/improve-not-renewed-label-logic
Browse files Browse the repository at this point in the history
Improve not renewed label logic
  • Loading branch information
albertkol authored Aug 11, 2023
2 parents e59e032 + bdc686e commit cbecbb1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ describe("SubscriptionDetails", () => {
type: UserSubscriptionType.Legacy,
statuses: userSubscriptionStatusesFactory.build({
is_renewed: false,
is_renewable: true,
is_renewal_actionable: true,
}),
});
Expand All @@ -396,6 +397,30 @@ describe("SubscriptionDetails", () => {
expect(wrapper.find(".p-chip__value").text()).toBe("Not renewed");
});

it("it does not display the not renewed label for legacy actionable but not renewable", () => {
const contract = userSubscriptionFactory.build({
type: UserSubscriptionType.Legacy,
statuses: userSubscriptionStatusesFactory.build({
is_renewed: false,
is_renewable: false,
is_renewal_actionable: true,
}),
});

queryClient.setQueryData("userSubscriptions", [contract]);
const wrapper = mount(
<QueryClientProvider client={queryClient}>
<SubscriptionDetails
onCloseModal={jest.fn()}
selectedId={contract.id}
setHasUnsavedChanges={jest.fn()}
/>
</QueryClientProvider>
);

expect(wrapper.find(".p-chip__value").exists()).toBe(false);
});

it("it does display the renewed label for legacy renewed", () => {
const contract = userSubscriptionFactory.build({
type: UserSubscriptionType.Legacy,
Expand Down Expand Up @@ -563,6 +588,7 @@ describe("SubscriptionDetails", () => {
type: UserSubscriptionType.Legacy,
statuses: userSubscriptionStatusesFactory.build({
is_renewed: false,
is_renewable: false,
is_renewal_actionable: false,
}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ export const SubscriptionDetails = forwardRef<HTMLDivElement, Props>(
</button>
) : (
<>
{subscription.statuses.is_renewal_actionable ? (
{subscription.statuses.is_renewal_actionable &&
subscription.statuses.is_renewable ? (
<button className="p-chip--caution">
<span className="p-chip__value">Not renewed</span>
</button>
Expand Down

0 comments on commit cbecbb1

Please sign in to comment.