Skip to content

Commit 05382b8

Browse files
authored
fix(AnalyticalTable): respect columnOrder prop (#666)
1 parent 972ee49 commit 05382b8

File tree

3 files changed

+408
-2
lines changed

3 files changed

+408
-2
lines changed

packages/main/src/components/AnalyticalTable/AnalyticalTable.test.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createPassThroughPropsTest } from '@shared/tests/utils';
2-
import { act, render, screen, fireEvent, cleanStaticAreaAfterEachTest, waitFor } from '@shared/tests';
2+
import { act, render, screen, fireEvent, cleanStaticAreaAfterEachTest, waitFor, getByText } from '@shared/tests';
33
import { AnalyticalTable } from '@ui5/webcomponents-react/lib/AnalyticalTable';
44
import { TableSelectionBehavior } from '@ui5/webcomponents-react/lib/TableSelectionBehavior';
55
import { TableSelectionMode } from '@ui5/webcomponents-react/lib/TableSelectionMode';
@@ -217,6 +217,25 @@ describe('AnalyticalTable', () => {
217217
expect(wrapper.render()).toMatchSnapshot();
218218
});
219219

220+
test('with initial column order', () => {
221+
const { getAllByRole, asFragment } = render(
222+
<AnalyticalTable
223+
data={data}
224+
columns={columns}
225+
groupable={false}
226+
filterable={false}
227+
sortable={false}
228+
columnOrder={['age', 'friend.age', 'friend.name', 'name']}
229+
/>
230+
);
231+
const columnHeaders = getAllByRole('columnheader', { hidden: true });
232+
233+
['Age', 'Friend Age', 'Friend Name', 'Name'].forEach((item, index) => {
234+
getByText(columnHeaders[index], item);
235+
});
236+
expect(asFragment()).toMatchSnapshot();
237+
});
238+
220239
test('test drag and drop of a draggable column', () => {
221240
const wrapper = mount(<AnalyticalTable data={data} title={'Test'} columns={columns} />);
222241

0 commit comments

Comments
 (0)