Skip to content

Commit

Permalink
fix: Change plan update banner to new alert and update seat count
Browse files Browse the repository at this point in the history
  • Loading branch information
calvin-codecov committed Feb 26, 2025
1 parent 67df9ca commit abfbad7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe('CurrentOrgPlan', () => {
})

render(<CurrentOrgPlan />, { wrapper })
const updatedAlert = await screen.findByText('Plan successfully updated.')
const updatedAlert = await screen.findByText('Plan successfully updated')

Check failure on line 200 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.test.tsx

View workflow job for this annotation

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.test.tsx > CurrentOrgPlan > when plan update success banner should be shown > renders banner for plan successfully updated

TestingLibraryElementError: Unable to find an element with the text: Plan successfully updated. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div> <div class="w-full lg:w-4/5" > <div class="flex flex-col gap-4 sm:mr-4 sm:flex-initial md:w-2/3 lg:w-3/4" > <div class="relative w-full border-l-4 p-4 border-green-500 bg-green-100 dark:bg-opacity-20" role="alert" > <svg class="stroke-green-500 float-left -mt-1 mr-2 align-middle w-6 h-6" data-icon="checkCircle" data-testid="checkCircle" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" > <path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" /> </svg> <p class="text-sm" > Plan successfully updated. </p> </div> CurrentPlanCard BillingDetails LatestInvoiceCard </div> </div> </div> </body> Ignored nodes: comments, script, style <body> <div> <div class="w-full lg:w-4/5" > <div class="flex flex-col gap-4 sm:mr-4 sm:flex-initial md:w-2/3 lg:w-3/4" > <div class="relative w-full border-l-4 p-4 border-green-500 bg-green-100 dark:bg-opacity-20" role="alert" > <svg class="stroke-green-500 float-left -mt-1 mr-2 align-middle w-6 h-6" data-icon="checkCircle" data-testid="checkCircle" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" > <path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" /> </svg> <p class="text-sm" > Plan successfully updated. </p> </div> CurrentPlanCard BillingDetails LatestInvoiceCard </div> </div> </div> </body> ❯ waitForWrapper node_modules/@testing-library/dom/dist/wait-for.js:163:27 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:86:33 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.test.tsx:200:41
expect(updatedAlert).toBeInTheDocument()
})

Expand All @@ -214,7 +214,7 @@ describe('CurrentOrgPlan', () => {
} as z.infer<typeof AccountDetailsSchema>,
})
render(<CurrentOrgPlan />, { wrapper })
const updatedAlert = await screen.findByText('Plan successfully updated.')
const updatedAlert = await screen.findByText('Plan successfully updated')
expect(updatedAlert).toBeInTheDocument()
expect(
screen.getByText(/with a monthly subscription for 34 seats/)
Expand All @@ -230,7 +230,7 @@ describe('CurrentOrgPlan', () => {
expect(currentPlanCard).toBeInTheDocument()

expect(
screen.queryByText('Plan successfully updated.')
screen.queryByText('Plan successfully updated')
).not.toBeInTheDocument()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function CurrentOrgPlan() {
<Alert variant={planUpdatedNotification.alertOption}>
{scheduleStart && scheduledPhase?.quantity ? (
<>
<Alert.Title>Plan successfully updated.</Alert.Title>
<Alert.Title>Plan successfully updated</Alert.Title>
<Alert.Description>
The start date is {scheduleStart} with a monthly
subscription for {scheduledPhase.quantity} seats.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('InfoMessageStripeCallback', () => {
)

await expect(
screen.getByText(/Subscription Update Successful/)
screen.getByText(/Plan successfully updated./)
).toBeInTheDocument()
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import qs from 'qs'
import { useLocation } from 'react-router-dom'

import Message from 'old_ui/Message'
import { Alert } from 'ui/Alert'

// Stripe redirects to this page with ?success or ?cancel in the URL
// this component takes care of rendering a message if it is successful
Expand All @@ -16,14 +16,12 @@ function InfoMessageStripeCallback({

if ('success' in urlParams && !awaitingInitialPaymentMethodVerification)
return (
<div className="col-start-1 col-end-13 mb-4">
<Message variant="success">
<h2 className="text-lg">Subscription Update Successful</h2>
<p className="text-sm">
Your subscription has been updated successfully. If your plan
details appear incorrect, please refresh the page.
</p>
</Message>
<div className="col-start-1 col-end-13 mb-4 sm:flex-initial md:w-2/3 lg:w-3/4">
<Alert variant="success">
<Alert.Description className="text-sm">
Plan successfully updated.
</Alert.Description>
</Alert>
</div>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ export const useUpgradeControls = () => {
newPlan: newPlan!,
},
{
onSuccess: () => {
queryClient.invalidateQueries(['accountDetails'])
onSuccess: async () => {
// we want to wait here as history.push can disrupt the query invalidation
await Promise.all([
queryClient.refetchQueries({ queryKey: ['accountDetails'] }),
queryClient.refetchQueries({ queryKey: ['GetPlanData'] }),
])
setPlanUpdatedNotification({
alertOption: 'success',
})
Expand Down

0 comments on commit abfbad7

Please sign in to comment.