Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: UI5 bump packages #3439

Merged
merged 7 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,833 changes: 484 additions & 1,349 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@
"@types/jsonpath": "^0.2.0",
"@types/pluralize": "^0.0.29",
"@ui-schema/ui-schema": "^0.4.5",
"@ui5/webcomponents": "^1.24.0",
"@ui5/webcomponents-base": "^1.24.0",
"@ui5/webcomponents-fiori": "^1.24.0",
"@ui5/webcomponents-icons": "^1.24.0",
"@ui5/webcomponents-icons-tnt": "^1.24.0",
"@ui5/webcomponents-react": "~1.28.1",
"@ui5/webcomponents-react-base": "^1.28.1",
"@ui5/webcomponents-react-charts": "^1.28.1",
"@ui5/webcomponents": "^2.3.0",
"@ui5/webcomponents-base": "^2.3.0",
"@ui5/webcomponents-compat": "^2.3.0",
"@ui5/webcomponents-fiori": "^2.3.0",
"@ui5/webcomponents-icons": "^2.3.0",
"@ui5/webcomponents-icons-tnt": "^2.3.0",
"@ui5/webcomponents-react": "^2.2.0",
"@ui5/webcomponents-react-base": "^2.2.0",
"@ui5/webcomponents-react-charts": "^2.2.0",
"@ui5/webcomponents-react-compat": "^2.3.0",
"classnames": "^2.2.6",
"copy-to-clipboard": "^3.2.0",
"core-js": "^3.3.6",
Expand All @@ -94,8 +96,8 @@
"pako": "^2.0.4",
"pluralize": "^8.0.0",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-i18next": "^11.18.6",
"react-router-dom": "^6.3.0",
"react-tippy": "^1.4.0",
Expand All @@ -107,7 +109,7 @@
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^12.1.3",
"@testing-library/react": "^16.0.1",
"@types/didyoumean": "^1.2.0",
"@types/enzyme": "^3.10.12",
"@types/file-saver": "^2.0.5",
Expand All @@ -119,7 +121,6 @@
"@types/react-dom": "^18.0.6",
"@types/uuid": "^9.0.0",
"@vitejs/plugin-react": "^4.3.1",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
"babel-polyfill": "^6.26.0",
"babel-preset-vite": "^1.1.3",
"concurrently": "^7.6.0",
Expand Down
1 change: 0 additions & 1 deletion src/components/Extensibility/components/CodeViewer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import jsyaml from 'js-yaml';
import { isNil } from 'lodash';
import { useTranslation } from 'react-i18next';

import { ReadonlyEditorPanel } from 'shared/components/ReadonlyEditorPanel';

Check failure on line 5 in src/components/Extensibility/components/CodeViewer.js

View workflow job for this annotation

GitHub Actions / run-unit-test

src/components/Extensibility/components/tests/CodeViewer.test.js

