Skip to content

Commit

Permalink
chore: Data grip upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
josebui committed Apr 17, 2024
1 parent 1b49a69 commit 325b328
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 48 deletions.
12 changes: 6 additions & 6 deletions src/collaboration/components/MembershipsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ const MembershipsList = props => {
xs: 12,
sm: 5,
},
valueGetter: ({ row: membership }) =>
membership.pendingEmail
? membership.pendingEmail
: t('user.full_name', { user: membership.user }),
valueGetter: (value, row, column, apiRef) =>
row.pendingEmail
? row.pendingEmail
: t('user.full_name', { user: row.user }),
cardRender: ({ row: membership }) => (
<Typography noWrap>
{membership.pendingEmail
Expand All @@ -72,8 +72,8 @@ const MembershipsList = props => {
xs: 6,
sm: 4,
},
valueGetter: ({ row: member }) =>
t(`group.role_${member.userRole.toLowerCase()}`),
valueGetter: (value, row, column, apiRef) =>
t(`group.role_${row.userRole.toLowerCase()}`),
renderCell: ({ row: membership, tabIndex }) => (
<RoleComponent membership={membership} tabIndex={tabIndex} />
),
Expand Down
10 changes: 5 additions & 5 deletions src/common/components/TableResponsive.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const CardField = props => {
const isActions = column.field === 'actions';

const value = column.valueGetter
? column.valueGetter({ row })
? column.valueGetter(null, row, null, null)
: _.get(column.field, row);

const showValue = isActions || _.isInteger(value) || !_.isEmpty(value);
Expand Down Expand Up @@ -112,7 +112,7 @@ const CardValue = props => {
}

const formattedValue = _.has('valueFormatter', column)
? column.valueFormatter({ value })
? column.valueFormatter(value)
: value;

if (column.renderCell) {
Expand Down Expand Up @@ -341,10 +341,10 @@ const setSearchHighligthRender = props => {
}
return {
...column,
valueFormatter: params => {
valueFormatter: (value, ...params) => {
const formattedValue = _.has('valueFormatter', column)
? column.valueFormatter(params)
: params.value;
? column.valueFormatter(value, ...params)
: value;
return (
<Highlighter
searchWords={[searchParams.search]}
Expand Down
14 changes: 7 additions & 7 deletions src/group/components/GroupList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,23 @@ test('GroupList: Display list', async () => {
const rows = screen.getAllByRole('row');
expect(rows.length).toBe(16); // 15 displayed + header
expect(
within(rows[2]).getByRole('cell', { name: 'Group name 1' })
within(rows[2]).getByRole('gridcell', { name: 'Group name 1' })
).toHaveAttribute('data-field', 'name');
expect(
within(rows[2]).getByRole('cell', { name: 'www.group.org' })
within(rows[2]).getByRole('gridcell', { name: 'www.group.org' })
).toHaveAttribute('data-field', 'website');
expect(
within(rows[2]).getByRole('cell', { name: '[email protected]' })
within(rows[2]).getByRole('gridcell', { name: '[email protected]' })
).toHaveAttribute('data-field', 'email');
expect(
within(rows[2])
.getByRole('button', { name: 'Join: Group name 1' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'actions');
expect(
screen
.getByRole('button', { name: 'Leave: Group name 3' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'actions');
});
test('GroupList: List sort', async () => {
Expand Down Expand Up @@ -214,7 +214,7 @@ test('GroupList: List sort', async () => {

// Sorting
expect(
within(rows[1]).getByRole('cell', { name: 'Group name 0' })
within(rows[1]).getByRole('gridcell', { name: 'Group name 0' })
).toHaveAttribute('data-field', 'name');
await act(async () =>
fireEvent.click(
Expand All @@ -223,7 +223,7 @@ test('GroupList: List sort', async () => {
);
const sortedRows = screen.getAllByRole('row');
expect(
within(sortedRows[1]).getByRole('cell', { name: 'Group name 9' })
within(sortedRows[1]).getByRole('gridcell', { name: 'Group name 9' })
).toHaveAttribute('data-field', 'name');
});
test('GroupList: Display list (small screen)', async () => {
Expand Down
20 changes: 10 additions & 10 deletions src/group/membership/components/GroupMembers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,21 @@ test('GroupMembers: Display list', async () => {
const rows = screen.getAllByRole('row');
expect(rows.length).toBe(16); // 15 displayed + header
expect(
within(rows[2]).getByRole('cell', {
within(rows[2]).getByRole('gridcell', {
name: 'First name Last Name',
})
).toHaveAttribute('data-field', 'name');
expect(
within(rows[9]).queryByRole('button', { name: 'Member' })
).not.toBeInTheDocument();
expect(
within(rows[9]).getByText('Member').closest('[role="cell"]')
within(rows[9]).getByText('Member').closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'role');
expect(within(rows[2]).queryByRole('button')).not.toBeInTheDocument();
expect(
within(rows[1])
.getByRole('button', { name: 'Leave: Group Name' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'actions');
});
test('GroupMembers: Display list (small)', async () => {
Expand Down Expand Up @@ -272,22 +272,22 @@ test('GroupMembers: Display list manager', async () => {
const rows = screen.getAllByRole('row');
expect(rows.length).toBe(16); // 15 displayed + header
expect(
within(rows[2]).getByRole('cell', {
within(rows[2]).getByRole('gridcell', {
name: 'Member name Member Last Name',
})
).toHaveAttribute('data-field', 'name');
expect(
within(rows[9])
.getByRole('combobox', { name: 'Role' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'role');
expect(
within(rows[9]).getByRole('combobox', { name: 'Role' })
).toHaveTextContent('Member');
expect(
within(rows[2])
.getByRole('button', { name: 'Remove' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'actions');
});
test('GroupMembers: Manager actions', async () => {
Expand Down Expand Up @@ -364,14 +364,14 @@ test('GroupMembers: Manager actions', async () => {

// Role Change
expect(
within(rows[3]).getByRole('cell', {
within(rows[3]).getByRole('gridcell', {
name: 'Member name 2 Member Last Name 2',
})
).toHaveAttribute('data-field', 'name');
expect(
within(rows[3])
.getByRole('combobox', { name: 'Role' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'role');
const roleButton = within(rows[3]).getByRole('combobox', { name: 'Role' });
expect(within(roleButton).getByText('Member')).toBeInTheDocument();
Expand All @@ -394,7 +394,7 @@ test('GroupMembers: Manager actions', async () => {
);

expect(
within(screen.getAllByRole('row')[3]).getByRole('cell', {
within(screen.getAllByRole('row')[3]).getByRole('gridcell', {
name: 'Member name 2 Member Last Name 2',
})
).toHaveAttribute('data-field', 'name');
Expand All @@ -404,7 +404,7 @@ test('GroupMembers: Manager actions', async () => {
.getByRole('combobox', {
name: 'Role',
})
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'role')
);
expect(
Expand Down
8 changes: 4 additions & 4 deletions src/landscape/components/LandscapeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ const LandscapeList = () => {
headerName: t('landscape.list_column_location'),
flex: 0.5,
minWidth: 200,
valueGetter: ({ row: landscape }) =>
landscape.location && countryNameForCode(landscape.location)?.name,
valueGetter: (value, row, column, apiRef) =>
row.location && countryNameForCode(row.location)?.name,
},
{
field: 'website',
Expand All @@ -149,8 +149,8 @@ const LandscapeList = () => {
cardFieldSizes: {
xs: 6,
},
valueGetter: ({ row: landscape }) =>
_.getOr(0, 'membershipInfo.totalCount', landscape),
valueGetter: (value, row, column, apiRef) =>
_.getOr(0, 'membershipInfo.totalCount', row),
renderCell: ({ row: landscape }) => (
<MembershipListCount membershipInfo={landscape.membershipInfo} />
),
Expand Down
12 changes: 6 additions & 6 deletions src/landscape/components/LandscapeList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,21 @@ test('LandscapeList: Display list', async () => {
const rows = screen.getAllByRole('row');
expect(rows.length).toBe(16); // 15 displayed + header
expect(
within(rows[2]).getByRole('cell', { name: 'Landscape Name 1' })
within(rows[2]).getByRole('gridcell', { name: 'Landscape Name 1' })
).toHaveAttribute('data-field', 'name');
expect(within(rows[2]).getByRole('cell', { name: '23' })).toHaveAttribute(
expect(within(rows[2]).getByRole('gridcell', { name: '23' })).toHaveAttribute(
'data-field',
'members'
);
expect(
within(rows[2])
.getByRole('button', { name: 'Join: Landscape Name 1' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'actions');
expect(
within(rows[9])
.getByRole('button', { name: 'Leave: Landscape Name 3' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'actions');
});
test('LandscapeList: Search', async () => {
Expand Down Expand Up @@ -354,7 +354,7 @@ test('LandscapeList: List sort', async () => {

// Sorting
expect(
within(rows[1]).getByRole('cell', { name: 'Landscape Name 0' })
within(rows[1]).getByRole('gridcell', { name: 'Landscape Name 0' })
).toHaveAttribute('data-field', 'name');
await act(async () =>
fireEvent.click(
Expand All @@ -364,7 +364,7 @@ test('LandscapeList: List sort', async () => {
const sortedRows = screen.getAllByRole('row');
expect(sortedRows.length).toBe(16); // 15 displayed + header
expect(
within(sortedRows[1]).getByRole('cell', { name: 'Landscape Name 9' })
within(sortedRows[1]).getByRole('gridcell', { name: 'Landscape Name 9' })
).toHaveAttribute('data-field', 'name');
});
test('LandscapeList: Display list (small screen)', async () => {
Expand Down
20 changes: 10 additions & 10 deletions src/landscape/membership/components/LandscapeMembers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,23 @@ test('LandscapeMembers: Display list', async () => {
const rows = screen.getAllByRole('row');
expect(rows.length).toBe(16); // 15 displayed + header
expect(
within(rows[2]).getByRole('cell', {
within(rows[2]).getByRole('gridcell', {
name: 'First name Last Name',
})
).toHaveAttribute('data-field', 'name');
expect(
within(rows[9]).queryByRole('button', { name: 'Member' })
).not.toBeInTheDocument();
expect(
within(rows[9]).getByText('Member').closest('[role="cell"]')
within(rows[9]).getByText('Member').closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'role');
expect(
within(rows[2]).queryByRole('button', { name: 'Member' })
).not.toBeInTheDocument();
expect(
within(rows[1])
.getByRole('button', { name: 'Leave: Landscape Name' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'actions');
});
test('LandscapeMembers: Display list (small)', async () => {
Expand Down Expand Up @@ -254,14 +254,14 @@ test('LandscapeMembers: Display list manager', async () => {
const rows = screen.getAllByRole('row');
expect(rows.length).toBe(16); // 15 displayed + header
expect(
within(rows[2]).getByRole('cell', {
within(rows[2]).getByRole('gridcell', {
name: 'Member name 1 Member Last Name 1',
})
).toHaveAttribute('data-field', 'name');
expect(
within(rows[9])
.getByRole('combobox', { name: 'Role' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'role');
expect(
within(within(rows[9]).getByRole('combobox', { name: 'Role' })).getByText(
Expand All @@ -271,7 +271,7 @@ test('LandscapeMembers: Display list manager', async () => {
expect(
within(rows[2])
.getByRole('button', { name: 'Remove' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'actions');
});
test('LandscapeMembers: Manager actions', async () => {
Expand Down Expand Up @@ -347,14 +347,14 @@ test('LandscapeMembers: Manager actions', async () => {

// Role Change
expect(
within(rows[3]).getByRole('cell', {
within(rows[3]).getByRole('gridcell', {
name: 'Member name 2 Member Last Name 2',
})
).toHaveAttribute('data-field', 'name');
expect(
within(rows[3])
.getByRole('combobox', { name: 'Role' })
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'role');
const roleButton = within(rows[3]).getByRole('combobox', { name: 'Role' });
expect(within(roleButton).getByText('Member')).toBeInTheDocument();
Expand All @@ -376,7 +376,7 @@ test('LandscapeMembers: Manager actions', async () => {
})
);
expect(
within(screen.getAllByRole('row')[3]).getByRole('cell', {
within(screen.getAllByRole('row')[3]).getByRole('gridcell', {
name: 'Member name 2 Member Last Name 2',
})
).toHaveAttribute('data-field', 'name');
Expand All @@ -386,7 +386,7 @@ test('LandscapeMembers: Manager actions', async () => {
.getByRole('combobox', {
name: 'Role',
})
.closest('[role="cell"]')
.closest('[role="gridcell"]')
).toHaveAttribute('data-field', 'role')
);

Expand Down

0 comments on commit 325b328

Please sign in to comment.