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

updated tests and added coverage for edit feature #608

Merged
merged 5 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
added aria label to compare with base form
  • Loading branch information
Carla-Moz committed Mar 4, 2024
commit cdde0d114fc89384f3efd5e8bfe336337a3fe1fa
17 changes: 9 additions & 8 deletions src/__tests__/Search/CompareWithBase.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ import {

function setUpTestData() {
const { testData } = getTestData();
(global.fetch as FetchMockSandbox).get(
'begin:https://treeherder.mozilla.org/api/project/try/push/',
{
(global.fetch as FetchMockSandbox)
.get('begin:https://treeherder.mozilla.org/api/project/try/push/', {
results: testData,
},
);
(window.fetch as FetchMockSandbox)
})
.get('begin:https://treeherder.mozilla.org/api/perfcompare/results/', [])
.get(
Carla-Moz marked this conversation as resolved.
Show resolved Hide resolved
'begin:https://treeherder.mozilla.org/api/project/mozilla-central/push/?revision=coconut',
Expand Down Expand Up @@ -62,7 +59,9 @@ describe('Compare With Base', () => {
<ResultsView title={Strings.metaData.pageTitle.results} />,
);
expect(await screen.findByText('Compare with a base')).toBeInTheDocument();
const formElement = await screen.findByRole('form');
const formElement = await screen.findByRole('form', {
name: 'Compare with base form',
});
expect(formElement).toMatchSnapshot('Initial state for the form');
});

Expand Down Expand Up @@ -143,7 +142,9 @@ describe('Compare With Base', () => {
const user = userEvent.setup({ delay: null });

expect(await screen.findByText('Compare with a base')).toBeInTheDocument();
const formElement = await screen.findByRole('form');
const formElement = await screen.findByRole('form', {
name: 'Compare with base form',
});
expect(formElement).toMatchSnapshot('Initial state for the form');

// Find out if the base revision is rendered
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/Search/__snapshots__/CompareWithBase.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
exports[`Compare With Base renders correctly when there are no results: Initial state for the form 1`] = `
<form
action="/compare-results"
aria-label="Compare with base form"
class="form-wrapper"
method="get"
role="form"
>
<div
class="MuiGrid-root component_f14z0jsa css-plh9qo-MuiGrid-root"
Expand Down Expand Up @@ -770,9 +770,9 @@ exports[`Compare With Base selects and displays new framework when clicked 1`] =
exports[`Compare With Base should have an edit mode in Results View: After clicking edit for the base revision 1`] = `
<form
action="/compare-results"
aria-label="Compare with base form"
class="form-wrapper"
method="get"
role="form"
>
<div
class="MuiGrid-root component_f14z0jsa css-plh9qo-MuiGrid-root"
Expand Down Expand Up @@ -1417,9 +1417,9 @@ exports[`Compare With Base should have an edit mode in Results View: After click
exports[`Compare With Base should have an edit mode in Results View: After clicking edit for the new revision 1`] = `
<form
action="/compare-results"
aria-label="Compare with base form"
class="form-wrapper"
method="get"
role="form"
>
<div
class="MuiGrid-root component_f14z0jsa css-plh9qo-MuiGrid-root"
Expand Down Expand Up @@ -1947,9 +1947,9 @@ exports[`Compare With Base should have an edit mode in Results View: After click
exports[`Compare With Base should have an edit mode in Results View: Initial state for the form 1`] = `
<form
action="/compare-results"
aria-label="Compare with base form"
class="form-wrapper"
method="get"
role="form"
>
<div
class="MuiGrid-root component_f14z0jsa css-plh9qo-MuiGrid-root"
Expand Down Expand Up @@ -2708,9 +2708,9 @@ exports[`Compare With Base should remove the checked revision once X button is c
/>
<form
action="/compare-results"
aria-label="Compare with base form"
class="form-wrapper"
method="get"
role="form"
>
<div
class="MuiGrid-root component_f14z0jsa css-plh9qo-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ exports[`Search Containter should match snapshot 1`] = `
/>
<form
action="/compare-results"
aria-label="Compare with base form"
class="form-wrapper"
method="get"
role="form"
>
<div
class="MuiGrid-root component_f14z0jsa css-plh9qo-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ exports[`SearchResultsList should match snapshot 1`] = `
/>
<form
action="/compare-results"
aria-label="Compare with base form"
class="form-wrapper"
method="get"
role="form"
>
<div
class="MuiGrid-root component_f14z0jsa css-plh9qo-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ exports[`Search View renders correctly when there are no results 1`] = `
/>
<form
action="/compare-results"
aria-label="Compare with base form"
class="form-wrapper"
method="get"
role="form"
>
<div
class="MuiGrid-root component_f14z0jsa css-plh9qo-MuiGrid-root"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Search/CompareWithBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function CompareWithBase({
action='/compare-results'
className='form-wrapper'
onSubmit={possiblyPreventFormSubmission}
role='form'
aria-label='Compare with base form'
>
<SearchComponent
{...stringsBase}
Expand Down