Error: [vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock ❯ src/components/Extensibility/components/CodeViewer.js:5:31 ❯ src/components/Extensibility/components/tests/CodeViewer.test.js:24:25 Caused by: Caused by: TypeError: Cannot read properties of undefined (reading 'find') ❯ hasStyle node_modules/@ui5/webcomponents-base/src/ManagedStyles.ts:58:39 ❯ createBlockingStyle node_modules/@ui5/webcomponents/src/Popup.ts:33:7 ❯ node_modules/@ui5/webcomponents/src/Popup.ts:38:1 ❯ src/shared/contexts/YamlEditorContext/EditorActions.js:3:31
import { isValidYaml } from 'shared/contexts/YamlEditorContext/isValidYaml';
import { useNotification } from 'shared/contexts/NotificationContext';

Expand Down
8 changes: 5 additions & 3 deletions src/components/Extensibility/components/Columns.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import { Widget } from './Widget';
import { isNil } from 'lodash';

Expand All @@ -12,7 +10,11 @@ export function Columns({ structure, inlineContext, ...props }) {
const classNames = inline ? 'inline-display' : 'panel-grid';

return (
<div className={classNames} style={spacing.sapUiSmallMargin}>
<div
className={classNames}
style={spacing.sapUiSmallMargin}
data-testid="extensibility-columns"
>
{(structure.children || []).map(child => (
<Widget
structure={child}
Expand Down
114 changes: 88 additions & 26 deletions src/components/Extensibility/components/tests/Badge.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { mount, shallow } from 'enzyme';
import { act, render } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react';
import { Badge } from '../Badge';
import { StatusBadge } from 'shared/components/StatusBadge/StatusBadge';
import { PopoverBadge } from 'shared/components/PopoverBadge/PopoverBadge';
Expand All @@ -11,16 +10,48 @@ vi.mock('../../hooks/useJsonata', () => ({
},
}));

vi.mock('shared/components/StatusBadge/StatusBadge', async () => {
const StatusBadgeMock = (
await vi.importActual('shared/components/StatusBadge/StatusBadge')
).StatusBadge;
return {
StatusBadge: vi.fn(props => <StatusBadgeMock {...props} />),
};
});

vi.mock('shared/components/PopoverBadge/PopoverBadge', async () => {
const PopoverBadgeMock = (
await vi.importActual('shared/components/PopoverBadge/PopoverBadge')
).PopoverBadge;
return {
PopoverBadge: vi.fn(props => <PopoverBadgeMock {...props} />),
};
});

describe('Badge', () => {
afterEach(() => {
vi.clearAllMocks();
});

it('Renders a badge with a default type', () => {
const value = 'Unknown';
const structure = {};

const wrapper = shallow(<Badge value={value} structure={structure} />);
const status = wrapper.find(StatusBadge);
const badgeProps = status.props();
expect(badgeProps.type).toEqual(null);
expect(badgeProps.autoResolveType).toEqual(true);
render(
<ThemeProvider>
<Badge value={value} structure={structure} />
</ThemeProvider>,
);

expect(StatusBadge).toHaveBeenCalledWith(
expect.objectContaining({
type: null,
autoResolveType: true,
}),
{},
);

const status = screen.getAllByRole('status');
expect(status).toHaveLength(1);
});

Expand All @@ -32,11 +63,21 @@ describe('Badge', () => {
},
};

const wrapper = shallow(<Badge value={value} structure={structure} />);
const status = wrapper.find(StatusBadge);
const badgeProps = status.props();
expect(badgeProps.type).toEqual('Success');
expect(badgeProps.autoResolveType).toEqual(false);
render(
<ThemeProvider>
<Badge value={value} structure={structure} />
</ThemeProvider>,
);

expect(StatusBadge).toHaveBeenCalledWith(
expect.objectContaining({
type: 'Success',
autoResolveType: false,
}),
{},
);

const status = screen.getAllByRole('status');
expect(status).toHaveLength(1);
});

Expand All @@ -48,11 +89,20 @@ describe('Badge', () => {
},
};

const wrapper = shallow(<Badge value={value} structure={structure} />);
const status = wrapper.find(StatusBadge);
const badgeProps = status.props();
expect(badgeProps.type).toEqual('Error');
expect(badgeProps.autoResolveType).toEqual(false);
render(
<ThemeProvider>
<Badge value={value} structure={structure} />
</ThemeProvider>,
);
expect(StatusBadge).toHaveBeenCalledWith(
expect.objectContaining({
type: 'Error',
autoResolveType: false,
}),
{},
);

const status = screen.getAllByRole('status');
expect(status).toHaveLength(1);
});

Expand All @@ -62,15 +112,25 @@ describe('Badge', () => {
placeholder: 'empty',
};

const { getByText } = render(<Badge value={value} structure={structure} />);
const { getByText } = render(
<ThemeProvider>
<Badge value={value} structure={structure} />
</ThemeProvider>,
);

expect(getByText('extensibility::empty')).toBeVisible();
});

it('Renders a default placeholder for empty values', () => {
const value = null;
const structure = {};

const { getByText } = render(<Badge value={value} structure={structure} />);
const { getByText } = render(
<ThemeProvider>
<Badge value={value} structure={structure} />
</ThemeProvider>,
);

expect(getByText('-')).toBeVisible();
});

Expand All @@ -80,20 +140,22 @@ describe('Badge', () => {
description: 'popover',
};

let wrapper;
act(() => {
wrapper = mount(
render(
<ThemeProvider>
<Badge value={value} structure={structure} />
</ThemeProvider>,
);
});
const status = wrapper.find(StatusBadge);
const popoverBadge = status.find(PopoverBadge);
const popoverProps = popoverBadge.props();

expect(popoverProps.tooltipContent).toEqual('popover');
expect(status).toHaveLength(1);
expect(PopoverBadge).toHaveBeenCalledWith(
expect.objectContaining({
tooltipContent: 'popover',
}),
{},
);

const popoverBadge = screen.getAllByTestId('has-tooltip');
expect(popoverBadge).toHaveLength(1);
});
});
78 changes: 60 additions & 18 deletions src/components/Extensibility/components/tests/CodeViewer.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { shallow } from 'enzyme';
import { render } from '@testing-library/react';
import { CodeViewer } from '../CodeViewer';
import { ReadonlyEditorPanel } from 'shared/components/ReadonlyEditorPanel';
import { ThemeProvider } from '@ui5/webcomponents-react';

