Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 15 additions & 2 deletions packages/core/src/app/order/OrderConfirmation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ import { CreatedCustomer } from '../guestSignup';
import OrderConfirmation, { OrderConfirmationProps } from './OrderConfirmation';
import { getGatewayOrderPayment, getOrder } from './orders.mock';

const passwordRegex = /^(?=.*[a-zA-Z])(?=.*[0-9]).*$/;

// Function to make sure faker generates valid password as per regex
const generateValidPassword = () => {
let password = '';

do {
password = faker.internet.password();
} while (!passwordRegex.test(password));

return password;
}

describe('OrderConfirmation', () => {
let checkoutService: CheckoutService;
let checkoutState: CheckoutSelectors;
Expand Down Expand Up @@ -131,7 +144,7 @@ describe('OrderConfirmation', () => {
});

it('renders create account form, fills in the form and submit data', async () => {
const password = faker.internet.password();
const password = generateValidPassword();

render(<ComponentTest {...defaultProps} />);

Expand All @@ -151,7 +164,7 @@ describe('OrderConfirmation', () => {
});

it('renders set password form, fills in the form and submit data', async () => {
const password = faker.internet.password();
const password = generateValidPassword();

jest.spyOn(checkoutState.data, 'getOrder').mockReturnValue({
...getOrder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ describe('ManageInstrumentsModal', () => {
expect(await screen.findByText(localeContext.language.translate('payment.instrument_manage_modal_confirmation_label'))).toBeInTheDocument();
});

it.skip('shows list of instruments if user decides to cancel their action', async () => {
it('shows list of instruments if user decides to cancel their action', async () => {
render(<ManageInstrumentsModalTest {...defaultProps} />);

await userEvent.click(screen.getAllByText('Delete')[0]);
await userEvent.click(screen.getByText('Cancel'));
await userEvent.click(screen.getAllByText('Delete')[0]);
await userEvent.click(screen.getByText('Cancel'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ManageInstrumentsModal extends Component<

this.setState(
{
isConfirmingDelete: false,
isConfirmingDelete: this.state.isConfirmingDelete,
},
onAfterOpen,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ describe('ManageInstrumentsModal', () => {
).toBeInTheDocument();
});

// Skip the test as it is flaky
it.skip('deletes selected instrument and closes modal if user confirms their action', async () => {
it('deletes selected instrument and closes modal if user confirms their action', async () => {
jest.spyOn(checkoutService, 'deleteInstrument').mockResolvedValue(checkoutState);

render(<ManageInstrumentsModalTest {...defaultProps} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,11 @@ class ManageInstrumentsModal extends Component<

private handleAfterOpen: () => void = () => {
const { onAfterOpen } = this.props;
const { isConfirmingDelete } = this.state;

this.setState(
{
isConfirmingDelete: false,
isConfirmingDelete,
},
onAfterOpen,
);
Expand Down