PluginProbe
Extendify / 3.0.5
Extendify v3.0.5
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / AutoLaunch / __tests__ / LaunchPage.test.jsx

LaunchPage.test.jsx in Extendify 3.0.5, at src/AutoLaunch/__tests__/LaunchPage.test.jsx

81 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { LaunchPage } from '@auto-launch/LaunchPage';
2 import { render, screen } from '@testing-library/react';
3
4 jest.mock('@auto-launch/components/Launch', () => ({
5 Launch: () => <div data-testid="launch" />,
6 }));
7 jest.mock('@auto-launch/components/Logo', () => ({ Logo: () => null }));
8 jest.mock('@auto-launch/components/MovingGradients', () => ({
9 MovingGradient: () => null,
10 }));
11 jest.mock('@auto-launch/components/NeedsTheme', () => ({
12 NeedsTheme: () => null,
13 }));
14 jest.mock('@auto-launch/components/RestartLaunchModal', () => ({
15 RestartLaunchModal: () => null,
16 }));
17 jest.mock('@auto-launch/components/ViewportPulse', () => ({
18 ViewportPulse: () => null,
19 }));
20 jest.mock('@auto-launch/functions/wp', () => ({ updateOption: jest.fn() }));
21 jest.mock('@auto-launch/state/launch-data', () => ({
22 useLaunchDataStore: () => ({
23 title: null,
24 descriptionRaw: null,
25 go: false,
26 urlParams: {},
27 designBuild: false,
28 pulse: false,
29 }),
30 }));
31 jest.mock('@wordpress/block-library', () => ({
32 registerCoreBlocks: jest.fn(),
33 }));
34 jest.mock('@wordpress/blocks', () => ({ getBlockTypes: () => [{}] }));
35 jest.mock('@wordpress/data', () => ({
36 useSelect: () => ({ textdomain: 'extendable' }),
37 }));
38 jest.mock('framer-motion', () => ({
39 AnimatePresence: ({ children }) => <>{children}</>,
40 motion: new Proxy(
41 {},
42 { get: () => (props) => <div {...props}>{props.children}</div> },
43 ),
44 }));
45 jest.mock('@auto-launch/functions/insights', () => ({ checkIn: jest.fn() }));
46
47 beforeAll(() => {
48 window.extLaunchData = {
49 resetSiteInformation: { pagesIds: [] },
50 urlParams: {},
51 hideAutoLaunchExitLink: false,
52 };
53 });
54
55 afterAll(() => {
56 delete window.extLaunchData;
57 });
58
59 beforeEach(() => {
60 window.extSharedData = {
61 adminUrl: 'https://example.test/wp-admin/',
62 };
63 });
64
65 describe('AutoLaunchPage — hideAutoLaunchExitLink flag', () => {
66 test('shows the WP Admin Dashboard exit link when the flag is false', () => {
67 render(<LaunchPage />);
68 expect(
69 screen.getByRole('link', { name: /WP Admin Dashboard/i }),
70 ).toBeInTheDocument();
71 });
72
73 test('hides the WP Admin Dashboard exit link when the flag is true', () => {
74 window.extLaunchData.hideAutoLaunchExitLink = true;
75 render(<LaunchPage />);
76 expect(
77 screen.queryByRole('link', { name: /WP Admin Dashboard/i }),
78 ).not.toBeInTheDocument();
79 });
80 });
81