From 325b328154a23690c002cc4bc30c0fb84ea929f4 Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Wed, 17 Apr 2024 11:48:26 -0500 Subject: [PATCH] chore: Data grip upgrade --- .../components/MembershipsList.js | 12 +++++------ src/common/components/TableResponsive.js | 10 +++++----- src/group/components/GroupList.test.js | 14 ++++++------- .../components/GroupMembers.test.js | 20 +++++++++---------- src/landscape/components/LandscapeList.js | 8 ++++---- .../components/LandscapeList.test.js | 12 +++++------ .../components/LandscapeMembers.test.js | 20 +++++++++---------- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/collaboration/components/MembershipsList.js b/src/collaboration/components/MembershipsList.js index f97800de1..4659acd99 100644 --- a/src/collaboration/components/MembershipsList.js +++ b/src/collaboration/components/MembershipsList.js @@ -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 }) => ( {membership.pendingEmail @@ -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 }) => ( ), diff --git a/src/common/components/TableResponsive.js b/src/common/components/TableResponsive.js index 17723d3d6..87c0f2d14 100644 --- a/src/common/components/TableResponsive.js +++ b/src/common/components/TableResponsive.js @@ -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); @@ -112,7 +112,7 @@ const CardValue = props => { } const formattedValue = _.has('valueFormatter', column) - ? column.valueFormatter({ value }) + ? column.valueFormatter(value) : value; if (column.renderCell) { @@ -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 ( { 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@email.com' }) + within(rows[2]).getByRole('gridcell', { name: 'email@email.com' }) ).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 () => { @@ -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( @@ -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 () => { diff --git a/src/group/membership/components/GroupMembers.test.js b/src/group/membership/components/GroupMembers.test.js index ab702d097..d079834a3 100644 --- a/src/group/membership/components/GroupMembers.test.js +++ b/src/group/membership/components/GroupMembers.test.js @@ -168,7 +168,7 @@ 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'); @@ -176,13 +176,13 @@ test('GroupMembers: Display list', async () => { 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 () => { @@ -272,14 +272,14 @@ 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' }) @@ -287,7 +287,7 @@ test('GroupMembers: Display list manager', async () => { expect( within(rows[2]) .getByRole('button', { name: 'Remove' }) - .closest('[role="cell"]') + .closest('[role="gridcell"]') ).toHaveAttribute('data-field', 'actions'); }); test('GroupMembers: Manager actions', async () => { @@ -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(); @@ -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'); @@ -404,7 +404,7 @@ test('GroupMembers: Manager actions', async () => { .getByRole('combobox', { name: 'Role', }) - .closest('[role="cell"]') + .closest('[role="gridcell"]') ).toHaveAttribute('data-field', 'role') ); expect( diff --git a/src/landscape/components/LandscapeList.js b/src/landscape/components/LandscapeList.js index 4a9c02500..40e93b809 100644 --- a/src/landscape/components/LandscapeList.js +++ b/src/landscape/components/LandscapeList.js @@ -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', @@ -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 }) => ( ), diff --git a/src/landscape/components/LandscapeList.test.js b/src/landscape/components/LandscapeList.test.js index a9a557886..9af78087d 100644 --- a/src/landscape/components/LandscapeList.test.js +++ b/src/landscape/components/LandscapeList.test.js @@ -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 () => { @@ -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( @@ -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 () => { diff --git a/src/landscape/membership/components/LandscapeMembers.test.js b/src/landscape/membership/components/LandscapeMembers.test.js index 1d925facc..afc2bbf50 100644 --- a/src/landscape/membership/components/LandscapeMembers.test.js +++ b/src/landscape/membership/components/LandscapeMembers.test.js @@ -129,7 +129,7 @@ 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'); @@ -137,7 +137,7 @@ test('LandscapeMembers: Display list', async () => { 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' }) @@ -145,7 +145,7 @@ test('LandscapeMembers: Display list', async () => { 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 () => { @@ -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( @@ -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 () => { @@ -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(); @@ -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'); @@ -386,7 +386,7 @@ test('LandscapeMembers: Manager actions', async () => { .getByRole('combobox', { name: 'Role', }) - .closest('[role="cell"]') + .closest('[role="gridcell"]') ).toHaveAttribute('data-field', 'role') );