Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change plan update banner to new alert and refresh seat count #3778

Merged
merged 5 commits into from
Mar 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: Change plan update banner to new alert and update seat count
  • Loading branch information
calvin-codecov committed Feb 26, 2025
commit abfbad7f7c791665c8514cb9a9deb3588526b955
Original file line number Diff line number Diff line change
@@ -197,7 +197,7 @@
})

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

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()
})

@@ -214,7 +214,7 @@
} 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/)
@@ -230,7 +230,7 @@
expect(currentPlanCard).toBeInTheDocument()

expect(
screen.queryByText('Plan successfully updated.')
screen.queryByText('Plan successfully updated')
).not.toBeInTheDocument()
})
})
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ describe('InfoMessageStripeCallback', () => {
)

await expect(
screen.getByText(/Subscription Update Successful/)
screen.getByText(/Plan successfully updated./)
).toBeInTheDocument()
})
})
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
@@ -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>
)

Original file line number Diff line number Diff line change
@@ -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',
})
Loading
Oops, something went wrong.