PluginProbe
Extendify / 3.1.1
Extendify v3.1.1
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 / tests / unit / AutoLaunch / LaunchPage.test.jsx

LaunchPage.test.jsx in Extendify 3.1.1, at tests/unit/AutoLaunch/LaunchPage.test.jsx

129 lines 3.7 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/functions/setup', () => ({
22 preLaunchFunctions: jest.fn(),
23 }));
24 jest.mock('@auto-launch/state/launch-data', () => ({
25 useLaunchDataStore: () => ({
26 title: null,
27 descriptionRaw: null,
28 go: false,
29 urlParams: {},
30 designBuild: false,
31 pulse: false,
32 }),
33 }));
34 jest.mock('@wordpress/block-library', () => ({
35 registerCoreBlocks: jest.fn(),
36 }));
37 jest.mock('@wordpress/blocks', () => ({ getBlockTypes: () => [{}] }));
38 jest.mock('@wordpress/data', () => ({
39 useSelect: () => ({ textdomain: 'extendable' }),
40 }));
41 jest.mock('framer-motion', () => ({
42 AnimatePresence: ({ children }) => <>{children}</>,
43 motion: new Proxy(
44 {},
45 { get: () => (props) => <div {...props}>{props.children}</div> },
46 ),
47 }));
48 jest.mock('@auto-launch/functions/insights', () => ({ checkIn: jest.fn() }));
49
50 beforeAll(() => {
51 window.extLaunchData = {
52 resetSiteInformation: { pagesIds: [] },
53 urlParams: {},
54 hideAutoLaunchExitLink: false,
55 };
56 });
57
58 afterAll(() => {
59 delete window.extLaunchData;
60 });
61
62 beforeEach(() => {
63 window.extSharedData = {
64 adminUrl: 'https://example.test/wp-admin/',
65 };
66 });
67
68 describe('AutoLaunchPage — hideAutoLaunchExitLink flag', () => {
69 test('shows the WP Admin Dashboard exit link when the flag is false', () => {
70 render(<LaunchPage />);
71 expect(
72 screen.getByRole('link', { name: /WP Admin Dashboard/i }),
73 ).toBeInTheDocument();
74 });
75
76 test('hides the WP Admin Dashboard exit link when the flag is true', () => {
77 window.extLaunchData.hideAutoLaunchExitLink = true;
78 render(<LaunchPage />);
79 expect(
80 screen.queryByRole('link', { name: /WP Admin Dashboard/i }),
81 ).not.toBeInTheDocument();
82 });
83 });
84
85 describe('AutoLaunchPage — AutoLaunch.HeaderParagraphOld A/B test', () => {
86 test('shows the old Launch-era heading and paragraph for variant B', () => {
87 window.extLaunchData.activeTests = {
88 'AutoLaunch.HeaderParagraphOld': { variant: 'B' },
89 };
90 render(<LaunchPage />);
91 expect(screen.getByText(/Tell Us About Your Website/i)).toBeInTheDocument();
92 expect(
93 screen.getByText(/Share your vision, and we'll craft a website/i),
94 ).toBeInTheDocument();
95 });
96
97 test('shows the current heading and no paragraph for variant A', () => {
98 window.extLaunchData.activeTests = {
99 'AutoLaunch.HeaderParagraphOld': { variant: 'A' },
100 };
101 render(<LaunchPage />);
102 expect(
103 screen.getByText(/Describe the website you want to build/i),
104 ).toBeInTheDocument();
105 expect(
106 screen.queryByText(/Share your vision, and we'll craft a website/i),
107 ).not.toBeInTheDocument();
108 });
109
110 test('shows the current heading when no assignment is present', () => {
111 window.extLaunchData.activeTests = {};
112 render(<LaunchPage />);
113 expect(
114 screen.getByText(/Describe the website you want to build/i),
115 ).toBeInTheDocument();
116 });
117 });
118
119 describe('AutoLaunchPage — content container', () => {
120 test('always scrolls on overflow', () => {
121 window.extLaunchData.activeTests = {};
122 const { container } = render(<LaunchPage />);
123 expect(container.querySelector('.flex-1')).toHaveClass(
124 'min-h-0',
125 'overflow-y-auto',
126 );
127 });
128 });
129