Skip to content

Commit

Permalink
chore: (WIP) mui upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
josebui committed Nov 7, 2023
1 parent 1f348cf commit cdae070
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/account/components/AccountLogin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,5 @@ test('AccountLogin: Display locale picker', async () => {
})
);
await render(<AccountLogin />);
expect(screen.getByRole('button', { name: /English/i })).toBeInTheDocument();
expect(screen.getByRole('combobox', { name: /English/i })).toBeInTheDocument();
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ const setup = async () => {
};

const changeYear = async newYear => {
const yearSelect = screen.getByRole('button', {
name: 'Year of landscape partnership inception Select a year',
const yearSelect = screen.getByRole('combobox', {
name: 'Year of landscape partnership inception',
});
await act(async () => fireEvent.mouseDown(yearSelect));
const listbox = within(screen.getByRole('listbox'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ const setup = async () => {
name: 'Description (required)',
});
const website = screen.getByRole('textbox', { name: 'Website' });
const location = screen.getByRole('button', {
name: 'Country or region (required) Landscape location',
const location = screen.getByRole('combobox', {
name: 'Country or region (required)',
});

const changeLocation = async newLocation => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const setup = async () => {
name: 'Description (required)',
});
const website = screen.getByRole('textbox', { name: 'Website' });
const location = screen.getByRole('button', {
name: 'Country or region (required) Landscape location',
const location = screen.getByRole('combobox', {
name: 'Country or region (required)',
});

const changeLocation = async newLocation => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const setup = async () => {
name: 'Description (required)',
});
const website = screen.getByRole('textbox', { name: 'Website' });
const location = screen.getByRole('button', {
name: 'Country or region (required) Landscape location',
const location = screen.getByRole('combobox', {
name: 'Country or region (required)',
});

const changeLocation = async newLocation => {
Expand Down
4 changes: 2 additions & 2 deletions src/landscape/components/LandscapeForm/KeyInfoNew.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const setup = async () => {
});
const email = screen.getByRole('textbox', { name: 'Email address' });
const website = screen.getByRole('textbox', { name: 'Website' });
const location = screen.getByRole('button', {
name: 'Country or region (required) Landscape location',
const location = screen.getByRole('combobox', {
name: 'Country or region (required)',
});

const changeLocation = async newLocation => {
Expand Down
5 changes: 3 additions & 2 deletions src/landscape/components/LandscapeForm/KeyInfoUpdate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ const setup = async (countryName = 'Landscape location') => {
});
const email = screen.getByRole('textbox', { name: 'Email address' });
const website = screen.getByRole('textbox', { name: 'Website' });
const location = screen.getByRole('button', {
name: `Country or region (required) ${countryName}`,
const location = screen.getByRole('combobox', {
name: `Country or region (required)`,
});
expect(within(location).getByText(countryName)).toBeInTheDocument();

const changeLocation = async newLocation => {
await act(async () => fireEvent.mouseDown(location));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const testSelectDataFileStep = async () => {
};

const validateSelectValue = async (name, value) => {
const select = screen.getByRole('button', { name });
const select = screen.getByRole('combobox', { name });
await act(async () => fireEvent.mouseDown(select));
expect(
within(screen.getByRole('listbox', { name })).getByRole('option', {
Expand All @@ -99,8 +99,8 @@ const validateSelectValue = async (name, value) => {
);
};
const changeSelectOption = async (name, newValue) => {
await screen.findByRole('button', { name });
const select = screen.getByRole('button', { name });
await screen.findByRole('combobox', { name });
const select = screen.getByRole('combobox', { name });

await act(async () => fireEvent.mouseDown(select));
await act(async () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ test('LandscapeMembers: Manager actions', async () => {
).toHaveAttribute('data-field', 'name');
expect(
within(rows[3])
.getByRole('button', { name: 'Member' })
.getByRole('combobox', { name: /Member/i })
.closest('[role="cell"]')
).toHaveAttribute('data-field', 'role');
const roleButton = within(rows[3]).getByRole('button', { name: 'Member' });
Expand Down
12 changes: 6 additions & 6 deletions src/localization/components/LocalePicker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ test('LocalePicker: Change locale', async () => {
await setup();
expect(screen.getByText('English')).toBeInTheDocument();
await act(async () =>
fireEvent.mouseDown(screen.getByRole('button', { name: /English/i }))
fireEvent.mouseDown(screen.getByRole('combobox', { name: /English/i }))
);
const listbox = within(screen.getByRole('listbox'));
await act(async () =>
fireEvent.click(listbox.getByRole('option', { name: /Español/i }))
);
expect(screen.getByRole('button', { name: /Español/i })).toBeInTheDocument();
expect(screen.getByRole('combobox', { name: /Español/i })).toBeInTheDocument();

const savePreferenceCall = terrasoApi.requestGraphQL.mock.calls[0];
expect(savePreferenceCall[1]).toStrictEqual({
Expand All @@ -84,13 +84,13 @@ test('LocalePicker: Dont save if no user', async () => {

expect(screen.getByText('English')).toBeInTheDocument();
await act(async () =>
fireEvent.mouseDown(screen.getByRole('button', { name: /English/i }))
fireEvent.mouseDown(screen.getByRole('combobox', { name: /English/i }))
);
const listbox = within(screen.getByRole('listbox'));
await act(async () =>
fireEvent.click(listbox.getByRole('option', { name: /Español/i }))
);
expect(screen.getByRole('button', { name: /Español/i })).toBeInTheDocument();
expect(screen.getByRole('combobox', { name: /Español/i })).toBeInTheDocument();
expect(terrasoApi.requestGraphQL).toHaveBeenCalledTimes(0);
});
test('LocalePicker: Change locale (small screen)', async () => {
Expand All @@ -106,11 +106,11 @@ test('LocalePicker: Change locale (small screen)', async () => {

expect(screen.getByText('EN')).toBeInTheDocument();
await act(async () =>
fireEvent.mouseDown(screen.getByRole('button', { name: /EN/i }))
fireEvent.mouseDown(screen.getByRole('combobox', { name: /EN/i }))
);
const listbox = within(screen.getByRole('listbox'));
await act(async () =>
fireEvent.click(listbox.getByRole('option', { name: /ES/i }))
);
expect(screen.getByRole('button', { name: /ES/i })).toBeInTheDocument();
expect(screen.getByRole('combobox', { name: /ES/i })).toBeInTheDocument();
});
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ test('SetDatasetStep: Longitude and latitude auto detected', async () => {

await act(async () =>
fireEvent.mouseDown(
screen.getByRole('button', { name: 'Latitude (required)' })
screen.getByRole('combobox', { name: 'Latitude (required)' })
)
);
const latitudeList = screen.getByRole('listbox', {
Expand All @@ -131,7 +131,7 @@ test('SetDatasetStep: Longitude and latitude auto detected', async () => {

await act(async () =>
fireEvent.mouseDown(
screen.getByRole('button', { name: 'Longitude (required)' })
screen.getByRole('combobox', { name: 'Longitude (required)' })
)
);
expect(
Expand Down

0 comments on commit cdae070

Please sign in to comment.