Skip to content

Commit d3f5ac6

Browse files
authored
Merge pull request #49 from TaloDev/can-view-billing-portal
Conditionally display billing portal tile
2 parents 7f2ff57 + ba6668b commit d3f5ac6

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/pages/Billing.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ export default function Billing() {
7474
}
7575

7676
<BillingUsageTile />
77-
<BillingPortalTile />
77+
78+
{orgPlan.canViewBillingPortal &&
79+
<BillingPortalTile />
80+
}
7881
</ul>
7982
</div>
8083

src/pages/__tests__/Billing.test.jsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ describe('<Billing />', () => {
3535
]
3636
},
3737
status: 'active',
38-
endDate: null
38+
endDate: null,
39+
canViewBillingPortal: true
3940
}
4041

4142
const userValue = {
@@ -181,6 +182,26 @@ describe('<Billing />', () => {
181182
expect(await screen.findByText('Your plan expires on 2nd Mar 2022')).toBeInTheDocument()
182183
})
183184

185+
it('should not render the billing portal tile if they cannot view it', async () => {
186+
const pricingPlan = {
187+
...orgPlan,
188+
canViewBillingPortal: false
189+
}
190+
191+
axiosMock.onGet('http://talo.test/billing/organisation-plan').replyOnce(200, { pricingPlan })
192+
axiosMock.onGet('http://talo.test/billing/plans').replyOnce(200, { pricingPlans })
193+
axiosMock.onGet('http://talo.test/billing/usage').replyOnce(200, { usage })
194+
195+
render(
196+
<KitchenSink states={[{ node: userState, initialValue: userValue }]}>
197+
<Billing />
198+
</KitchenSink>
199+
)
200+
201+
expect(await screen.findByText('Current plan')).toBeInTheDocument()
202+
expect(screen.queryByText('Billing details')).not.toBeInTheDocument()
203+
})
204+
184205
it('should handle organisation plan errors', async () => {
185206
axiosMock.onGet('http://talo.test/billing/organisation-plan').networkErrorOnce()
186207
axiosMock.onGet('http://talo.test/billing/plans').replyOnce(200, { pricingPlans })

0 commit comments

Comments
 (0)