@pingux/astro 1.2.0-alpha.0 → 1.2.0-alpha.1
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/lib/cjs/components/Breadcrumbs/BreadcrumbItem.js +3 -0
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +24 -14
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.js +9 -0
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +338 -0
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +295 -0
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +287 -0
- package/lib/cjs/components/EnvironmentBreadcrumb/index.js +18 -0
- package/lib/cjs/index.js +10 -0
- package/lib/cjs/styles/variants/boxes.js +13 -0
- package/lib/cjs/styles/variants/buttons.js +23 -0
- package/lib/cjs/styles/variants/text.js +9 -0
- package/lib/components/Breadcrumbs/BreadcrumbItem.js +4 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.js +24 -15
- package/lib/components/Breadcrumbs/Breadcrumbs.test.js +9 -0
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +296 -0
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +256 -0
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +246 -0
- package/lib/components/EnvironmentBreadcrumb/index.js +1 -0
- package/lib/index.js +1 -0
- package/lib/styles/variants/boxes.js +13 -0
- package/lib/styles/variants/buttons.js +23 -0
- package/lib/styles/variants/text.js +9 -0
- package/package.json +1 -1
@@ -0,0 +1,246 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
2
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
3
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
4
|
+
import React from 'react';
|
5
|
+
import userEvent from '@testing-library/user-event';
|
6
|
+
import { Section } from '@react-stately/collections';
|
7
|
+
import { axe } from 'jest-axe';
|
8
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
9
|
+
import { EnvironmentBreadcrumb, Item, OverlayProvider } from '../../index';
|
10
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
11
|
+
var testEnvBreadcrumb = 'test-env-breadcrumb';
|
12
|
+
var testName = 'test-name';
|
13
|
+
var testSelectedItem = 'test-selected-item';
|
14
|
+
var testSearchLabel = 'test-Search-Label';
|
15
|
+
var items = [{
|
16
|
+
name: 'a'
|
17
|
+
}, {
|
18
|
+
name: 'b'
|
19
|
+
}, {
|
20
|
+
name: 'c'
|
21
|
+
}];
|
22
|
+
var itemsWithSections = [{
|
23
|
+
name: 'Heading 1',
|
24
|
+
options: [{
|
25
|
+
name: 'Foo'
|
26
|
+
}, {
|
27
|
+
name: 'Bar'
|
28
|
+
}, {
|
29
|
+
name: 'Baz'
|
30
|
+
}]
|
31
|
+
}];
|
32
|
+
var defaultProps = {
|
33
|
+
'data-testid': testEnvBreadcrumb,
|
34
|
+
name: testName,
|
35
|
+
selectedItem: testSelectedItem,
|
36
|
+
searchProps: {
|
37
|
+
label: testSearchLabel
|
38
|
+
},
|
39
|
+
items: items
|
40
|
+
};
|
41
|
+
var defaultWithSectionsProps = {
|
42
|
+
'data-testid': testEnvBreadcrumb,
|
43
|
+
name: testName,
|
44
|
+
selectedItem: testSelectedItem,
|
45
|
+
searchProps: {
|
46
|
+
label: testSearchLabel
|
47
|
+
},
|
48
|
+
items: itemsWithSections
|
49
|
+
};
|
50
|
+
var onSelectionChange = jest.fn();
|
51
|
+
|
52
|
+
var getComponent = function getComponent(props) {
|
53
|
+
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(EnvironmentBreadcrumb, _extends({}, defaultProps, props), function (item) {
|
54
|
+
return ___EmotionJSX(Item, {
|
55
|
+
key: item.name
|
56
|
+
}, item.name);
|
57
|
+
})));
|
58
|
+
};
|
59
|
+
|
60
|
+
var getSectionsComponent = function getSectionsComponent() {
|
61
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
62
|
+
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(EnvironmentBreadcrumb, _extends({}, defaultWithSectionsProps, props), function (section) {
|
63
|
+
return (// eslint-disable-next-line testing-library/no-node-access
|
64
|
+
___EmotionJSX(Section, {
|
65
|
+
key: section.name,
|
66
|
+
name: section.name,
|
67
|
+
items: section.options
|
68
|
+
}, function (item) {
|
69
|
+
return ___EmotionJSX(Item, {
|
70
|
+
key: item.name,
|
71
|
+
childItems: item.options
|
72
|
+
}, item.name);
|
73
|
+
})
|
74
|
+
);
|
75
|
+
})));
|
76
|
+
};
|
77
|
+
|
78
|
+
beforeAll(function () {
|
79
|
+
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(function () {
|
80
|
+
return 1000;
|
81
|
+
});
|
82
|
+
jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(function () {
|
83
|
+
return 1000;
|
84
|
+
});
|
85
|
+
window.HTMLElement.prototype.scrollIntoView = jest.fn();
|
86
|
+
jest.spyOn(window.screen, 'width', 'get').mockImplementation(function () {
|
87
|
+
return 1024;
|
88
|
+
});
|
89
|
+
jest.spyOn(window, 'requestAnimationFrame').mockImplementation(function (cb) {
|
90
|
+
return cb();
|
91
|
+
});
|
92
|
+
jest.useFakeTimers();
|
93
|
+
});
|
94
|
+
afterEach(function () {
|
95
|
+
jest.clearAllMocks();
|
96
|
+
onSelectionChange.mockClear();
|
97
|
+
});
|
98
|
+
afterAll(function () {
|
99
|
+
jest.restoreAllMocks();
|
100
|
+
});
|
101
|
+
test('should render environment breadcrumb component by default', function () {
|
102
|
+
getComponent();
|
103
|
+
var imageUploadButton = screen.getByTestId(testEnvBreadcrumb);
|
104
|
+
expect(imageUploadButton).toBeInstanceOf(HTMLDivElement);
|
105
|
+
expect(imageUploadButton).toBeInTheDocument();
|
106
|
+
});
|
107
|
+
test('should display name', function () {
|
108
|
+
getComponent();
|
109
|
+
expect(screen.getByText(testName)).toBeInTheDocument();
|
110
|
+
});
|
111
|
+
test('should display selectedItem', function () {
|
112
|
+
getComponent();
|
113
|
+
expect(screen.getByText(testSelectedItem)).toBeInTheDocument();
|
114
|
+
});
|
115
|
+
test('should call onNamePress when name pressed', function () {
|
116
|
+
var onNamePressMock = jest.fn();
|
117
|
+
getComponent({
|
118
|
+
onNamePress: onNamePressMock
|
119
|
+
});
|
120
|
+
expect(onNamePressMock).not.toHaveBeenCalled();
|
121
|
+
userEvent.click(screen.getByText(testName));
|
122
|
+
expect(onNamePressMock).toHaveBeenCalledTimes(1);
|
123
|
+
});
|
124
|
+
test('should not call onNamePress when current env button pressed', function () {
|
125
|
+
var onNamePressMock = jest.fn();
|
126
|
+
getComponent({
|
127
|
+
onNamePress: onNamePressMock
|
128
|
+
});
|
129
|
+
expect(onNamePressMock).not.toHaveBeenCalled();
|
130
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
131
|
+
expect(onNamePressMock).not.toHaveBeenCalled();
|
132
|
+
});
|
133
|
+
test('should render items passed in props', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
134
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
135
|
+
while (1) {
|
136
|
+
switch (_context.prev = _context.next) {
|
137
|
+
case 0:
|
138
|
+
getComponent();
|
139
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
140
|
+
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
141
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
142
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
143
|
+
expect(screen.queryAllByRole('option')).toHaveLength(3);
|
144
|
+
|
145
|
+
case 6:
|
146
|
+
case "end":
|
147
|
+
return _context.stop();
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}, _callee);
|
151
|
+
})));
|
152
|
+
test('should render items with sections passed in props', function () {
|
153
|
+
getSectionsComponent();
|
154
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
155
|
+
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
156
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
157
|
+
expect(screen.getByRole('group')).toBeInTheDocument();
|
158
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
159
|
+
expect(screen.queryAllByRole('option')).toHaveLength(3);
|
160
|
+
});
|
161
|
+
test('should call onSelectionChange when env clicked', function () {
|
162
|
+
var onSelectionChangeMock = jest.fn();
|
163
|
+
getComponent({
|
164
|
+
onSelectionChange: onSelectionChangeMock
|
165
|
+
});
|
166
|
+
expect(onSelectionChangeMock).not.toHaveBeenCalled();
|
167
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
168
|
+
userEvent.click(screen.getByText(items[0].name));
|
169
|
+
expect(onSelectionChangeMock).toHaveBeenNthCalledWith(1, items[0].name);
|
170
|
+
});
|
171
|
+
test('should disable item if his hey passed in the disabledKeys prop', function () {
|
172
|
+
getComponent({
|
173
|
+
disabledKeys: ['a']
|
174
|
+
});
|
175
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
176
|
+
expect(screen.getByText(items[0].name)).toHaveClass('is-disabled');
|
177
|
+
});
|
178
|
+
test('should call onPopoverOpen if it is passed in the props', function () {
|
179
|
+
var onPopoverOpenMock = jest.fn();
|
180
|
+
getComponent({
|
181
|
+
onPopoverOpen: onPopoverOpenMock
|
182
|
+
});
|
183
|
+
expect(onPopoverOpenMock).not.toHaveBeenCalled();
|
184
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
185
|
+
expect(onPopoverOpenMock).toHaveBeenCalled();
|
186
|
+
});
|
187
|
+
test('should call onPopoverClose if it is passed in the props', function () {
|
188
|
+
var onPopoverCloseMock = jest.fn();
|
189
|
+
getComponent({
|
190
|
+
onPopoverClose: onPopoverCloseMock
|
191
|
+
});
|
192
|
+
expect(onPopoverCloseMock).not.toHaveBeenCalled();
|
193
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
194
|
+
userEvent.click(screen.getByText(testName));
|
195
|
+
expect(onPopoverCloseMock).toHaveBeenCalled();
|
196
|
+
});
|
197
|
+
test('should close popover when other component clicked', function () {
|
198
|
+
getComponent();
|
199
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
200
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
201
|
+
expect(screen.queryAllByRole('option')).toHaveLength(3);
|
202
|
+
userEvent.click(screen.getByText(testName));
|
203
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
204
|
+
expect(screen.queryAllByRole('option')).not.toHaveLength(3);
|
205
|
+
});
|
206
|
+
test('should render current env node if passed in props', function () {
|
207
|
+
var testSelectedItemId = 'testSelectedItemId';
|
208
|
+
getComponent({
|
209
|
+
selectedItem: ___EmotionJSX("div", {
|
210
|
+
"data-testid": testSelectedItemId
|
211
|
+
})
|
212
|
+
});
|
213
|
+
expect(screen.getByTestId(testSelectedItemId)).toBeInTheDocument();
|
214
|
+
});
|
215
|
+
test('should show empty state in search if there are no results', function () {
|
216
|
+
var testEmptySearchText = 'testEmptySearchText';
|
217
|
+
getComponent({
|
218
|
+
emptySearchText: testEmptySearchText
|
219
|
+
});
|
220
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
221
|
+
userEvent.type(screen.getByRole('searchbox'), '111');
|
222
|
+
expect(screen.getByText(testEmptySearchText)).toBeInTheDocument();
|
223
|
+
});
|
224
|
+
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
225
|
+
var _getComponent, container, results;
|
226
|
+
|
227
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
228
|
+
while (1) {
|
229
|
+
switch (_context2.prev = _context2.next) {
|
230
|
+
case 0:
|
231
|
+
jest.useRealTimers();
|
232
|
+
_getComponent = getComponent(), container = _getComponent.container;
|
233
|
+
_context2.next = 4;
|
234
|
+
return axe(container);
|
235
|
+
|
236
|
+
case 4:
|
237
|
+
results = _context2.sent;
|
238
|
+
expect(results).toHaveNoViolations();
|
239
|
+
|
240
|
+
case 6:
|
241
|
+
case "end":
|
242
|
+
return _context2.stop();
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}, _callee2);
|
246
|
+
})));
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './EnvironmentBreadcrumb';
|
package/lib/index.js
CHANGED
@@ -31,6 +31,7 @@ export { default as CodeView } from './components/CodeView';
|
|
31
31
|
export { default as ComboBoxField } from './components/ComboBoxField';
|
32
32
|
export { default as CopyText } from './components/CopyText';
|
33
33
|
export { default as ColorField } from './components/ColorField';
|
34
|
+
export { default as EnvironmentBreadcrumb } from './components/EnvironmentBreadcrumb';
|
34
35
|
export { default as FieldHelperText } from './components/FieldHelperText';
|
35
36
|
export * from './components/FieldHelperText';
|
36
37
|
export { default as FileInputField } from './components/FileInputField';
|
@@ -252,6 +252,18 @@ var datePicker = {
|
|
252
252
|
}
|
253
253
|
}
|
254
254
|
};
|
255
|
+
|
256
|
+
var environmentChip = _objectSpread(_objectSpread({}, chip), {}, {
|
257
|
+
alignSelf: 'center',
|
258
|
+
height: '17px',
|
259
|
+
minWidth: 'fit-content',
|
260
|
+
ml: 8,
|
261
|
+
'& span': {
|
262
|
+
fontSize: 'xs',
|
263
|
+
lineHeight: 1
|
264
|
+
}
|
265
|
+
});
|
266
|
+
|
255
267
|
var fileInputFieldWrapper = {
|
256
268
|
display: 'flex',
|
257
269
|
border: '1px dashed',
|
@@ -280,6 +292,7 @@ export default {
|
|
280
292
|
chip: chip,
|
281
293
|
copy: copy,
|
282
294
|
datePicker: datePicker,
|
295
|
+
environmentChip: environmentChip,
|
283
296
|
expandableRow: expandableRow,
|
284
297
|
inputInContainerSlot: inputInContainerSlot,
|
285
298
|
fileInputFieldWrapper: fileInputFieldWrapper,
|
@@ -463,6 +463,28 @@ var expandableRow = {
|
|
463
463
|
}
|
464
464
|
}
|
465
465
|
};
|
466
|
+
var environmentBreadcrumb = {
|
467
|
+
current: _objectSpread(_objectSpread({}, text), {}, {
|
468
|
+
color: 'neutral.30',
|
469
|
+
fontSize: 'md',
|
470
|
+
fontWeight: 1,
|
471
|
+
'&.is-hovered, &.is-focused': {
|
472
|
+
color: 'active',
|
473
|
+
textDecoration: 'none',
|
474
|
+
boxShadow: 'none'
|
475
|
+
},
|
476
|
+
'&.is-pressed': {
|
477
|
+
color: 'accent.20',
|
478
|
+
textDecoration: 'none'
|
479
|
+
}
|
480
|
+
}),
|
481
|
+
selectItem: _objectSpread(_objectSpread({}, text), {}, {
|
482
|
+
color: 'neutral.10',
|
483
|
+
fontSize: 'md',
|
484
|
+
fontWeight: 0,
|
485
|
+
justifyContent: 'start'
|
486
|
+
})
|
487
|
+
};
|
466
488
|
var fileInputField = {
|
467
489
|
background: 'none',
|
468
490
|
cursor: 'pointer',
|
@@ -529,6 +551,7 @@ export default {
|
|
529
551
|
'&.is-pressed': _objectSpread({}, defaultActive),
|
530
552
|
'&.is-focused': _objectSpread({}, defaultFocus)
|
531
553
|
}),
|
554
|
+
environmentBreadcrumb: environmentBreadcrumb,
|
532
555
|
expandableRow: expandableRow,
|
533
556
|
fileInputField: fileInputField,
|
534
557
|
iconButton: iconButton,
|
@@ -119,6 +119,14 @@ var expandableRow = {
|
|
119
119
|
}
|
120
120
|
}
|
121
121
|
};
|
122
|
+
|
123
|
+
var environmentBreadcrumb = _objectSpread(_objectSpread({}, base), {}, {
|
124
|
+
fontSize: 'sm',
|
125
|
+
fontWeight: 3,
|
126
|
+
color: 'secondary',
|
127
|
+
textTransform: 'capitalize'
|
128
|
+
});
|
129
|
+
|
122
130
|
var navBarSubtitle = {
|
123
131
|
fontWeight: 3,
|
124
132
|
fontSize: '11px',
|
@@ -155,6 +163,7 @@ export var text = {
|
|
155
163
|
textTransform: 'uppercase',
|
156
164
|
fontFamily: 'standard'
|
157
165
|
}),
|
166
|
+
environmentBreadcrumb: environmentBreadcrumb,
|
158
167
|
fieldHelperText: fieldHelperText,
|
159
168
|
inputValue: {
|
160
169
|
fontWeight: 1,
|