@dhis2/analytics 28.0.2 → 28.0.3

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.
@@ -19,8 +19,8 @@ const Wrapper = story => /*#__PURE__*/_react.default.createElement(_appServiceCo
19
19
  }
20
20
  }
21
21
  }, /*#__PURE__*/_react.default.createElement(_appRuntime.DataProvider, {
22
- baseUrl: "https://test.e2e.dhis2.org/analytics-41dev",
23
- apiVersion: "41"
22
+ baseUrl: "https://test.e2e.dhis2.org/anly-42",
23
+ apiVersion: "42"
24
24
  }, story()));
25
25
  var _default = exports.default = {
26
26
  title: 'DataDimension',
@@ -10,8 +10,8 @@ var _OpenFileDialog = require("../components/OpenFileDialog/OpenFileDialog.js");
10
10
  var _visTypes = require("../modules/visTypes.js");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  const Wrapper = story => /*#__PURE__*/_react.default.createElement(_appRuntime.DataProvider, {
13
- baseUrl: "https://test.e2e.dhis2.org/analytics-41dev/",
14
- apiVersion: "41"
13
+ baseUrl: "https://test.e2e.dhis2.org/anly-42/",
14
+ apiVersion: "42"
15
15
  }, story());
16
16
  const user = {
17
17
  displayName: 'John Traore',
@@ -11,8 +11,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
11
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
13
  const Wrapper = story => /*#__PURE__*/_react.default.createElement(_appRuntime.DataProvider, {
14
- baseUrl: "https://test.e2e.dhis2.org/analytics-41dev/",
15
- apiVersion: "41"
14
+ baseUrl: "https://test.e2e.dhis2.org/anly-42/",
15
+ apiVersion: "42"
16
16
  }, story());
17
17
  const defaultRootOrgUnits = ['ImspTQPwCqd']; // Sierra Leone
18
18
  var _default = exports.default = {
@@ -15,8 +15,8 @@ const Wrapper = story => /*#__PURE__*/_react.default.createElement(_appServiceCo
15
15
  systemInfo: {}
16
16
  }
17
17
  }, /*#__PURE__*/_react.default.createElement(_appRuntime.DataProvider, {
18
- baseUrl: "https://test.e2e.dhis2.org/analytics-41dev/",
19
- apiVersion: "41"
18
+ baseUrl: "https://test.e2e.dhis2.org/anly-42/",
19
+ apiVersion: "42"
20
20
  }, story()));
21
21
  const selectedPeriods = [{
22
22
  id: 'LAST_12_MONTHS',
@@ -23,7 +23,7 @@ const TranslationModal = _ref => {
23
23
  } = _ref;
24
24
  const [translations, setTranslations] = (0, _react.useState)([]);
25
25
  const endpointPath = new URL(objectToTranslate.href).pathname;
26
- const endpointPathMatch = endpointPath.match(/api\/\d+\/(?<resource>.+)/);
26
+ const endpointPathMatch = endpointPath.match(/api\/(?:\d+\/)?(?<resource>.+)/);
27
27
  const resource = endpointPathMatch !== null && endpointPathMatch !== void 0 && endpointPathMatch.groups ? endpointPathMatch.groups.resource : null;
28
28
  const {
29
29
  translationsData,
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _ui = require("@dhis2/ui");
4
+ var _enzyme = require("enzyme");
5
+ var _react = _interopRequireDefault(require("react"));
6
+ var _TranslationModal = require("../TranslationModal.js");
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ const mockUseTranslationResults = jest.fn(() => ({
9
+ translationsData: undefined,
10
+ fetching: false
11
+ }));
12
+ jest.mock('../useTranslationsResults.js', () => ({
13
+ useTranslationsResults: args => mockUseTranslationResults(args)
14
+ }));
15
+ describe('The Translation Dialog component', () => {
16
+ let shallowTranslationModal;
17
+ let props;
18
+ const onClose = jest.fn();
19
+ const onTranslationSaved = jest.fn();
20
+ const getTranslationModalComponent = props => {
21
+ if (!shallowTranslationModal) {
22
+ shallowTranslationModal = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_TranslationModal.TranslationModal, props));
23
+ }
24
+ return shallowTranslationModal;
25
+ };
26
+ beforeEach(() => {
27
+ shallowTranslationModal = undefined;
28
+ props = {
29
+ fieldsToTranslate: ['name', 'description'],
30
+ objectToTranslate: {
31
+ name: 'Test object',
32
+ href: 'https://dhis2.tld/path/api/visualization/object-id'
33
+ },
34
+ onClose,
35
+ onTranslationSaved
36
+ };
37
+ });
38
+ it('renders a Modal component', () => {
39
+ expect(getTranslationModalComponent(props).find(_ui.Modal)).toHaveLength(1);
40
+ });
41
+ it("renders a ModalTitle containing the object's name", () => {
42
+ expect(getTranslationModalComponent(props).find(_ui.ModalTitle).childAt(0).text()).toEqual(`Translate: ${props.objectToTranslate.name}`);
43
+ });
44
+ test.each(['https://dhis2.tld/path/api/visualization/object-id', 'https://dhis2.tld/path/api/42/visualization/object-id'])('uses the correct resource for the translation endpoint', href => {
45
+ props.objectToTranslate.href = href;
46
+ getTranslationModalComponent(props);
47
+ expect(mockUseTranslationResults).toHaveBeenCalled();
48
+ expect(mockUseTranslationResults).toHaveBeenCalledWith({
49
+ resource: 'visualization/object-id'
50
+ });
51
+ });
52
+ });
@@ -10,8 +10,8 @@ const Wrapper = story => /*#__PURE__*/React.createElement(ConfigProvider, {
10
10
  }
11
11
  }
12
12
  }, /*#__PURE__*/React.createElement(DataProvider, {
13
- baseUrl: "https://test.e2e.dhis2.org/analytics-41dev",
14
- apiVersion: "41"
13
+ baseUrl: "https://test.e2e.dhis2.org/anly-42",
14
+ apiVersion: "42"
15
15
  }, story()));