vi.mock('../../helpers', () => ({
useGetTranslation: () => ({
widgetT: key => key,
widgetT: () => 'Test Title',
}),
}));

Expand All @@ -14,18 +15,40 @@ vi.mock('../../hooks/useJsonata', () => ({
},
}));

vi.mock('shared/components/MonacoEditorESM/Editor', () => ({
Editor: vi.fn(props => <div {...props} />),
}));

vi.mock('shared/components/ReadonlyEditorPanel', async () => {
const ReadonlyEditorPanelMock = (
await vi.importActual('shared/components/ReadonlyEditorPanel')
).ReadonlyEditorPanel;
return {
ReadonlyEditorPanel: vi.fn(props => <ReadonlyEditorPanelMock {...props} />),
};
});

describe('CodeViewer', () => {
it('Renders CodeViewer component and detects yaml', () => {
const value = {
key: 'value',
};

const wrapper = shallow(<CodeViewer value={value} />);
const editor = wrapper.find(ReadonlyEditorPanel);
const { value: valueProps, editorProps } = editor.props();
const { language } = editorProps;
expect(valueProps).toEqual(JSON.stringify(value, null, 2));
expect(language).toEqual();
const { container } = render(
<ThemeProvider>
<CodeViewer value={value} />
</ThemeProvider>,
);

expect(ReadonlyEditorPanel).toHaveBeenCalledWith(
expect.objectContaining({
value: JSON.stringify(value, null, 2),
editorProps: expect.objectContaining({ language: undefined }),
}),
{},
);

const editor = container.getElementsByTagName('ui5-panel');
expect(editor).toHaveLength(1);
});

Expand All @@ -35,22 +58,41 @@ describe('CodeViewer', () => {
};
const structure = { language: 'json' };

const wrapper = shallow(<CodeViewer value={value} structure={structure} />);
const editor = wrapper.find(ReadonlyEditorPanel);
const { value: valueProps, editorProps } = editor.props();
const { language } = editorProps;
expect(valueProps).toEqual(JSON.stringify(value, null, 2));
expect(language).toEqual('json');
const { container } = render(
<ThemeProvider>
<CodeViewer value={value} structure={structure} />
</ThemeProvider>,
);

expect(ReadonlyEditorPanel).toHaveBeenCalledWith(
expect.objectContaining({
value: JSON.stringify(value, null, 2),
editorProps: expect.objectContaining({ language: 'json' }),
}),
{},
);

const editor = container.getElementsByTagName('ui5-panel');
expect(editor).toHaveLength(1);
});

it('Renders CodeViewer component without an empty value', () => {
const value = null;

const wrapper = shallow(<CodeViewer value={value} />);
const editor = wrapper.find(ReadonlyEditorPanel);
const { value: valueProps } = editor.props();
expect(valueProps).toEqual('');
const { container } = render(
<ThemeProvider>
<CodeViewer value={value} />
</ThemeProvider>,
);

expect(ReadonlyEditorPanel).toHaveBeenCalledWith(
expect.objectContaining({
value: '',
}),
{},
);

const editor = container.getElementsByTagName('ui5-panel');
expect(editor).toHaveLength(1);
});
});
Loading
Loading