forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartNotebookModal.spec.tsx
More file actions
executable file
·186 lines (164 loc) · 6.9 KB
/
StartNotebookModal.spec.tsx
File metadata and controls
executable file
·186 lines (164 loc) · 6.9 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import React from 'react';
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import StartNotebookModal from '#~/concepts/notebooks/StartNotebookModal';
import {
mockCompletedStates,
mockFailedStates,
mockInitialStates,
mockInProgressStates,
} from '#~/concepts/__tests__/mockNotebookStates';
describe('Start Notebook modal', () => {
it('should show initial notebook startup status', async () => {
const mockData = mockInitialStates;
render(
<StartNotebookModal
notebookStatus={mockData.notebookStatus}
isStarting={mockData.notebookState.isStarting}
isStopping={mockData.notebookState.isStopping}
isRunning={mockData.notebookState.isRunning}
events={mockData.events}
buttons={null}
/>,
);
// Validate the header contents
const header = screen.getByTestId('notebook-status-modal-header');
expect(header).toHaveTextContent('Workbench statusStarting');
const statusLabel = screen.getByTestId('notebook-latest-status');
expect(statusLabel).toHaveTextContent('Waiting for server request to start');
// Validate the steps
const stepper = screen.getByTestId('notebook-startup-steps');
expect(stepper).toBeTruthy();
const steps = screen.getAllByRole('listitem');
expect(steps).toHaveLength(13);
expect(steps[0]).toHaveTextContent('Workbench requested');
expect(steps[1]).toHaveTextContent('Pod created');
expect(steps[2]).toHaveTextContent('Pod assigned');
expect(steps[3]).toHaveTextContent('Interface added');
expect(steps[4]).toHaveTextContent('Pulling workbench image');
expect(steps[5]).toHaveTextContent('Workbench image pulled');
expect(steps[6]).toHaveTextContent('Workbench container created');
expect(steps[7]).toHaveTextContent('Workbench container started');
expect(steps[8]).toHaveTextContent('Pulling auth proxy');
expect(steps[9]).toHaveTextContent('Auth proxy pulled');
expect(steps[10]).toHaveTextContent('Auth proxy container created');
expect(steps[11]).toHaveTextContent('Auth proxy container started');
expect(steps[12]).toHaveTextContent('Workbench started');
});
it('should show failed notebook startup status', async () => {
const mockData = mockFailedStates;
render(
<StartNotebookModal
notebookStatus={mockData.notebookStatus}
isStarting={mockData.notebookState.isStarting}
isStopping={mockData.notebookState.isStopping}
isRunning={mockData.notebookState.isRunning}
events={mockData.events}
buttons={null}
/>,
);
// Validate the header contents
const header = screen.getByTestId('notebook-status-modal-header');
expect(header).toHaveTextContent('Workbench statusFailed');
const statusLabel = screen.getByTestId('notebook-latest-status');
expect(statusLabel).toHaveTextContent('Failed to scale-up');
expect(screen.getByTestId('danger-NotTriggerScaleUp')).toBeTruthy();
// Validate the steps
const stepper = screen.getByTestId('notebook-startup-steps');
expect(stepper).toBeTruthy();
const steps = screen.getAllByRole('listitem');
expect(steps).toHaveLength(14);
expect(steps[1]).toHaveTextContent('There was a problem with the pod');
});
it('should show in progress notebook startup status', async () => {
const mockData = mockInProgressStates;
render(
<StartNotebookModal
notebookStatus={mockData.notebookStatus}
isStarting={mockData.notebookState.isStarting}
isStopping={mockData.notebookState.isStopping}
isRunning={mockData.notebookState.isRunning}
events={mockData.events}
buttons={null}
/>,
);
// Validate the header contents
const header = screen.getByTestId('notebook-status-modal-header');
expect(header).toHaveTextContent('Workbench statusStarting');
const statusLabel = screen.getByTestId('notebook-latest-status');
expect(statusLabel).toHaveTextContent('Pulling auth proxy');
// Validate the steps
const stepper = screen.getByTestId('notebook-startup-steps');
expect(stepper).toBeTruthy();
expect(screen.getAllByRole('listitem')).toHaveLength(14);
expect(screen.getAllByTestId('step-status-Success')).toHaveLength(10);
expect(screen.getAllByTestId('step-status-Pending')).toHaveLength(4);
});
it('should show completed notebook startup status', async () => {
const mockData = mockCompletedStates;
render(
<StartNotebookModal
notebookStatus={mockData.notebookStatus}
isStarting={mockData.notebookState.isStarting}
isStopping={mockData.notebookState.isStopping}
isRunning={mockData.notebookState.isRunning}
events={mockData.events}
buttons={null}
/>,
);
// Validate the header contents
const header = screen.getByTestId('notebook-status-modal-header');
expect(header).toHaveTextContent('Workbench statusRunning');
// Validate the steps
const stepper = screen.getByTestId('notebook-startup-steps');
expect(stepper).toBeTruthy();
const steps = screen.getAllByRole('listitem');
expect(steps).toHaveLength(14);
expect(screen.getAllByTestId('step-status-Success')).toHaveLength(14);
});
it('should show completed notebook startup status for standalone notebooks', async () => {
const mockData = mockCompletedStates;
render(
<StartNotebookModal
notebookStatus={mockData.notebookStatus}
isStarting
isStopping={mockData.notebookState.isStopping}
isRunning={mockData.notebookState.isRunning}
events={mockData.events}
buttons={null}
/>,
);
// Validate the header contents
const header = screen.getByTestId('notebook-status-modal-header');
expect(header).toHaveTextContent('Workbench statusRunning');
// Validate the steps
const stepper = screen.getByTestId('notebook-startup-steps');
expect(stepper).toBeTruthy();
const steps = screen.getAllByRole('listitem');
expect(steps).toHaveLength(14);
expect(screen.getAllByTestId('step-status-Success')).toHaveLength(14);
});
it('should show stopping notebook status', async () => {
render(
<StartNotebookModal
notebookStatus={null}
isStarting={false}
isStopping
isRunning={false}
events={[]}
buttons={null}
/>,
);
// Validate the header contents
const header = screen.getByTestId('notebook-status-modal-header');
expect(header).toHaveTextContent('Workbench statusStopping');
const statusLabel = screen.getByTestId('notebook-latest-status');
expect(statusLabel).toHaveTextContent('Shutting down the server');
// Validate the steps
const stepper = screen.getByTestId('notebook-startup-steps');
expect(stepper).toBeTruthy();
const steps = screen.getAllByRole('listitem');
expect(steps).toHaveLength(13);
expect(screen.getAllByTestId('step-status-Pending')).toHaveLength(13);
});
});