16
16
  export default {
17
17
  title: 'DataDimension',
@@ -3,8 +3,8 @@ import React from 'react';
3
3
  import { OpenFileDialog } from '../components/OpenFileDialog/OpenFileDialog.js';
4
4
  import { VIS_TYPE_GROUP_ALL, VIS_TYPE_GROUP_CHARTS, VIS_TYPE_PIVOT_TABLE, VIS_TYPE_COLUMN, VIS_TYPE_BAR, VIS_TYPE_LINE_LIST } from '../modules/visTypes.js';
5
5
  const Wrapper = story => /*#__PURE__*/React.createElement(DataProvider, {
6
- baseUrl: "https://test.e2e.dhis2.org/analytics-41dev/",
7
- apiVersion: "41"
6
+ baseUrl: "https://test.e2e.dhis2.org/anly-42/",
7
+ apiVersion: "42"
8
8
  }, story());
9
9
  const user = {
10
10
  displayName: 'John Traore',
@@ -2,8 +2,8 @@ import { DataProvider } from '@dhis2/app-runtime';
2
2
  import React, { useState } from 'react';
3
3
  import OrgUnitDimension from '../components/OrgUnitDimension/OrgUnitDimension.js';
4
4
  const Wrapper = story => /*#__PURE__*/React.createElement(DataProvider, {
5
- baseUrl: "https://test.e2e.dhis2.org/analytics-41dev/",
6
- apiVersion: "41"
5
+ baseUrl: "https://test.e2e.dhis2.org/anly-42/",
6
+ apiVersion: "42"
7
7
  }, story());
8
8
  const defaultRootOrgUnits = ['ImspTQPwCqd']; // Sierra Leone
9
9
 
@@ -8,8 +8,8 @@ const Wrapper = story => /*#__PURE__*/React.createElement(ConfigProvider, {
8
8
  systemInfo: {}
9
9
  }
10
10
  }, /*#__PURE__*/React.createElement(DataProvider, {
11
- baseUrl: "https://test.e2e.dhis2.org/analytics-41dev/",
12
- apiVersion: "41"
11
+ baseUrl: "https://test.e2e.dhis2.org/anly-42/",
12
+ apiVersion: "42"
13
13
  }, story()));
14
14
  const selectedPeriods = [{
15
15
  id: 'LAST_12_MONTHS',
@@ -14,7 +14,7 @@ export const TranslationModal = _ref => {
14
14
  } = _ref;
15
15
  const [translations, setTranslations] = useState([]);
16
16
  const endpointPath = new URL(objectToTranslate.href).pathname;
17
- const endpointPathMatch = endpointPath.match(/api\/\d+\/(?<resource>.+)/);
17
+ const endpointPathMatch = endpointPath.match(/api\/(?:\d+\/)?(?<resource>.+)/);
18
18
  const resource = endpointPathMatch !== null && endpointPathMatch !== void 0 && endpointPathMatch.groups ? endpointPathMatch.groups.resource : null;
19
19
  const {
20
20
  translationsData,
@@ -0,0 +1,49 @@
1
+ import { ModalTitle, Modal } from '@dhis2/ui';
2
+ import { shallow } from 'enzyme';
3
+ import React from 'react';
4
+ import { TranslationModal } from '../TranslationModal.js';
5
+ const mockUseTranslationResults = jest.fn(() => ({
6
+ translationsData: undefined,
7
+ fetching: false
8
+ }));
9
+ jest.mock('../useTranslationsResults.js', () => ({
10
+ useTranslationsResults: args => mockUseTranslationResults(args)
11
+ }));
12
+ describe('The Translation Dialog component', () => {
13
+ let shallowTranslationModal;
14
+ let props;
15
+ const onClose = jest.fn();
16
+ const onTranslationSaved = jest.fn();
17
+ const getTranslationModalComponent = props => {
18
+ if (!shallowTranslationModal) {
19
+ shallowTranslationModal = shallow(/*#__PURE__*/React.createElement(TranslationModal, props));
20
+ }
21
+ return shallowTranslationModal;
22
+ };
23
+ beforeEach(() => {
24
+ shallowTranslationModal = undefined;
25
+ props = {
26
+ fieldsToTranslate: ['name', 'description'],
27
+ objectToTranslate: {
28
+ name: 'Test object',
29
+ href: 'https://dhis2.tld/path/api/visualization/object-id'
30
+ },
31
+ onClose,
32
+ onTranslationSaved
33
+ };
34
+ });
35
+ it('renders a Modal component', () => {
36
+ expect(getTranslationModalComponent(props).find(Modal)).toHaveLength(1);
37
+ });
38
+ it("renders a ModalTitle containing the object's name", () => {
39
+ expect(getTranslationModalComponent(props).find(ModalTitle).childAt(0).text()).toEqual(`Translate: ${props.objectToTranslate.name}`);
40
+ });
41
+ test.each(['https://dhis2.tld/path/api/visualization/object-id', 'https://dhis2.tld/path/api/42/visualization/object-id'])('uses the correct resource for the translation endpoint', href => {
42
+ props.objectToTranslate.href = href;
43
+ getTranslationModalComponent(props);
44
+ expect(mockUseTranslationResults).toHaveBeenCalled();
45
+ expect(mockUseTranslationResults).toHaveBeenCalledWith({
46
+ resource: 'visualization/object-id'
47
+ });
48
+ });
49
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2/analytics",
3
- "version": "28.0.2",
3
+ "version": "28.0.3",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/es/index.js",
6
6
  "exports": {