@dhis2/analytics 25.2.3 → 26.0.0
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/build/cjs/__demo__/FileMenu.stories.js +8 -6
- package/build/cjs/__demo__/Toolbar.stories.js +77 -0
- package/build/cjs/components/FileMenu/FileMenu.js +21 -59
- package/build/cjs/components/FileMenu/__tests__/FileMenu.spec.js +318 -194
- package/build/cjs/components/Options/VisualizationOptions.js +3 -1
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuBar.js +107 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuDropdown.js +66 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuList.js +94 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuListItem.js +99 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuListItem.styles.js +13 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuBar.spec.js +219 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuDropdown.spec.js +23 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuList.spec.js +56 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuListItem.spec.js +50 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/index.js +37 -0
- package/build/cjs/components/Toolbar/InterpretationsAndDetailsToggler.js +50 -0
- package/build/cjs/components/Toolbar/MenuButton.styles.js +13 -0
- package/build/cjs/components/Toolbar/Toolbar.js +39 -0
- package/build/cjs/components/Toolbar/ToolbarSidebar.js +45 -0
- package/build/cjs/components/Toolbar/UpdateButton.js +57 -0
- package/build/cjs/components/Toolbar/__tests__/InterpretationsAndDetailsToggler.spec.js +50 -0
- package/build/cjs/components/Toolbar/__tests__/Toolbar.spec.js +24 -0
- package/build/cjs/components/Toolbar/__tests__/ToolbarSidebar.spec.js +30 -0
- package/build/cjs/components/Toolbar/__tests__/UpdateButton.spec.js +44 -0
- package/build/cjs/components/Toolbar/index.js +57 -0
- package/build/cjs/index.js +304 -46
- package/build/cjs/locales/en/translations.json +1 -0
- package/build/es/__demo__/FileMenu.stories.js +7 -6
- package/build/es/__demo__/Toolbar.stories.js +69 -0
- package/build/es/components/FileMenu/FileMenu.js +20 -57
- package/build/es/components/FileMenu/__tests__/FileMenu.spec.js +293 -189
- package/build/es/components/Options/VisualizationOptions.js +3 -1
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuBar.js +90 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuDropdown.js +44 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuList.js +75 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuListItem.js +78 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuListItem.styles.js +4 -0
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuBar.spec.js +168 -0
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuDropdown.spec.js +16 -0
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuList.spec.js +49 -0
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuListItem.spec.js +41 -0
- package/build/es/components/Toolbar/HoverMenuBar/index.js +4 -0
- package/build/es/components/Toolbar/InterpretationsAndDetailsToggler.js +33 -0
- package/build/es/components/Toolbar/MenuButton.styles.js +4 -0
- package/build/es/components/Toolbar/Toolbar.js +24 -0
- package/build/es/components/Toolbar/ToolbarSidebar.js +29 -0
- package/build/es/components/Toolbar/UpdateButton.js +38 -0
- package/build/es/components/Toolbar/__tests__/InterpretationsAndDetailsToggler.spec.js +43 -0
- package/build/es/components/Toolbar/__tests__/Toolbar.spec.js +17 -0
- package/build/es/components/Toolbar/__tests__/ToolbarSidebar.spec.js +23 -0
- package/build/es/components/Toolbar/__tests__/UpdateButton.spec.js +37 -0
- package/build/es/components/Toolbar/index.js +5 -0
- package/build/es/index.js +1 -0
- package/build/es/locales/en/translations.json +1 -0
- package/package.json +3 -1
- package/CHANGELOG.md +0 -4072
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _appRuntime = require("@dhis2/app-runtime");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _react2 = _interopRequireDefault(require("react"));
|
|
10
10
|
|
|
11
|
-
var _index = require("../../
|
|
12
|
-
|
|
13
|
-
var _DeleteDialog = require("../DeleteDialog.js");
|
|
11
|
+
var _index = require("../../Toolbar/index.js");
|
|
14
12
|
|
|
15
13
|
var _FileMenu = require("../FileMenu.js");
|
|
16
14
|
|
|
17
|
-
var _GetLinkDialog = require("../GetLinkDialog.js");
|
|
18
|
-
|
|
19
|
-
var _RenameDialog = require("../RenameDialog.js");
|
|
20
|
-
|
|
21
|
-
var _SaveAsDialog = require("../SaveAsDialog.js");
|
|
22
|
-
|
|
23
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
16
|
|
|
17
|
+
jest.mock('../../TranslationDialog/TranslationModal/useTranslationsResults.js', () => ({
|
|
18
|
+
/* This will keep the translation dialog in
|
|
19
|
+
* a loading state, which prevents it from
|
|
20
|
+
* throwing other errors */
|
|
21
|
+
useTranslationsResults: () => ({
|
|
22
|
+
translationsData: undefined,
|
|
23
|
+
fetching: true
|
|
24
|
+
})
|
|
25
|
+
}));
|
|
25
26
|
describe('The FileMenu component ', () => {
|
|
26
|
-
let shallowFileMenu;
|
|
27
|
-
let props;
|
|
28
27
|
const onDelete = jest.fn();
|
|
29
28
|
const onError = jest.fn();
|
|
30
29
|
const onNew = jest.fn();
|
|
@@ -34,206 +33,331 @@ describe('The FileMenu component ', () => {
|
|
|
34
33
|
const onSaveAs = jest.fn();
|
|
35
34
|
const onShare = jest.fn();
|
|
36
35
|
const onTranslate = jest.fn();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
const baseProps = {
|
|
37
|
+
currentUser: {
|
|
38
|
+
id: 'u1',
|
|
39
|
+
displayName: 'Test user'
|
|
40
|
+
},
|
|
41
|
+
fileType: 'visualization',
|
|
42
|
+
fileObject: undefined,
|
|
43
|
+
onDelete,
|
|
44
|
+
onError,
|
|
45
|
+
onNew,
|
|
46
|
+
onOpen,
|
|
47
|
+
onRename,
|
|
48
|
+
onSave,
|
|
49
|
+
onSaveAs,
|
|
50
|
+
onShare,
|
|
51
|
+
onTranslate
|
|
44
52
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
shallowFileMenu = undefined;
|
|
48
|
-
props = {
|
|
49
|
-
currentUser: {
|
|
50
|
-
id: 'u1',
|
|
51
|
-
displayName: 'Test user'
|
|
52
|
-
},
|
|
53
|
-
fileType: 'visualization',
|
|
54
|
-
fileObject: undefined,
|
|
55
|
-
onDelete,
|
|
56
|
-
onError,
|
|
57
|
-
onNew,
|
|
58
|
-
onOpen,
|
|
59
|
-
onRename,
|
|
60
|
-
onSave,
|
|
61
|
-
onSaveAs,
|
|
62
|
-
onShare,
|
|
63
|
-
onTranslate
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
it('renders a button', () => {
|
|
67
|
-
expect(getFileMenuComponent(props).find('button')).toHaveLength(1);
|
|
68
|
-
});
|
|
69
|
-
it('renders some enabled buttons regardless of the access settings', () => {
|
|
70
|
-
const fileMenuComponent = getFileMenuComponent(props);
|
|
71
|
-
fileMenuComponent.find('button').simulate('click');
|
|
72
|
-
const buttonLabels = ['New', 'Open…'];
|
|
73
|
-
buttonLabels.forEach(buttonLabel => expect(fileMenuComponent.findWhere(n => n.prop('label') === buttonLabel).prop('disabled')).toBe(undefined));
|
|
74
|
-
});
|
|
75
|
-
it('renders some disabled buttons when no fileObject is present', () => {
|
|
76
|
-
const fileMenuComponent = getFileMenuComponent(props);
|
|
77
|
-
fileMenuComponent.find('button').simulate('click');
|
|
78
|
-
const buttonLabels = ['Save as…', 'Rename…', 'Translate…', 'Share…', 'Get link…', 'Delete'];
|
|
79
|
-
buttonLabels.forEach(buttonLabel => expect(fileMenuComponent.findWhere(n => n.prop('label') === buttonLabel).prop('disabled')).toBe(true));
|
|
80
|
-
});
|
|
81
|
-
it('renders some enabled buttons when update access is granted', () => {
|
|
82
|
-
props.fileObject = {
|
|
83
|
-
id: 'test',
|
|
84
|
-
access: {
|
|
85
|
-
delete: false,
|
|
86
|
-
manage: false,
|
|
87
|
-
update: true
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const fileMenuComponent = getFileMenuComponent(props);
|
|
91
|
-
fileMenuComponent.find('button').simulate('click');
|
|
92
|
-
const buttonLabels = ['Save', 'Rename…', 'Translate…'];
|
|
93
|
-
buttonLabels.forEach(buttonLabel => expect(fileMenuComponent.findWhere(n => n.prop('label') === buttonLabel).prop('disabled')).toBe(false));
|
|
94
|
-
});
|
|
95
|
-
it('renders enabled Delete button when delete access is granted', () => {
|
|
96
|
-
props.fileObject = {
|
|
97
|
-
id: 'test',
|
|
98
|
-
access: {
|
|
99
|
-
delete: true,
|
|
100
|
-
manage: false,
|
|
101
|
-
update: false
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
const fileMenuComponent = getFileMenuComponent(props);
|
|
105
|
-
fileMenuComponent.find('button').simulate('click');
|
|
106
|
-
expect(fileMenuComponent.findWhere(n => n.prop('label') === 'Delete').prop('disabled')).toBe(false);
|
|
107
|
-
});
|
|
108
|
-
it('renders enabled Share button when manage access is granted', () => {
|
|
109
|
-
props.fileObject = {
|
|
110
|
-
id: 'test',
|
|
111
|
-
access: {
|
|
112
|
-
delete: false,
|
|
113
|
-
manage: true,
|
|
114
|
-
update: false
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
const fileMenuComponent = getFileMenuComponent(props);
|
|
118
|
-
fileMenuComponent.find('button').simulate('click');
|
|
119
|
-
expect(fileMenuComponent.findWhere(n => n.prop('label') === 'Share…').prop('disabled')).toBe(false);
|
|
120
|
-
});
|
|
121
|
-
it('renders the OpenFileDialog component when the Open button is clicked', () => {
|
|
122
|
-
const fileMenuComponent = getFileMenuComponent(props);
|
|
123
|
-
fileMenuComponent.find('button').simulate('click');
|
|
124
|
-
fileMenuComponent.findWhere(n => n.prop('label') === 'Open…').simulate('click');
|
|
125
|
-
expect(fileMenuComponent.find(_OpenFileDialog.OpenFileDialog)).toHaveLength(1);
|
|
126
|
-
});
|
|
127
|
-
it('renders the RenameDialog when the Rename button is clicked', () => {
|
|
128
|
-
props.fileObject = {
|
|
53
|
+
const fullAccessProps = {
|
|
54
|
+
fileObject: {
|
|
129
55
|
id: 'test',
|
|
130
56
|
access: {
|
|
131
57
|
delete: true,
|
|
132
58
|
manage: true,
|
|
133
59
|
update: true
|
|
134
|
-
}
|
|
60
|
+
},
|
|
61
|
+
href: 'http://dhis2.org'
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const renderFileMenu = function () {
|
|
66
|
+
let customProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
67
|
+
const props = { ...baseProps,
|
|
68
|
+
...customProps
|
|
135
69
|
};
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
70
|
+
const providerData = {
|
|
71
|
+
translations: {
|
|
72
|
+
translations: {}
|
|
73
|
+
},
|
|
74
|
+
sharing: {
|
|
75
|
+
meta: {
|
|
76
|
+
allowPublicAccess: true
|
|
77
|
+
},
|
|
78
|
+
object: {
|
|
79
|
+
userAccesses: [],
|
|
80
|
+
userGroupAccesses: []
|
|
81
|
+
}
|
|
148
82
|
}
|
|
149
83
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
84
|
+
return (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_appRuntime.CustomDataProvider, {
|
|
85
|
+
data: providerData
|
|
86
|
+
}, /*#__PURE__*/_react2.default.createElement(_index.HoverMenuBar, null, /*#__PURE__*/_react2.default.createElement(_FileMenu.FileMenu, props))));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const openDropdown = async () => {
|
|
90
|
+
_react.fireEvent.click(_react.screen.getByTestId('dhis2-analytics-hovermenudropdown'));
|
|
91
|
+
|
|
92
|
+
expect(await _react.screen.findByTestId('file-menu-container')).toBeVisible();
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const MENU_ITEMS = {
|
|
96
|
+
NEW: {
|
|
97
|
+
testId: 'file-menu-new',
|
|
98
|
+
text: 'New'
|
|
99
|
+
},
|
|
100
|
+
OPEN: {
|
|
101
|
+
testId: 'file-menu-open',
|
|
102
|
+
text: 'Open…'
|
|
103
|
+
},
|
|
104
|
+
SAVE: {
|
|
105
|
+
testId: 'file-menu-save',
|
|
106
|
+
text: 'Save'
|
|
107
|
+
},
|
|
108
|
+
SAVE_AS: {
|
|
109
|
+
testId: 'file-menu-saveas',
|
|
110
|
+
text: 'Save as…'
|
|
111
|
+
},
|
|
112
|
+
RENAME: {
|
|
113
|
+
testId: 'file-menu-rename',
|
|
114
|
+
text: 'Rename…'
|
|
115
|
+
},
|
|
116
|
+
TRANSLATE: {
|
|
117
|
+
testId: 'file-menu-translate',
|
|
118
|
+
text: 'Translate…'
|
|
119
|
+
},
|
|
120
|
+
SHARE: {
|
|
121
|
+
testId: 'file-menu-sharing',
|
|
122
|
+
text: 'Share…'
|
|
123
|
+
},
|
|
124
|
+
GET_LINK: {
|
|
125
|
+
testId: 'file-menu-getlink',
|
|
126
|
+
text: 'Get link…'
|
|
127
|
+
},
|
|
128
|
+
DELETE: {
|
|
129
|
+
testId: 'file-menu-delete',
|
|
130
|
+
text: 'Delete'
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const assertMenuItemsDisabledState = menuItems => {
|
|
135
|
+
for (const menuTitem of menuItems) {
|
|
136
|
+
const li = _react.screen.getByTestId(menuTitem.testId);
|
|
137
|
+
|
|
138
|
+
expect((0, _react.getByText)(li, menuTitem.text)).toBeVisible();
|
|
139
|
+
|
|
140
|
+
if (menuTitem.disabled) {
|
|
141
|
+
expect(li).toHaveClass('disabled');
|
|
142
|
+
} else {
|
|
143
|
+
expect(li).not.toHaveClass('disabled');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
it('renders a button', () => {
|
|
149
|
+
renderFileMenu();
|
|
150
|
+
expect(_react.screen.getAllByTestId('dhis2-analytics-hovermenudropdown')).toHaveLength(1);
|
|
151
|
+
|
|
152
|
+
const button = _react.screen.getByTestId('dhis2-analytics-hovermenudropdown');
|
|
153
|
+
|
|
154
|
+
expect(button).toBeVisible();
|
|
155
|
+
expect(button).toHaveTextContent('File');
|
|
154
156
|
});
|
|
155
|
-
it('
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
it('opens when clicking the button', async () => {
|
|
158
|
+
renderFileMenu();
|
|
159
|
+
expect(_react.screen.queryByTestId('file-menu-container')).not.toBeInTheDocument();
|
|
160
|
+
await openDropdown();
|
|
161
|
+
expect(await _react.screen.findByTestId('file-menu-container')).toBeVisible();
|
|
162
|
+
});
|
|
163
|
+
it('renders some enabled buttons regardless of the access settings', async () => {
|
|
164
|
+
renderFileMenu();
|
|
165
|
+
await openDropdown();
|
|
166
|
+
assertMenuItemsDisabledState([{ ...MENU_ITEMS.NEW,
|
|
167
|
+
disabled: false
|
|
168
|
+
}, { ...MENU_ITEMS.OPEN,
|
|
169
|
+
disabled: false
|
|
170
|
+
}]);
|
|
171
|
+
});
|
|
172
|
+
it('renders some disabled buttons when no fileObject is present', async () => {
|
|
173
|
+
renderFileMenu();
|
|
174
|
+
await openDropdown();
|
|
175
|
+
assertMenuItemsDisabledState([{ ...MENU_ITEMS.SAVE_AS,
|
|
176
|
+
disabled: true
|
|
177
|
+
}, { ...MENU_ITEMS.RENAME,
|
|
178
|
+
disabled: true
|
|
179
|
+
}, { ...MENU_ITEMS.TRANSLATE,
|
|
180
|
+
disabled: true
|
|
181
|
+
}, { ...MENU_ITEMS.SHARE,
|
|
182
|
+
disabled: true
|
|
183
|
+
}, { ...MENU_ITEMS.GET_LINK,
|
|
184
|
+
disabled: true
|
|
185
|
+
}, { ...MENU_ITEMS.DELETE,
|
|
186
|
+
disabled: true
|
|
187
|
+
}]);
|
|
188
|
+
});
|
|
189
|
+
it('renders some enabled buttons when update access is granted', async () => {
|
|
190
|
+
const customProps = {
|
|
191
|
+
fileObject: {
|
|
192
|
+
id: 'test',
|
|
193
|
+
access: {
|
|
194
|
+
delete: false,
|
|
195
|
+
manage: false,
|
|
196
|
+
update: true
|
|
197
|
+
}
|
|
162
198
|
}
|
|
163
199
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
200
|
+
renderFileMenu(customProps);
|
|
201
|
+
await openDropdown();
|
|
202
|
+
assertMenuItemsDisabledState([{ ...MENU_ITEMS.SAVE,
|
|
203
|
+
disabled: false
|
|
204
|
+
}, { ...MENU_ITEMS.RENAME,
|
|
205
|
+
disabled: false
|
|
206
|
+
}, { ...MENU_ITEMS.TRANSLATE,
|
|
207
|
+
disabled: false
|
|
208
|
+
}]);
|
|
168
209
|
});
|
|
169
|
-
it('renders
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
210
|
+
it('renders enabled Delete button when delete access is granted', async () => {
|
|
211
|
+
const customProps = {
|
|
212
|
+
fileObject: {
|
|
213
|
+
id: 'test',
|
|
214
|
+
access: {
|
|
215
|
+
delete: true,
|
|
216
|
+
manage: false,
|
|
217
|
+
update: false
|
|
218
|
+
}
|
|
176
219
|
}
|
|
177
220
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
221
|
+
renderFileMenu(customProps);
|
|
222
|
+
await openDropdown();
|
|
223
|
+
assertMenuItemsDisabledState([{ ...MENU_ITEMS.DELETE,
|
|
224
|
+
disabled: false
|
|
225
|
+
}]);
|
|
226
|
+
});
|
|
227
|
+
it('renders enabled Share button when manage access is granted', async () => {
|
|
228
|
+
const customProps = {
|
|
229
|
+
fileObject: {
|
|
230
|
+
id: 'test',
|
|
231
|
+
access: {
|
|
232
|
+
delete: false,
|
|
233
|
+
manage: true,
|
|
234
|
+
update: false
|
|
235
|
+
}
|
|
190
236
|
}
|
|
191
237
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
238
|
+
renderFileMenu(customProps);
|
|
239
|
+
await openDropdown();
|
|
240
|
+
assertMenuItemsDisabledState([{ ...MENU_ITEMS.SHARE,
|
|
241
|
+
disabled: false
|
|
242
|
+
}]);
|
|
196
243
|
});
|
|
197
|
-
it('renders the
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
244
|
+
it('renders the OpenFileDialog component when the Open button is clicked', async () => {
|
|
245
|
+
renderFileMenu();
|
|
246
|
+
await openDropdown();
|
|
247
|
+
|
|
248
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.OPEN.testId));
|
|
249
|
+
|
|
250
|
+
expect(await _react.screen.findByText('Open a visualization', {
|
|
251
|
+
selector: 'h1'
|
|
252
|
+
})).toBeVisible();
|
|
253
|
+
});
|
|
254
|
+
it('renders the RenameDialog when the Rename button is clicked', async () => {
|
|
255
|
+
renderFileMenu(fullAccessProps);
|
|
256
|
+
await openDropdown();
|
|
257
|
+
|
|
258
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.RENAME.testId));
|
|
259
|
+
|
|
260
|
+
expect(await _react.screen.findByText('Rename visualization', {
|
|
261
|
+
selector: 'h1'
|
|
262
|
+
})).toBeVisible();
|
|
263
|
+
});
|
|
264
|
+
it('renders the TranslationDialog when the Translate button is clicked', async () => {
|
|
265
|
+
renderFileMenu(fullAccessProps);
|
|
266
|
+
await openDropdown();
|
|
267
|
+
|
|
268
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.TRANSLATE.testId));
|
|
269
|
+
|
|
270
|
+
expect(await _react.screen.findByText('Translate', {
|
|
271
|
+
exact: false,
|
|
272
|
+
selector: 'h1'
|
|
273
|
+
})).toBeVisible();
|
|
274
|
+
});
|
|
275
|
+
it('renders the SharingDialog when the Share button is clicked', async () => {
|
|
276
|
+
renderFileMenu(fullAccessProps);
|
|
277
|
+
await openDropdown();
|
|
278
|
+
|
|
279
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.SHARE.testId));
|
|
280
|
+
|
|
281
|
+
expect(await _react.screen.findByText('Sharing and access', {
|
|
282
|
+
selector: 'h1'
|
|
283
|
+
})).toBeVisible();
|
|
284
|
+
});
|
|
285
|
+
it('renders the GetLinkDialog when the Get link button is clicked', async () => {
|
|
286
|
+
const url = 'http://localhost/dhis-web-data-visualizer/#/test';
|
|
287
|
+
renderFileMenu(fullAccessProps);
|
|
288
|
+
await openDropdown();
|
|
289
|
+
|
|
290
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.GET_LINK.testId));
|
|
291
|
+
|
|
292
|
+
expect(await _react.screen.findByTestId('dhis2-uicore-modal')).toBeVisible();
|
|
293
|
+
expect(_react.screen.getByRole('link', {
|
|
294
|
+
name: url
|
|
295
|
+
})).toHaveAttribute('href', url);
|
|
296
|
+
});
|
|
297
|
+
it('renders the DeleteDialog when the Delete button is clicked', async () => {
|
|
298
|
+
const customProps = {
|
|
299
|
+
fileObject: {
|
|
300
|
+
id: 'delete-test',
|
|
301
|
+
access: {
|
|
302
|
+
delete: true,
|
|
303
|
+
manage: true,
|
|
304
|
+
update: true
|
|
305
|
+
}
|
|
204
306
|
}
|
|
205
307
|
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
308
|
+
renderFileMenu(customProps);
|
|
309
|
+
await openDropdown();
|
|
310
|
+
|
|
311
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.DELETE.testId));
|
|
312
|
+
|
|
313
|
+
expect(await _react.screen.findByText('Delete visualization', {
|
|
314
|
+
selector: 'h1'
|
|
315
|
+
})).toBeVisible();
|
|
316
|
+
});
|
|
317
|
+
it('renders the SaveAsDialog when the Save as… button is clicked', async () => {
|
|
318
|
+
renderFileMenu(fullAccessProps);
|
|
319
|
+
await openDropdown();
|
|
320
|
+
|
|
321
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.SAVE_AS.testId));
|
|
322
|
+
|
|
323
|
+
expect(await _react.screen.findByText('Save visualization as', {
|
|
324
|
+
selector: 'h1'
|
|
325
|
+
})).toBeVisible();
|
|
326
|
+
});
|
|
327
|
+
it('renders the SaveAsDialog when the Save… button is clicked but no fileObject is present', async () => {
|
|
328
|
+
const customProps = {
|
|
329
|
+
fileObject: {
|
|
330
|
+
// NOTE: no `id` field
|
|
331
|
+
access: {
|
|
332
|
+
update: true
|
|
333
|
+
}
|
|
224
334
|
}
|
|
225
335
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
336
|
+
renderFileMenu(customProps);
|
|
337
|
+
await openDropdown();
|
|
338
|
+
|
|
339
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.SAVE.testId));
|
|
340
|
+
|
|
341
|
+
expect(await _react.screen.findByText('Save visualization as', {
|
|
342
|
+
selector: 'h1'
|
|
343
|
+
})).toBeVisible();
|
|
344
|
+
});
|
|
345
|
+
it('calls the onSave callback when the Save button is clicked and a fileObject is present', async () => {
|
|
346
|
+
renderFileMenu(fullAccessProps);
|
|
347
|
+
await openDropdown();
|
|
348
|
+
|
|
349
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.SAVE.testId));
|
|
350
|
+
|
|
351
|
+
expect(_react.screen.queryByText('Open a visualization')).not.toBeVisible();
|
|
352
|
+
expect(onSave).toHaveBeenCalledTimes(1);
|
|
353
|
+
});
|
|
354
|
+
it('calls the onNew callback when the New button is clicked', async () => {
|
|
355
|
+
renderFileMenu();
|
|
356
|
+
await openDropdown();
|
|
357
|
+
|
|
358
|
+
_react.fireEvent.click(_react.screen.getByTestId(MENU_ITEMS.NEW.testId));
|
|
359
|
+
|
|
360
|
+
expect(_react.screen.queryByText('Open a visualization')).not.toBeVisible();
|
|
361
|
+
expect(onNew).toHaveBeenCalledTimes(1);
|
|
238
362
|
});
|
|
239
363
|
});
|
|
@@ -23,11 +23,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
23
|
|
|
24
24
|
const VisualizationOptions = _ref => {
|
|
25
25
|
let {
|
|
26
|
+
initiallyActiveTabKey,
|
|
26
27
|
optionsConfig,
|
|
27
28
|
onClose,
|
|
28
29
|
onUpdate
|
|
29
30
|
} = _ref;
|
|
30
|
-
const [activeTabKey, setActiveTabKey] = (0, _react.useState)();
|
|
31
|
+
const [activeTabKey, setActiveTabKey] = (0, _react.useState)(initiallyActiveTabKey);
|
|
31
32
|
|
|
32
33
|
const generateTabContent = sections => sections.map(_ref2 => {
|
|
33
34
|
let {
|
|
@@ -109,6 +110,7 @@ const VisualizationOptions = _ref => {
|
|
|
109
110
|
|
|
110
111
|
VisualizationOptions.propTypes = {
|
|
111
112
|
optionsConfig: _propTypes.default.array.isRequired,
|
|
113
|
+
initiallyActiveTabKey: _propTypes.default.string,
|
|
112
114
|
onClose: _propTypes.default.func,
|
|
113
115
|
onUpdate: _propTypes.default.func
|
|
114
116
|
};
|