mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
fix(ui): fix ui test
fix ui test
This commit is contained in:
parent
925dc052d7
commit
e4629f2a5f
3 changed files with 31 additions and 15 deletions
|
@ -22,14 +22,14 @@ describe('<PasscodeValidation />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('render counter', () => {
|
it('render counter', () => {
|
||||||
const { queryByText } = renderWithPageContext(
|
const { queryByText, debug } = renderWithPageContext(
|
||||||
<PasscodeValidation type="sign-in" method="email" target={email} />
|
<PasscodeValidation type="sign-in" method="email" target={email} />
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(queryByText('description.resend_after_seconds')).not.toBeNull();
|
expect(queryByText('description.resend_after_seconds')).not.toBeNull();
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
jest.runAllTimers();
|
jest.advanceTimersByTime(1e3 * 60);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(queryByText('description.resend_passcode')).not.toBeNull();
|
expect(queryByText('description.resend_passcode')).not.toBeNull();
|
||||||
|
@ -40,7 +40,7 @@ describe('<PasscodeValidation />', () => {
|
||||||
<PasscodeValidation type="sign-in" method="email" target={email} />
|
<PasscodeValidation type="sign-in" method="email" target={email} />
|
||||||
);
|
);
|
||||||
act(() => {
|
act(() => {
|
||||||
jest.runAllTimers();
|
jest.advanceTimersByTime(1e3 * 60);
|
||||||
});
|
});
|
||||||
const resendButton = getByText('description.resend_passcode');
|
const resendButton = getByText('description.resend_passcode');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { fireEvent, waitFor } from '@testing-library/react';
|
import { fireEvent, waitFor, act } from '@testing-library/react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import renderWithPageContext from '@/__mocks__/RenderWithPageContext';
|
import renderWithPageContext from '@/__mocks__/RenderWithPageContext';
|
||||||
|
@ -112,12 +112,14 @@ describe('SecondarySocialSignIn', () => {
|
||||||
const socialButton = container.querySelector('button');
|
const socialButton = container.querySelector('button');
|
||||||
|
|
||||||
if (socialButton) {
|
if (socialButton) {
|
||||||
await waitFor(() => {
|
act(() => {
|
||||||
fireEvent.click(socialButton);
|
fireEvent.click(socialButton);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(invokeSocialSignInSpy).toBeCalled();
|
void waitFor(() => {
|
||||||
expect(logtoNativeSdk?.getPostMessage).toBeCalled();
|
expect(invokeSocialSignInSpy).toBeCalled();
|
||||||
|
expect(logtoNativeSdk?.getPostMessage).toBeCalled();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { fireEvent, waitFor } from '@testing-library/react';
|
import { fireEvent, waitFor } from '@testing-library/react';
|
||||||
|
import { act } from 'react-dom/test-utils';
|
||||||
|
|
||||||
import renderWithPageContext from '@/__mocks__/RenderWithPageContext';
|
import renderWithPageContext from '@/__mocks__/RenderWithPageContext';
|
||||||
import SettingsProvider from '@/__mocks__/RenderWithPageContext/SettingsProvider';
|
import SettingsProvider from '@/__mocks__/RenderWithPageContext/SettingsProvider';
|
||||||
|
@ -87,11 +88,13 @@ describe('<UsernameSignin>', () => {
|
||||||
fireEvent.change(passwordInput, { target: { value: 'password' } });
|
fireEvent.change(passwordInput, { target: { value: 'password' } });
|
||||||
}
|
}
|
||||||
|
|
||||||
await waitFor(() => {
|
await act(async () => {
|
||||||
fireEvent.click(submitButton);
|
fireEvent.click(submitButton);
|
||||||
});
|
|
||||||
|
|
||||||
expect(signInBasic).toBeCalledWith('username', 'password', undefined);
|
await waitFor(() => {
|
||||||
|
expect(termsOfUseConfirmModalPromiseMock).toBeCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should show terms detail modal', async () => {
|
test('should show terms detail modal', async () => {
|
||||||
|
@ -115,11 +118,15 @@ describe('<UsernameSignin>', () => {
|
||||||
fireEvent.change(passwordInput, { target: { value: 'password' } });
|
fireEvent.change(passwordInput, { target: { value: 'password' } });
|
||||||
}
|
}
|
||||||
|
|
||||||
await waitFor(() => {
|
act(() => {
|
||||||
fireEvent.click(submitButton);
|
fireEvent.click(submitButton);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(termsOfUseIframeModalPromiseMock).toBeCalledWith();
|
expect(signInBasic).not.toBeCalled();
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(termsOfUseIframeModalPromiseMock).toBeCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('submit form', async () => {
|
test('submit form', async () => {
|
||||||
|
@ -142,12 +149,19 @@ describe('<UsernameSignin>', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const termsButton = getByText('description.agree_with_terms');
|
const termsButton = getByText('description.agree_with_terms');
|
||||||
fireEvent.click(termsButton);
|
|
||||||
|
|
||||||
await waitFor(() => {
|
act(() => {
|
||||||
|
fireEvent.click(termsButton);
|
||||||
|
});
|
||||||
|
|
||||||
|
act(() => {
|
||||||
fireEvent.click(submitButton);
|
fireEvent.click(submitButton);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(signInBasic).toBeCalledWith('username', 'password', undefined);
|
act(() => {
|
||||||
|
void waitFor(() => {
|
||||||
|
expect(signInBasic).toBeCalledWith('username', 'password', undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue