-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathReview.test.tsx
More file actions
112 lines (96 loc) · 3.14 KB
/
Review.test.tsx
File metadata and controls
112 lines (96 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { Router as RemixRouter } from '@remix-run/router/dist/router';
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import {
clickBack,
clickNext,
clickRegisterLater,
goToReview,
renderCreateMode,
verifyCancelButton,
} from '../../wizardTestUtils';
let router: RemixRouter | undefined = undefined;
const selectGuestImage = async () => {
const user = userEvent.setup();
const guestImageCheckBox = await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
});
await waitFor(() => user.click(guestImageCheckBox));
};
const setupWithRhel = async () => {
await renderCreateMode();
await selectGuestImage();
};
const setupWithCentos = async () => {
const user = userEvent.setup();
await renderCreateMode();
const releaseMenu = screen.getByTestId('release_select');
await waitFor(() => user.click(releaseMenu));
const showOptionsButton = await screen.findByRole('option', {
name: 'Show options for further development of RHEL',
});
await waitFor(() => user.click(showOptionsButton));
const centos = await screen.findByRole('option', {
name: 'CentOS Stream 9',
});
await waitFor(() => user.click(centos));
await selectGuestImage();
};
const handleRegistration = async () => {
await clickNext(); // Registration
await clickRegisterLater();
};
describe('Step Review', () => {
beforeEach(() => {
vi.clearAllMocks();
router = undefined;
});
test('has 3 buttons', async () => {
await setupWithRhel();
await handleRegistration();
await goToReview();
await screen.findByRole('button', { name: /Create blueprint/ });
await screen.findByRole('button', { name: /Back/ });
await screen.findByRole('button', { name: /Cancel/ });
});
test('clicking Back loads Image name', async () => {
await setupWithRhel();
await handleRegistration();
await goToReview();
await clickBack();
await screen.findByRole('heading', {
name: 'Image details',
});
});
test('clicking Cancel loads landing page', async () => {
await setupWithRhel();
await handleRegistration();
await goToReview();
await verifyCancelButton(router);
});
test('has Registration expandable section for rhel', async () => {
await setupWithRhel();
await handleRegistration();
await goToReview();
await screen.findByRole('heading', { name: /Review/ });
const registrationExpandable = await screen.findByTestId(
'registration-expandable',
);
await within(registrationExpandable).findByText('Registration type');
await within(registrationExpandable).findByText(
'Register the system later',
);
});
test('has no Registration expandable for centos', async () => {
await setupWithCentos();
await goToReview();
await screen.findByRole('heading', { name: /Review/ });
expect(
screen.queryByTestId('registration-expandable'),
).not.toBeInTheDocument();
expect(screen.queryByText('Registration type')).not.toBeInTheDocument();
expect(
screen.queryByText('Register the system later'),
).not.toBeInTheDocument();
});
});