@strapi/plugin-documentation 4.12.0-beta.3 → 4.12.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/src/hooks/useDocumentation.js +77 -0
- package/admin/src/index.js +2 -2
- package/admin/src/pages/PluginPage/index.js +59 -49
- package/admin/src/pages/PluginPage/tests/index.test.js +152 -807
- package/admin/src/pages/SettingsPage/index.js +36 -15
- package/admin/src/pages/SettingsPage/tests/index.test.js +86 -587
- package/jest.config.front.js +1 -0
- package/package.json +6 -12
- package/tests/server.js +37 -0
- package/tests/setup.js +15 -0
- package/admin/src/components/FieldActionWrapper/index.js +0 -14
- package/admin/src/components/PluginIcon/index.js +0 -13
- package/admin/src/pages/PluginPage/tests/server.js +0 -23
- package/admin/src/pages/SettingsPage/tests/server.js +0 -18
- package/admin/src/pages/utils/schema.js +0 -11
- package/admin/src/pages/utils/useReactQuery.js +0 -67
- package/admin/src/utils/openWithNewTab.js +0 -19
|
@@ -1,861 +1,206 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
import { fixtures } from '@strapi/admin-test-utils';
|
|
3
4
|
import { lightTheme, ThemeProvider } from '@strapi/design-system';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { NotificationsProvider, RBACContext } from '@strapi/helper-plugin';
|
|
6
|
+
import { render as renderRTL, waitFor } from '@testing-library/react';
|
|
7
|
+
import userEvent from '@testing-library/user-event';
|
|
6
8
|
import { IntlProvider } from 'react-intl';
|
|
7
9
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
8
|
-
import {
|
|
10
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
9
11
|
|
|
10
12
|
import PluginPage from '../index';
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const render = ({ permissions } = { permissions: fixtures.permissions.allPermissions }) => ({
|
|
15
|
+
...renderRTL(<PluginPage />, {
|
|
16
|
+
wrapper({ children }) {
|
|
17
|
+
const client = new QueryClient({
|
|
18
|
+
defaultOptions: {
|
|
19
|
+
queries: {
|
|
20
|
+
retry: false,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
26
|
+
const rbacContextValue = React.useMemo(
|
|
27
|
+
() => ({
|
|
28
|
+
allPermissions: permissions,
|
|
29
|
+
}),
|
|
30
|
+
[]
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<MemoryRouter>
|
|
35
|
+
<ThemeProvider theme={lightTheme}>
|
|
36
|
+
<QueryClientProvider client={client}>
|
|
37
|
+
<IntlProvider locale="en" messages={{}} textComponent="span">
|
|
38
|
+
<NotificationsProvider>
|
|
39
|
+
<RBACContext.Provider value={rbacContextValue}>{children}</RBACContext.Provider>
|
|
40
|
+
</NotificationsProvider>
|
|
41
|
+
</IntlProvider>
|
|
42
|
+
</QueryClientProvider>
|
|
43
|
+
</ThemeProvider>
|
|
44
|
+
</MemoryRouter>
|
|
45
|
+
);
|
|
24
46
|
},
|
|
25
|
-
},
|
|
47
|
+
}),
|
|
48
|
+
user: userEvent.setup(),
|
|
26
49
|
});
|
|
27
50
|
|
|
28
|
-
const
|
|
29
|
-
<Router history={history}>
|
|
30
|
-
<ThemeProvider theme={lightTheme}>
|
|
31
|
-
<QueryClientProvider client={client}>
|
|
32
|
-
<IntlProvider locale="en" messages={{}} textComponent="span">
|
|
33
|
-
<PluginPage />
|
|
34
|
-
</IntlProvider>
|
|
35
|
-
</QueryClientProvider>
|
|
36
|
-
</ThemeProvider>
|
|
37
|
-
</Router>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
describe('Plugin | Documentation | PluginPage', () => {
|
|
41
|
-
beforeAll(() => server.listen());
|
|
42
|
-
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
jest.clearAllMocks();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
afterEach(() => server.resetHandlers());
|
|
48
|
-
|
|
49
|
-
afterAll(() => server.close());
|
|
50
|
-
|
|
51
|
-
it('should show a loader when fetching data', () => {
|
|
52
|
-
const history = createMemoryHistory();
|
|
53
|
-
const App = makeApp(history);
|
|
54
|
-
render(App);
|
|
55
|
-
|
|
56
|
-
expect(screen.getByTestId('loader')).toBeInTheDocument();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should show a list of versions', async () => {
|
|
60
|
-
const history = createMemoryHistory();
|
|
61
|
-
const App = makeApp(history);
|
|
62
|
-
const {
|
|
63
|
-
container: { firstChild },
|
|
64
|
-
} = render(App);
|
|
65
|
-
|
|
66
|
-
await waitFor(() => expect(screen.getByText('1.0.0')).toBeInTheDocument());
|
|
67
|
-
|
|
68
|
-
expect(firstChild).toMatchInlineSnapshot(`
|
|
69
|
-
.c36 {
|
|
70
|
-
border: 0;
|
|
71
|
-
-webkit-clip: rect(0 0 0 0);
|
|
72
|
-
clip: rect(0 0 0 0);
|
|
73
|
-
height: 1px;
|
|
74
|
-
margin: -1px;
|
|
75
|
-
overflow: hidden;
|
|
76
|
-
padding: 0;
|
|
77
|
-
position: absolute;
|
|
78
|
-
width: 1px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.c9 {
|
|
82
|
-
font-weight: 600;
|
|
83
|
-
font-size: 2rem;
|
|
84
|
-
line-height: 1.25;
|
|
85
|
-
color: #32324d;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.c14 {
|
|
89
|
-
font-size: 0.75rem;
|
|
90
|
-
line-height: 1.33;
|
|
91
|
-
font-weight: 600;
|
|
92
|
-
color: #ffffff;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.c15 {
|
|
96
|
-
font-size: 1rem;
|
|
97
|
-
line-height: 1.5;
|
|
98
|
-
color: #666687;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.c27 {
|
|
102
|
-
font-weight: 600;
|
|
103
|
-
font-size: 0.6875rem;
|
|
104
|
-
line-height: 1.45;
|
|
105
|
-
text-transform: uppercase;
|
|
106
|
-
color: #666687;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.c31 {
|
|
110
|
-
font-size: 0.875rem;
|
|
111
|
-
line-height: 1.43;
|
|
112
|
-
color: #32324d;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.c1 {
|
|
116
|
-
padding-bottom: 56px;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.c4 {
|
|
120
|
-
background: #f6f6f9;
|
|
121
|
-
padding-top: 40px;
|
|
122
|
-
padding-right: 56px;
|
|
123
|
-
padding-bottom: 40px;
|
|
124
|
-
padding-left: 56px;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.c6 {
|
|
128
|
-
min-width: 0;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.c10 {
|
|
132
|
-
background: #4945ff;
|
|
133
|
-
padding: 8px;
|
|
134
|
-
padding-right: 16px;
|
|
135
|
-
padding-left: 16px;
|
|
136
|
-
border-radius: 4px;
|
|
137
|
-
border-color: #4945ff;
|
|
138
|
-
border: 1px solid #4945ff;
|
|
139
|
-
cursor: pointer;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.c16 {
|
|
143
|
-
padding-right: 56px;
|
|
144
|
-
padding-left: 56px;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.c17 {
|
|
148
|
-
background: #ffffff;
|
|
149
|
-
border-radius: 4px;
|
|
150
|
-
box-shadow: 0px 1px 4px rgba(33,33,52,0.1);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.c19 {
|
|
154
|
-
position: relative;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.c21 {
|
|
158
|
-
padding-right: 24px;
|
|
159
|
-
padding-left: 24px;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.c30 {
|
|
163
|
-
width: 50%;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.c33 {
|
|
167
|
-
background: #ffffff;
|
|
168
|
-
padding: 8px;
|
|
169
|
-
border-radius: 4px;
|
|
170
|
-
border-width: 0;
|
|
171
|
-
border-color: #dcdce4;
|
|
172
|
-
width: 2rem;
|
|
173
|
-
height: 2rem;
|
|
174
|
-
cursor: pointer;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.c5 {
|
|
178
|
-
-webkit-align-items: center;
|
|
179
|
-
-webkit-box-align: center;
|
|
180
|
-
-ms-flex-align: center;
|
|
181
|
-
align-items: center;
|
|
182
|
-
display: -webkit-box;
|
|
183
|
-
display: -webkit-flex;
|
|
184
|
-
display: -ms-flexbox;
|
|
185
|
-
display: flex;
|
|
186
|
-
-webkit-flex-direction: row;
|
|
187
|
-
-ms-flex-direction: row;
|
|
188
|
-
flex-direction: row;
|
|
189
|
-
-webkit-box-pack: justify;
|
|
190
|
-
-webkit-justify-content: space-between;
|
|
191
|
-
-ms-flex-pack: justify;
|
|
192
|
-
justify-content: space-between;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
.c7 {
|
|
196
|
-
-webkit-align-items: center;
|
|
197
|
-
-webkit-box-align: center;
|
|
198
|
-
-ms-flex-align: center;
|
|
199
|
-
align-items: center;
|
|
200
|
-
display: -webkit-box;
|
|
201
|
-
display: -webkit-flex;
|
|
202
|
-
display: -ms-flexbox;
|
|
203
|
-
display: flex;
|
|
204
|
-
-webkit-flex-direction: row;
|
|
205
|
-
-ms-flex-direction: row;
|
|
206
|
-
flex-direction: row;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.c11 {
|
|
210
|
-
-webkit-align-items: center;
|
|
211
|
-
-webkit-box-align: center;
|
|
212
|
-
-ms-flex-align: center;
|
|
213
|
-
align-items: center;
|
|
214
|
-
display: -webkit-box;
|
|
215
|
-
display: -webkit-flex;
|
|
216
|
-
display: -ms-flexbox;
|
|
217
|
-
display: flex;
|
|
218
|
-
-webkit-flex-direction: row;
|
|
219
|
-
-ms-flex-direction: row;
|
|
220
|
-
flex-direction: row;
|
|
221
|
-
gap: 8px;
|
|
222
|
-
}
|
|
51
|
+
const versions = ['2.0.0', '1.2.0', '1.0.0'];
|
|
223
52
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
-ms-flex-align: center;
|
|
228
|
-
align-items: center;
|
|
229
|
-
display: -webkit-box;
|
|
230
|
-
display: -webkit-flex;
|
|
231
|
-
display: -ms-flexbox;
|
|
232
|
-
display: flex;
|
|
233
|
-
-webkit-flex-direction: row;
|
|
234
|
-
-ms-flex-direction: row;
|
|
235
|
-
flex-direction: row;
|
|
236
|
-
-webkit-box-pack: end;
|
|
237
|
-
-webkit-justify-content: end;
|
|
238
|
-
-ms-flex-pack: end;
|
|
239
|
-
justify-content: end;
|
|
240
|
-
}
|
|
53
|
+
describe('PluginPage', () => {
|
|
54
|
+
it('render the plugin page correctly', async () => {
|
|
55
|
+
const { getByRole, queryByText, getByText } = render();
|
|
241
56
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
display: -ms-flexbox;
|
|
250
|
-
display: flex;
|
|
251
|
-
-webkit-flex-direction: row;
|
|
252
|
-
-ms-flex-direction: row;
|
|
253
|
-
flex-direction: row;
|
|
254
|
-
-webkit-box-pack: center;
|
|
255
|
-
-webkit-justify-content: center;
|
|
256
|
-
-ms-flex-pack: center;
|
|
257
|
-
justify-content: center;
|
|
258
|
-
}
|
|
57
|
+
expect(getByRole('heading', { name: 'Documentation' })).toBeInTheDocument();
|
|
58
|
+
expect(getByText('Configure the documentation plugin')).toBeInTheDocument();
|
|
59
|
+
expect(queryByText('Plugin is loading')).toBeInTheDocument();
|
|
60
|
+
expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
|
|
61
|
+
'aria-disabled',
|
|
62
|
+
'true'
|
|
63
|
+
);
|
|
259
64
|
|
|
260
|
-
|
|
261
|
-
position: relative;
|
|
262
|
-
outline: none;
|
|
263
|
-
}
|
|
65
|
+
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
264
66
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
67
|
+
expect(getByRole('heading', { name: 'Documentation' })).toBeInTheDocument();
|
|
68
|
+
expect(getByText('Configure the documentation plugin')).toBeInTheDocument();
|
|
69
|
+
expect(getByRole('link', { name: 'Open Documentation' })).toBeInTheDocument();
|
|
269
70
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
71
|
+
expect(getByRole('grid')).toBeInTheDocument();
|
|
72
|
+
expect(getByRole('gridcell', { name: 'Version' })).toBeInTheDocument();
|
|
73
|
+
expect(getByRole('gridcell', { name: 'Last Generated' })).toBeInTheDocument();
|
|
274
74
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
75
|
+
versions.forEach((version) => {
|
|
76
|
+
expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
|
|
77
|
+
expect(getByRole('link', { name: `Open ${version}` })).toBeInTheDocument();
|
|
78
|
+
expect(getByRole('button', { name: `Regenerate ${version}` })).toBeInTheDocument();
|
|
278
79
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
border-radius: 8px;
|
|
285
|
-
content: '';
|
|
286
|
-
position: absolute;
|
|
287
|
-
top: -4px;
|
|
288
|
-
bottom: -4px;
|
|
289
|
-
left: -4px;
|
|
290
|
-
right: -4px;
|
|
291
|
-
border: 2px solid transparent;
|
|
80
|
+
/**
|
|
81
|
+
* You can't delete the original version
|
|
82
|
+
*/
|
|
83
|
+
if (version !== '1.0.0') {
|
|
84
|
+
expect(getByRole('button', { name: `Delete ${version}` })).toBeInTheDocument();
|
|
292
85
|
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
293
88
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
89
|
+
describe('actions', () => {
|
|
90
|
+
it('should open the documentation', async () => {
|
|
91
|
+
const { getByRole, queryByText, user } = render();
|
|
297
92
|
|
|
298
|
-
.
|
|
299
|
-
border-radius: 8px;
|
|
300
|
-
content: '';
|
|
301
|
-
position: absolute;
|
|
302
|
-
top: -5px;
|
|
303
|
-
bottom: -5px;
|
|
304
|
-
left: -5px;
|
|
305
|
-
right: -5px;
|
|
306
|
-
border: 2px solid #4945ff;
|
|
307
|
-
}
|
|
93
|
+
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
308
94
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
95
|
+
expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
|
|
96
|
+
'href',
|
|
97
|
+
'http://localhost:1337/documentation/v1.0.0'
|
|
98
|
+
);
|
|
312
99
|
|
|
313
|
-
.
|
|
314
|
-
height: 0.75rem;
|
|
315
|
-
width: auto;
|
|
316
|
-
}
|
|
100
|
+
await user.click(getByRole('link', { name: 'Open Documentation' }));
|
|
317
101
|
|
|
318
|
-
.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
102
|
+
versions.forEach((version) => {
|
|
103
|
+
expect(getByRole('link', { name: `Open ${version}` })).toHaveAttribute(
|
|
104
|
+
'href',
|
|
105
|
+
`http://localhost:1337/documentation/v${version}`
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
322
109
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
110
|
+
it('should regenerate the documentation', async () => {
|
|
111
|
+
const { getByRole, queryByText, user, getByText } = render();
|
|
326
112
|
|
|
327
|
-
|
|
328
|
-
fill: #666687;
|
|
329
|
-
}
|
|
113
|
+
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
330
114
|
|
|
331
|
-
|
|
332
|
-
border: 1px solid #dcdce4;
|
|
333
|
-
background: #eaeaef;
|
|
334
|
-
}
|
|
115
|
+
expect(getByRole('button', { name: 'Regenerate 2.0.0' })).toBeInTheDocument();
|
|
335
116
|
|
|
336
|
-
.
|
|
337
|
-
color: #666687;
|
|
338
|
-
}
|
|
117
|
+
await user.click(getByRole('button', { name: 'Regenerate 2.0.0' }));
|
|
339
118
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
119
|
+
expect(getByText('Successfully generated documentation')).toBeInTheDocument();
|
|
120
|
+
});
|
|
343
121
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
background: #7b79ff;
|
|
347
|
-
}
|
|
122
|
+
it('should delete the documentation', async () => {
|
|
123
|
+
const { getByRole, queryByText, user, getByText } = render();
|
|
348
124
|
|
|
349
|
-
.
|
|
350
|
-
border: 1px solid #4945ff;
|
|
351
|
-
background: #4945ff;
|
|
352
|
-
}
|
|
125
|
+
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
353
126
|
|
|
354
|
-
|
|
355
|
-
.c13 svg path {
|
|
356
|
-
fill: #ffffff;
|
|
357
|
-
}
|
|
127
|
+
expect(getByRole('button', { name: 'Delete 2.0.0' })).toBeInTheDocument();
|
|
358
128
|
|
|
359
|
-
.
|
|
360
|
-
.c35 svg path {
|
|
361
|
-
fill: #8e8ea9;
|
|
362
|
-
}
|
|
129
|
+
await user.click(getByRole('button', { name: 'Delete 2.0.0' }));
|
|
363
130
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
131
|
+
expect(getByRole('dialog', { name: 'Confirmation' })).toBeInTheDocument();
|
|
132
|
+
expect(getByRole('button', { name: 'Confirm' })).toBeInTheDocument();
|
|
133
|
+
expect(getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
|
|
368
134
|
|
|
369
|
-
.
|
|
370
|
-
.c35:active svg path {
|
|
371
|
-
fill: #a5a5ba;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
.c35[aria-disabled='true'] svg path {
|
|
375
|
-
fill: #666687;
|
|
376
|
-
}
|
|
135
|
+
await user.click(getByRole('button', { name: 'Confirm' }));
|
|
377
136
|
|
|
378
|
-
.
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
.c2 {
|
|
384
|
-
overflow-x: hidden;
|
|
385
|
-
}
|
|
137
|
+
expect(getByText('Successfully deleted documentation')).toBeInTheDocument();
|
|
138
|
+
});
|
|
139
|
+
});
|
|
386
140
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
141
|
+
describe('permissions', () => {
|
|
142
|
+
it("should always disable the 'Open Documentation' link if the user cannot open", async () => {
|
|
143
|
+
const { getByRole, queryByText } = render({
|
|
144
|
+
permissions: [],
|
|
145
|
+
});
|
|
390
146
|
|
|
391
|
-
.
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
147
|
+
expect(queryByText('Plugin is loading')).toBeInTheDocument();
|
|
148
|
+
expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
|
|
149
|
+
'aria-disabled',
|
|
150
|
+
'true'
|
|
151
|
+
);
|
|
395
152
|
|
|
396
|
-
.
|
|
397
|
-
width: 100%;
|
|
398
|
-
white-space: nowrap;
|
|
399
|
-
}
|
|
153
|
+
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
400
154
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
box-shadow: 0px 1px 4px rgba(33,33,52,0.1);
|
|
407
|
-
width: 8px;
|
|
408
|
-
left: 0;
|
|
409
|
-
}
|
|
155
|
+
expect(getByRole('link', { name: 'Open Documentation' })).toHaveAttribute(
|
|
156
|
+
'aria-disabled',
|
|
157
|
+
'true'
|
|
158
|
+
);
|
|
159
|
+
});
|
|
410
160
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
height: 100%;
|
|
416
|
-
box-shadow: 0px 1px 4px rgba(33,33,52,0.1);
|
|
417
|
-
width: 8px;
|
|
418
|
-
right: 0;
|
|
419
|
-
top: 0;
|
|
420
|
-
}
|
|
161
|
+
it('should disabled the open documentation version link in the table if the user cannot open', async () => {
|
|
162
|
+
const { getByRole, queryByText } = render({
|
|
163
|
+
permissions: [],
|
|
164
|
+
});
|
|
421
165
|
|
|
422
|
-
.
|
|
423
|
-
overflow-x: auto;
|
|
424
|
-
}
|
|
166
|
+
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
425
167
|
|
|
426
|
-
.
|
|
427
|
-
|
|
428
|
-
}
|
|
168
|
+
versions.forEach((version) => {
|
|
169
|
+
expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
|
|
429
170
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
171
|
+
expect(getByRole('link', { name: `Open ${version}` })).toHaveAttribute(
|
|
172
|
+
'aria-disabled',
|
|
173
|
+
'true'
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
433
177
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
178
|
+
it('should not render the regenerate buttons if the user cannot regenerate', async () => {
|
|
179
|
+
const { queryByRole, getByRole, queryByText } = render({
|
|
180
|
+
permissions: [],
|
|
181
|
+
});
|
|
437
182
|
|
|
438
|
-
.
|
|
439
|
-
.c25 th {
|
|
440
|
-
padding: 16px;
|
|
441
|
-
}
|
|
183
|
+
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
442
184
|
|
|
443
|
-
.
|
|
444
|
-
|
|
445
|
-
padding: 0 4px;
|
|
446
|
-
}
|
|
185
|
+
versions.forEach((version) => {
|
|
186
|
+
expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
|
|
447
187
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
height: 3.5rem;
|
|
452
|
-
}
|
|
188
|
+
expect(queryByRole('button', { name: `Regenerate ${version}` })).not.toBeInTheDocument();
|
|
189
|
+
});
|
|
190
|
+
});
|
|
453
191
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
outline-offset: -4px;
|
|
459
|
-
}
|
|
192
|
+
it('should not render the delete buttons if the user cannot delete', async () => {
|
|
193
|
+
const { queryByRole, getByRole, queryByText } = render({
|
|
194
|
+
permissions: [],
|
|
195
|
+
});
|
|
460
196
|
|
|
461
|
-
|
|
462
|
-
vertical-align: sub;
|
|
463
|
-
}
|
|
197
|
+
await waitFor(() => expect(queryByText('Plugin is loading')).not.toBeInTheDocument());
|
|
464
198
|
|
|
465
|
-
.
|
|
466
|
-
|
|
467
|
-
}
|
|
199
|
+
versions.forEach((version) => {
|
|
200
|
+
expect(getByRole('gridcell', { name: version })).toBeInTheDocument();
|
|
468
201
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
<div
|
|
473
|
-
class="c1 c2"
|
|
474
|
-
>
|
|
475
|
-
<main
|
|
476
|
-
aria-busy="false"
|
|
477
|
-
aria-labelledby="main-content-title"
|
|
478
|
-
class="c3"
|
|
479
|
-
id="main-content"
|
|
480
|
-
tabindex="-1"
|
|
481
|
-
>
|
|
482
|
-
<div
|
|
483
|
-
style="height: 0px;"
|
|
484
|
-
>
|
|
485
|
-
<div
|
|
486
|
-
class="c4"
|
|
487
|
-
data-strapi-header="true"
|
|
488
|
-
>
|
|
489
|
-
<div
|
|
490
|
-
class="c5"
|
|
491
|
-
>
|
|
492
|
-
<div
|
|
493
|
-
class="c6 c7"
|
|
494
|
-
>
|
|
495
|
-
<h1
|
|
496
|
-
class="c8 c9"
|
|
497
|
-
>
|
|
498
|
-
Documentation
|
|
499
|
-
</h1>
|
|
500
|
-
</div>
|
|
501
|
-
<button
|
|
502
|
-
aria-disabled="false"
|
|
503
|
-
class="c10 c11 c12 c13"
|
|
504
|
-
type="button"
|
|
505
|
-
>
|
|
506
|
-
<div
|
|
507
|
-
aria-hidden="true"
|
|
508
|
-
class=""
|
|
509
|
-
>
|
|
510
|
-
<svg
|
|
511
|
-
fill="none"
|
|
512
|
-
height="1rem"
|
|
513
|
-
viewBox="0 0 24 24"
|
|
514
|
-
width="1rem"
|
|
515
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
516
|
-
>
|
|
517
|
-
<path
|
|
518
|
-
d="M15.2 12a3.2 3.2 0 1 1-6.399 0 3.2 3.2 0 0 1 6.4 0Z"
|
|
519
|
-
fill="#212134"
|
|
520
|
-
/>
|
|
521
|
-
<path
|
|
522
|
-
clip-rule="evenodd"
|
|
523
|
-
d="M18.78 6.103c1.923 1.243 3.64 2.981 4.963 5.027a1.61 1.61 0 0 1 .005 1.738c-1.318 2.063-3.031 3.807-4.954 5.046-2.12 1.364-4.475 2.086-6.81 2.086-2.388 0-4.683-.7-6.816-2.082-1.894-1.225-3.593-2.966-4.914-5.032a1.596 1.596 0 0 1 .032-1.777C1.89 8.811 3.734 7.027 5.77 5.805 7.767 4.608 9.858 4 11.984 4c2.317 0 4.667.728 6.795 2.103Zm-9.446 9.888a4.8 4.8 0 1 0 5.334-7.982 4.8 4.8 0 0 0-5.334 7.982Z"
|
|
524
|
-
fill="#212134"
|
|
525
|
-
fill-rule="evenodd"
|
|
526
|
-
/>
|
|
527
|
-
</svg>
|
|
528
|
-
</div>
|
|
529
|
-
<span
|
|
530
|
-
class="c8 c14"
|
|
531
|
-
>
|
|
532
|
-
Open Documentation
|
|
533
|
-
</span>
|
|
534
|
-
</button>
|
|
535
|
-
</div>
|
|
536
|
-
<p
|
|
537
|
-
class="c8 c15"
|
|
538
|
-
>
|
|
539
|
-
Configure the documentation plugin
|
|
540
|
-
</p>
|
|
541
|
-
</div>
|
|
542
|
-
</div>
|
|
543
|
-
<div
|
|
544
|
-
class="c16"
|
|
545
|
-
>
|
|
546
|
-
<div
|
|
547
|
-
class="c17 c18"
|
|
548
|
-
>
|
|
549
|
-
<div
|
|
550
|
-
class="c19 c20"
|
|
551
|
-
>
|
|
552
|
-
<div
|
|
553
|
-
class="c21 c22"
|
|
554
|
-
>
|
|
555
|
-
<table
|
|
556
|
-
aria-colcount="4"
|
|
557
|
-
aria-rowcount="3"
|
|
558
|
-
class="c23"
|
|
559
|
-
role="grid"
|
|
560
|
-
>
|
|
561
|
-
<thead
|
|
562
|
-
class="c24"
|
|
563
|
-
>
|
|
564
|
-
<tr
|
|
565
|
-
aria-rowindex="1"
|
|
566
|
-
class="c25"
|
|
567
|
-
>
|
|
568
|
-
<th
|
|
569
|
-
aria-colindex="1"
|
|
570
|
-
class="c26"
|
|
571
|
-
role="gridcell"
|
|
572
|
-
tabindex="0"
|
|
573
|
-
>
|
|
574
|
-
<div
|
|
575
|
-
class="c7"
|
|
576
|
-
>
|
|
577
|
-
<span
|
|
578
|
-
class="c8 c27"
|
|
579
|
-
>
|
|
580
|
-
Version
|
|
581
|
-
</span>
|
|
582
|
-
<span
|
|
583
|
-
class="c28"
|
|
584
|
-
/>
|
|
585
|
-
</div>
|
|
586
|
-
</th>
|
|
587
|
-
<th
|
|
588
|
-
aria-colindex="2"
|
|
589
|
-
class="c26"
|
|
590
|
-
role="gridcell"
|
|
591
|
-
tabindex="-1"
|
|
592
|
-
>
|
|
593
|
-
<div
|
|
594
|
-
class="c7"
|
|
595
|
-
>
|
|
596
|
-
<span
|
|
597
|
-
class="c8 c27"
|
|
598
|
-
>
|
|
599
|
-
Last Generated
|
|
600
|
-
</span>
|
|
601
|
-
<span
|
|
602
|
-
class="c28"
|
|
603
|
-
/>
|
|
604
|
-
</div>
|
|
605
|
-
</th>
|
|
606
|
-
</tr>
|
|
607
|
-
</thead>
|
|
608
|
-
<tbody
|
|
609
|
-
class="c29"
|
|
610
|
-
>
|
|
611
|
-
<tr
|
|
612
|
-
aria-rowindex="2"
|
|
613
|
-
class="c25"
|
|
614
|
-
>
|
|
615
|
-
<td
|
|
616
|
-
aria-colindex="1"
|
|
617
|
-
class="c30 c26"
|
|
618
|
-
role="gridcell"
|
|
619
|
-
tabindex="-1"
|
|
620
|
-
>
|
|
621
|
-
<span
|
|
622
|
-
class="c8 c31"
|
|
623
|
-
>
|
|
624
|
-
1.2.0
|
|
625
|
-
</span>
|
|
626
|
-
</td>
|
|
627
|
-
<td
|
|
628
|
-
aria-colindex="2"
|
|
629
|
-
class="c30 c26"
|
|
630
|
-
role="gridcell"
|
|
631
|
-
tabindex="-1"
|
|
632
|
-
>
|
|
633
|
-
<span
|
|
634
|
-
class="c8 c31"
|
|
635
|
-
/>
|
|
636
|
-
</td>
|
|
637
|
-
<td
|
|
638
|
-
aria-colindex="3"
|
|
639
|
-
class="c26"
|
|
640
|
-
role="gridcell"
|
|
641
|
-
>
|
|
642
|
-
<div
|
|
643
|
-
aria-hidden="true"
|
|
644
|
-
class="c32"
|
|
645
|
-
role="button"
|
|
646
|
-
>
|
|
647
|
-
<span>
|
|
648
|
-
<button
|
|
649
|
-
aria-disabled="false"
|
|
650
|
-
aria-labelledby=":r2:"
|
|
651
|
-
class="c33 c34 c12 c35"
|
|
652
|
-
tabindex="-1"
|
|
653
|
-
type="button"
|
|
654
|
-
>
|
|
655
|
-
<span
|
|
656
|
-
class="c36"
|
|
657
|
-
>
|
|
658
|
-
Open 1.2.0
|
|
659
|
-
</span>
|
|
660
|
-
<svg
|
|
661
|
-
aria-hidden="true"
|
|
662
|
-
fill="none"
|
|
663
|
-
focusable="false"
|
|
664
|
-
height="1rem"
|
|
665
|
-
viewBox="0 0 24 24"
|
|
666
|
-
width="1rem"
|
|
667
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
668
|
-
>
|
|
669
|
-
<path
|
|
670
|
-
d="M15.2 12a3.2 3.2 0 1 1-6.399 0 3.2 3.2 0 0 1 6.4 0Z"
|
|
671
|
-
fill="#212134"
|
|
672
|
-
/>
|
|
673
|
-
<path
|
|
674
|
-
clip-rule="evenodd"
|
|
675
|
-
d="M18.78 6.103c1.923 1.243 3.64 2.981 4.963 5.027a1.61 1.61 0 0 1 .005 1.738c-1.318 2.063-3.031 3.807-4.954 5.046-2.12 1.364-4.475 2.086-6.81 2.086-2.388 0-4.683-.7-6.816-2.082-1.894-1.225-3.593-2.966-4.914-5.032a1.596 1.596 0 0 1 .032-1.777C1.89 8.811 3.734 7.027 5.77 5.805 7.767 4.608 9.858 4 11.984 4c2.317 0 4.667.728 6.795 2.103Zm-9.446 9.888a4.8 4.8 0 1 0 5.334-7.982 4.8 4.8 0 0 0-5.334 7.982Z"
|
|
676
|
-
fill="#212134"
|
|
677
|
-
fill-rule="evenodd"
|
|
678
|
-
/>
|
|
679
|
-
</svg>
|
|
680
|
-
</button>
|
|
681
|
-
</span>
|
|
682
|
-
<span>
|
|
683
|
-
<button
|
|
684
|
-
aria-disabled="false"
|
|
685
|
-
aria-labelledby=":r4:"
|
|
686
|
-
class="c33 c34 c12 c35"
|
|
687
|
-
tabindex="-1"
|
|
688
|
-
type="button"
|
|
689
|
-
>
|
|
690
|
-
<span
|
|
691
|
-
class="c36"
|
|
692
|
-
>
|
|
693
|
-
Regenerate 1.2.0
|
|
694
|
-
</span>
|
|
695
|
-
<svg
|
|
696
|
-
aria-hidden="true"
|
|
697
|
-
fill="none"
|
|
698
|
-
focusable="false"
|
|
699
|
-
height="1rem"
|
|
700
|
-
viewBox="0 0 24 24"
|
|
701
|
-
width="1rem"
|
|
702
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
703
|
-
>
|
|
704
|
-
<path
|
|
705
|
-
clip-rule="evenodd"
|
|
706
|
-
d="M15.681 2.804A9.64 9.64 0 0 0 11.818 2C6.398 2 2 6.48 2 12c0 5.521 4.397 10 9.818 10 2.03 0 4.011-.641 5.67-1.835a9.987 9.987 0 0 0 3.589-4.831 1.117 1.117 0 0 0-.664-1.418 1.086 1.086 0 0 0-1.393.676 7.769 7.769 0 0 1-2.792 3.758 7.546 7.546 0 0 1-4.41 1.428V4.222h.002a7.492 7.492 0 0 1 3.003.625 7.61 7.61 0 0 1 2.5 1.762l.464.551-2.986 3.042a.186.186 0 0 0 .129.316H22V3.317a.188.188 0 0 0-.112-.172.179.179 0 0 0-.199.04l-2.355 2.4-.394-.468-.02-.02a9.791 9.791 0 0 0-3.239-2.293Zm-3.863 1.418V2v2.222Zm0 0v15.556c-4.216 0-7.636-3.484-7.636-7.778s3.42-7.777 7.636-7.778Z"
|
|
707
|
-
fill="#212134"
|
|
708
|
-
fill-rule="evenodd"
|
|
709
|
-
/>
|
|
710
|
-
</svg>
|
|
711
|
-
</button>
|
|
712
|
-
</span>
|
|
713
|
-
<span>
|
|
714
|
-
<button
|
|
715
|
-
aria-disabled="false"
|
|
716
|
-
aria-labelledby=":r6:"
|
|
717
|
-
class="c33 c34 c12 c35"
|
|
718
|
-
tabindex="-1"
|
|
719
|
-
type="button"
|
|
720
|
-
>
|
|
721
|
-
<span
|
|
722
|
-
class="c36"
|
|
723
|
-
>
|
|
724
|
-
Delete 1.2.0
|
|
725
|
-
</span>
|
|
726
|
-
<svg
|
|
727
|
-
aria-hidden="true"
|
|
728
|
-
fill="none"
|
|
729
|
-
focusable="false"
|
|
730
|
-
height="1rem"
|
|
731
|
-
viewBox="0 0 24 24"
|
|
732
|
-
width="1rem"
|
|
733
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
734
|
-
>
|
|
735
|
-
<path
|
|
736
|
-
d="M3.236 6.149a.2.2 0 0 0-.197.233L6 24h12l2.96-17.618a.2.2 0 0 0-.196-.233H3.236ZM21.8 1.983c.11 0 .2.09.2.2v1.584a.2.2 0 0 1-.2.2H2.2a.2.2 0 0 1-.2-.2V2.183c0-.11.09-.2.2-.2h5.511c.9 0 1.631-1.09 1.631-1.983h5.316c0 .894.73 1.983 1.631 1.983H21.8Z"
|
|
737
|
-
fill="#32324D"
|
|
738
|
-
/>
|
|
739
|
-
</svg>
|
|
740
|
-
</button>
|
|
741
|
-
</span>
|
|
742
|
-
</div>
|
|
743
|
-
</td>
|
|
744
|
-
</tr>
|
|
745
|
-
<tr
|
|
746
|
-
aria-rowindex="3"
|
|
747
|
-
class="c25"
|
|
748
|
-
>
|
|
749
|
-
<td
|
|
750
|
-
aria-colindex="1"
|
|
751
|
-
class="c30 c26"
|
|
752
|
-
role="gridcell"
|
|
753
|
-
tabindex="-1"
|
|
754
|
-
>
|
|
755
|
-
<span
|
|
756
|
-
class="c8 c31"
|
|
757
|
-
>
|
|
758
|
-
1.0.0
|
|
759
|
-
</span>
|
|
760
|
-
</td>
|
|
761
|
-
<td
|
|
762
|
-
aria-colindex="2"
|
|
763
|
-
class="c30 c26"
|
|
764
|
-
role="gridcell"
|
|
765
|
-
tabindex="-1"
|
|
766
|
-
>
|
|
767
|
-
<span
|
|
768
|
-
class="c8 c31"
|
|
769
|
-
/>
|
|
770
|
-
</td>
|
|
771
|
-
<td
|
|
772
|
-
aria-colindex="3"
|
|
773
|
-
class="c26"
|
|
774
|
-
role="gridcell"
|
|
775
|
-
>
|
|
776
|
-
<div
|
|
777
|
-
aria-hidden="true"
|
|
778
|
-
class="c32"
|
|
779
|
-
role="button"
|
|
780
|
-
>
|
|
781
|
-
<span>
|
|
782
|
-
<button
|
|
783
|
-
aria-disabled="false"
|
|
784
|
-
aria-labelledby=":r8:"
|
|
785
|
-
class="c33 c34 c12 c35"
|
|
786
|
-
tabindex="-1"
|
|
787
|
-
type="button"
|
|
788
|
-
>
|
|
789
|
-
<span
|
|
790
|
-
class="c36"
|
|
791
|
-
>
|
|
792
|
-
Open 1.0.0
|
|
793
|
-
</span>
|
|
794
|
-
<svg
|
|
795
|
-
aria-hidden="true"
|
|
796
|
-
fill="none"
|
|
797
|
-
focusable="false"
|
|
798
|
-
height="1rem"
|
|
799
|
-
viewBox="0 0 24 24"
|
|
800
|
-
width="1rem"
|
|
801
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
802
|
-
>
|
|
803
|
-
<path
|
|
804
|
-
d="M15.2 12a3.2 3.2 0 1 1-6.399 0 3.2 3.2 0 0 1 6.4 0Z"
|
|
805
|
-
fill="#212134"
|
|
806
|
-
/>
|
|
807
|
-
<path
|
|
808
|
-
clip-rule="evenodd"
|
|
809
|
-
d="M18.78 6.103c1.923 1.243 3.64 2.981 4.963 5.027a1.61 1.61 0 0 1 .005 1.738c-1.318 2.063-3.031 3.807-4.954 5.046-2.12 1.364-4.475 2.086-6.81 2.086-2.388 0-4.683-.7-6.816-2.082-1.894-1.225-3.593-2.966-4.914-5.032a1.596 1.596 0 0 1 .032-1.777C1.89 8.811 3.734 7.027 5.77 5.805 7.767 4.608 9.858 4 11.984 4c2.317 0 4.667.728 6.795 2.103Zm-9.446 9.888a4.8 4.8 0 1 0 5.334-7.982 4.8 4.8 0 0 0-5.334 7.982Z"
|
|
810
|
-
fill="#212134"
|
|
811
|
-
fill-rule="evenodd"
|
|
812
|
-
/>
|
|
813
|
-
</svg>
|
|
814
|
-
</button>
|
|
815
|
-
</span>
|
|
816
|
-
<span>
|
|
817
|
-
<button
|
|
818
|
-
aria-disabled="false"
|
|
819
|
-
aria-labelledby=":ra:"
|
|
820
|
-
class="c33 c34 c12 c35"
|
|
821
|
-
tabindex="-1"
|
|
822
|
-
type="button"
|
|
823
|
-
>
|
|
824
|
-
<span
|
|
825
|
-
class="c36"
|
|
826
|
-
>
|
|
827
|
-
Regenerate 1.0.0
|
|
828
|
-
</span>
|
|
829
|
-
<svg
|
|
830
|
-
aria-hidden="true"
|
|
831
|
-
fill="none"
|
|
832
|
-
focusable="false"
|
|
833
|
-
height="1rem"
|
|
834
|
-
viewBox="0 0 24 24"
|
|
835
|
-
width="1rem"
|
|
836
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
837
|
-
>
|
|
838
|
-
<path
|
|
839
|
-
clip-rule="evenodd"
|
|
840
|
-
d="M15.681 2.804A9.64 9.64 0 0 0 11.818 2C6.398 2 2 6.48 2 12c0 5.521 4.397 10 9.818 10 2.03 0 4.011-.641 5.67-1.835a9.987 9.987 0 0 0 3.589-4.831 1.117 1.117 0 0 0-.664-1.418 1.086 1.086 0 0 0-1.393.676 7.769 7.769 0 0 1-2.792 3.758 7.546 7.546 0 0 1-4.41 1.428V4.222h.002a7.492 7.492 0 0 1 3.003.625 7.61 7.61 0 0 1 2.5 1.762l.464.551-2.986 3.042a.186.186 0 0 0 .129.316H22V3.317a.188.188 0 0 0-.112-.172.179.179 0 0 0-.199.04l-2.355 2.4-.394-.468-.02-.02a9.791 9.791 0 0 0-3.239-2.293Zm-3.863 1.418V2v2.222Zm0 0v15.556c-4.216 0-7.636-3.484-7.636-7.778s3.42-7.777 7.636-7.778Z"
|
|
841
|
-
fill="#212134"
|
|
842
|
-
fill-rule="evenodd"
|
|
843
|
-
/>
|
|
844
|
-
</svg>
|
|
845
|
-
</button>
|
|
846
|
-
</span>
|
|
847
|
-
</div>
|
|
848
|
-
</td>
|
|
849
|
-
</tr>
|
|
850
|
-
</tbody>
|
|
851
|
-
</table>
|
|
852
|
-
</div>
|
|
853
|
-
</div>
|
|
854
|
-
</div>
|
|
855
|
-
</div>
|
|
856
|
-
</main>
|
|
857
|
-
</div>
|
|
858
|
-
</div>
|
|
859
|
-
`);
|
|
202
|
+
expect(queryByRole('button', { name: `Delete ${version}` })).not.toBeInTheDocument();
|
|
203
|
+
});
|
|
204
|
+
});
|
|
860
205
|
});
|
|
861
206
|
});
|