-
Notifications
You must be signed in to change notification settings - Fork 208
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
Wd-16440 Restrict channel users from editing billing information #14547
base: main
Are you sure you want to change the base?
Conversation
userEvent.click(screen.getByRole("button", { name: "Edit" })); | ||
await waitFor(() => { | ||
expect(screen.getByTestId("select-country")).toBeInTheDocument(); | ||
expect(screen.getByTestId("field-vat-number")).toBeInTheDocument(); | ||
expect(screen.getByRole("button", { name: "Save" })).toBeInTheDocument(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit that doesn't need to be addressed 👇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended to await the userEvent
interactions and then waitFor
should only be used to wait for a single UI change to happen if all of the changes happen simultaneously.
userEvent.click(screen.getByRole("button", { name: "Edit" })); | |
await waitFor(() => { | |
expect(screen.getByTestId("select-country")).toBeInTheDocument(); | |
expect(screen.getByTestId("field-vat-number")).toBeInTheDocument(); | |
expect(screen.getByRole("button", { name: "Save" })).toBeInTheDocument(); | |
}); | |
await userEvent.click(screen.getByRole("button", { name: "Edit" })); | |
await waitFor(() => { | |
expect(screen.getByTestId("select-country")).toBeInTheDocument(); | |
}); | |
expect(screen.getByTestId("field-vat-number")).toBeInTheDocument(); | |
expect(screen.getByRole("button", { name: "Save" })).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even better if you simply use await screen.findBy
because findBy
uses expect
wrapped in waitFor
under the hood.
userEvent.click(screen.getByRole("button", { name: "Edit" })); | |
await waitFor(() => { | |
expect(screen.getByTestId("select-country")).toBeInTheDocument(); | |
expect(screen.getByTestId("field-vat-number")).toBeInTheDocument(); | |
expect(screen.getByRole("button", { name: "Save" })).toBeInTheDocument(); | |
}); | |
await userEvent.click(screen.getByRole("button", { name: "Edit" })); | |
const countryField = await screen.findByTestId("select-country"); | |
expect(countryField).toBeInTheDocument(); | |
expect(screen.getByTestId("field-vat-number")).toBeInTheDocument(); | |
expect(screen.getByRole("button", { name: "Save" })).toBeInTheDocument(); |
fireEvent.click(screen.getByRole("button", { name: "Edit" })); | ||
fireEvent.change(screen.getByTestId("field-card-number"), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
It is recommended to use userEvent
as it is built on top of fireEvent
, but it provides several methods that resemble the user interactions more closely. For example, fireEvent.change
will simply trigger a single change event on the input. However userEvent.type
will trigger keyDown, keyPress, and keyUp events for each character as well. It's much closer to the user's actual interactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Fasih, updated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you Min!
b23ad18
to
491d609
Compare
Done
QA steps
Pro shop & Credential users
Distributor users
Issue / Card
Fixes #https://warthogs.atlassian.net/browse/WD-16449