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

Wd-16440 Restrict channel users from editing billing information #14547

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

minkyngkm
Copy link
Contributor

@minkyngkm minkyngkm commented Dec 9, 2024

Done

  • Restrict channel users from editing billing information

QA steps

Pro shop & Credential users

  1. Log in as Pro user (normal user)
  2. Select products from the pro shop (/pro/subscribe)
  3. Click the checkout button to land on the checkout page
  4. On the check out page
  • If new user who hasn't made any purchases before: the Tax section and User Information section inputs will be displayed and allow users to edit the fields.
image
  • If the existing user who has made a purchase before, the Tax section and User Information section are in display mode. but they can still edit their fields by clicking the edit button. When in edit mode, all fields are available for editing.
image
  1. Edit the information or save the information, and check the purchase is working properly.

Distributor users

  1. Log in as a channel user (distributor user)
  2. Go to /pro/distributor
  3. Click the checkout button to land on the checkout page.
  4. On the check out page
  • New user: it works the same as for Pro Shop users
  • For existing users: the Tax section is restricted for editing, and only the card number is editable in the User Information section.
image
  1. Edit the information or save the information, and check the purchase is working properly.

Issue / Card

Fixes #https://warthogs.atlassian.net/browse/WD-16449

@webteam-app
Copy link

Comment on lines 249 to 254
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();
});
Copy link
Contributor

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 👇

Copy link
Contributor

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.

Suggested change
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();

Copy link
Contributor

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.

Suggested change
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();

Comment on lines +112 to +113
fireEvent.click(screen.getByRole("button", { name: "Edit" }));
fireEvent.change(screen.getByTestId("field-card-number"), {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Fasih, updated!

fasih-mehmood
fasih-mehmood previously approved these changes Dec 19, 2024
Copy link
Contributor

@fasih-mehmood fasih-mehmood left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants