Merge pull request #10518 from backstage/dependabot/npm_and_yarn/testing-library/user-event-14.0.0

build(deps): bump @testing-library/user-event from 13.5.0 to 14.0.0
This commit is contained in:
Johan Haals
2022-04-05 13:16:40 +02:00
committed by GitHub
109 changed files with 391 additions and 280 deletions
+1 -1
View File
@@ -46,7 +46,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/object-hash": "^2.2.1",
+1 -1
View File
@@ -46,7 +46,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -44,7 +44,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -42,7 +42,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"msw": "^0.35.0"
+1 -1
View File
@@ -62,7 +62,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/swagger-ui-react": "^4.1.1",
+1 -1
View File
@@ -55,7 +55,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -52,7 +52,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -49,7 +49,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/recharts": "^1.8.15",
+1 -1
View File
@@ -53,7 +53,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7"
},
"files": [
@@ -141,7 +141,7 @@ describe('<CatalogGraphCard/>', () => {
);
expect(await findByText('b:d/c')).toBeInTheDocument();
userEvent.click(await findByText('b:d/c'));
await userEvent.click(await findByText('b:d/c'));
expect(analyticsSpy.getEvents()[0]).toMatchObject({
action: 'click',
@@ -45,6 +45,14 @@ describe('<CatalogGraphPage/>', () => {
value: () => ({ width: 100, height: 100 }),
configurable: true,
});
Object.defineProperty(window.SVGElement.prototype, 'viewBox', {
value: { baseVal: { x: 0, y: 0, width: 100, height: 100 } },
configurable: true,
});
Object.defineProperty(window.MouseEvent.prototype, 'view', {
value: window,
configurable: true,
});
});
beforeEach(() => {
@@ -142,7 +150,7 @@ describe('<CatalogGraphPage/>', () => {
expect(queryByText('Max Depth')).toBeNull();
userEvent.click(getByText('Filters'));
await userEvent.click(getByText('Filters'));
expect(getByText('Max Depth')).toBeInTheDocument();
});
@@ -159,7 +167,7 @@ describe('<CatalogGraphPage/>', () => {
expect(await findAllByTestId('node')).toHaveLength(2);
userEvent.click(getByText('b:d/e'));
await userEvent.click(getByText('b:d/e'));
expect(await findByText('hasPart')).toBeInTheDocument();
});
@@ -173,8 +181,9 @@ describe('<CatalogGraphPage/>', () => {
expect(await findAllByTestId('node')).toHaveLength(2);
userEvent.click(getByText('b:d/e'), { shiftKey: true });
const user = userEvent.setup();
await user.keyboard('{Shift>}');
await user.click(getByText('b:d/e'));
expect(navigate).toBeCalledWith('/entity/{kind}/{namespace}/{name}');
});
@@ -193,7 +202,10 @@ describe('<CatalogGraphPage/>', () => {
expect(await findAllByTestId('node')).toHaveLength(2);
userEvent.click(getByText('b:d/e'));
// We wait a bit here to reliably reproduce an issue where that requires the `baseVal` and `view` mocks
await new Promise(r => setTimeout(r, 100));
await userEvent.click(getByText('b:d/e'));
expect(analyticsSpy.getEvents()[0]).toMatchObject({
action: 'click',
@@ -216,7 +228,9 @@ describe('<CatalogGraphPage/>', () => {
expect(await findAllByTestId('node')).toHaveLength(2);
userEvent.click(getByText('b:d/e'), { shiftKey: true });
const user = userEvent.setup();
await user.keyboard('{Shift>}');
await user.click(getByText('b:d/e'));
expect(analyticsSpy.getEvents()[0]).toMatchObject({
action: 'click',
@@ -36,8 +36,8 @@ describe('<DirectionFilter/>', () => {
expect(getByText('Right to left')).toBeInTheDocument();
userEvent.click(getByTestId('select'));
userEvent.click(getByText('Top to bottom'));
await userEvent.click(getByTestId('select'));
await userEvent.click(getByText('Top to bottom'));
await waitFor(() => {
expect(getByText('Top to bottom')).toBeInTheDocument();
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { render } from '@testing-library/react';
import { render, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { MaxDepthFilter } from './MaxDepthFilter';
@@ -37,24 +37,24 @@ describe('<MaxDepthFilter/>', () => {
expect(getByLabelText('maxp')).toHaveValue(null);
});
test('should clear max depth', () => {
test('should clear max depth', async () => {
const onChange = jest.fn();
const { getByLabelText } = render(
<MaxDepthFilter value={10} onChange={onChange} />,
);
userEvent.click(getByLabelText('clear max depth'));
await userEvent.click(getByLabelText('clear max depth'));
expect(onChange).toBeCalledWith(Number.POSITIVE_INFINITY);
});
test('should set max depth to undefined if below one', () => {
test('should set max depth to undefined if below one', async () => {
const onChange = jest.fn();
const { getByLabelText } = render(
<MaxDepthFilter value={1} onChange={onChange} />,
);
userEvent.clear(getByLabelText('maxp'));
userEvent.type(getByLabelText('maxp'), '0');
await userEvent.clear(getByLabelText('maxp'));
await userEvent.type(getByLabelText('maxp'), '0');
expect(onChange).toBeCalledWith(Number.POSITIVE_INFINITY);
});
@@ -67,9 +67,10 @@ describe('<MaxDepthFilter/>', () => {
expect(getByLabelText('maxp')).toHaveValue(5);
userEvent.clear(getByLabelText('maxp'));
userEvent.type(getByLabelText('maxp'), '10');
expect(onChange).toBeCalledWith(10);
await userEvent.clear(getByLabelText('maxp'));
await userEvent.type(getByLabelText('maxp'), '10');
waitFor(() => {
expect(onChange).toBeCalledWith(10);
});
});
});
@@ -69,10 +69,10 @@ describe('<SelectedKindsFilter/>', () => {
</ApiProvider>,
);
userEvent.click(getByLabelText('Open'));
await userEvent.click(getByLabelText('Open'));
await waitFor(() => expect(getByText('System')).toBeInTheDocument());
userEvent.click(getByText('System'));
await userEvent.click(getByText('System'));
await waitFor(() => {
expect(onChange).toBeCalledWith(['api', 'component', 'system']);
@@ -89,11 +89,11 @@ describe('<SelectedKindsFilter/>', () => {
/>
</ApiProvider>,
);
userEvent.click(getByLabelText('Open'));
await userEvent.click(getByLabelText('Open'));
await waitFor(() => expect(getByText('Resource')).toBeInTheDocument());
userEvent.click(getByText('Resource'));
await userEvent.click(getByText('Resource'));
await waitFor(() => {
expect(onChange).toBeCalledWith(undefined);
@@ -108,7 +108,7 @@ describe('<SelectedKindsFilter/>', () => {
</ApiProvider>,
);
userEvent.click(getByRole('combobox'));
await userEvent.click(getByRole('combobox'));
userEvent.tab();
await waitFor(() => {
@@ -48,13 +48,13 @@ describe('<SelectedRelationsFilter/>', () => {
/>,
);
userEvent.click(getByLabelText('Open'));
await userEvent.click(getByLabelText('Open'));
await waitFor(() =>
expect(getByText(RELATION_HAS_MEMBER)).toBeInTheDocument(),
);
userEvent.click(getByText(RELATION_HAS_MEMBER));
await userEvent.click(getByText(RELATION_HAS_MEMBER));
await waitFor(() => {
expect(onChange).toBeCalledWith([
@@ -77,13 +77,13 @@ describe('<SelectedRelationsFilter/>', () => {
/>,
);
userEvent.click(getByLabelText('Open'));
await userEvent.click(getByLabelText('Open'));
await waitFor(() =>
expect(getByText(RELATION_HAS_MEMBER)).toBeInTheDocument(),
);
userEvent.click(getByText(RELATION_HAS_MEMBER));
await userEvent.click(getByText(RELATION_HAS_MEMBER));
await waitFor(() => {
expect(onChange).toBeCalledWith(undefined);
@@ -100,7 +100,7 @@ describe('<SelectedRelationsFilter/>', () => {
/>,
);
userEvent.click(getByRole('combobox'));
await userEvent.click(getByRole('combobox'));
userEvent.tab();
await waitFor(() => {
@@ -28,7 +28,7 @@ describe('<SwitchFilter/>', () => {
expect(getByLabelText('My label')).not.toBeChecked();
});
test('should toggle value', () => {
test('should toggle value', async () => {
const onChange = jest.fn();
const { getByLabelText } = render(
<SwitchFilter label="My label" value onChange={onChange} />,
@@ -37,7 +37,7 @@ describe('<SwitchFilter/>', () => {
expect(getByLabelText('My label')).toBeInTheDocument();
expect(getByLabelText('My label')).toBeChecked();
userEvent.click(getByLabelText('My label'));
await userEvent.click(getByLabelText('My label'));
expect(onChange).toBeCalledWith(false);
});
@@ -81,7 +81,7 @@ describe('<CustomNode />', () => {
);
expect(getByText('kind:namespace/name')).toBeInTheDocument();
userEvent.click(getByText('kind:namespace/name'));
await userEvent.click(getByText('kind:namespace/name'));
expect(onClick).toBeCalledTimes(1);
});
@@ -377,7 +377,7 @@ describe('<EntityRelationsGraph/>', () => {
</Wrapper>,
);
userEvent.click(await findByText('k:d/a1'));
await userEvent.click(await findByText('k:d/a1'));
expect(onNodeClick).toBeCalledTimes(1);
});
+1 -1
View File
@@ -67,7 +67,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
@@ -100,7 +100,7 @@ describe('<StepInitAnalyzeUrl />', () => {
await act(async () => {
try {
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
} catch {
return;
}
@@ -126,7 +126,7 @@ describe('<StepInitAnalyzeUrl />', () => {
getByRole('textbox', { name: /Repository/i }),
'http:/',
);
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
});
expect(catalogImportApi.analyzeUrl).toBeCalledTimes(0);
@@ -161,7 +161,7 @@ describe('<StepInitAnalyzeUrl />', () => {
getByRole('textbox', { name: /Repository/i }),
'https://my-repository',
);
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
});
expect(onAnalysisFn).toBeCalledTimes(1);
@@ -198,7 +198,7 @@ describe('<StepInitAnalyzeUrl />', () => {
getByRole('textbox', { name: /Repository/i }),
'https://my-repository-1',
);
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
});
expect(onAnalysisFn).toBeCalledTimes(1);
@@ -234,7 +234,7 @@ describe('<StepInitAnalyzeUrl />', () => {
getByRole('textbox', { name: /Repository/i }),
'https://my-repository-1',
);
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
});
expect(onAnalysisFn).toBeCalledTimes(0);
@@ -278,7 +278,7 @@ describe('<StepInitAnalyzeUrl />', () => {
getByRole('textbox', { name: /Repository/i }),
'https://my-repository-2',
);
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
});
expect(onAnalysisFn).toBeCalledTimes(1);
@@ -316,7 +316,7 @@ describe('<StepInitAnalyzeUrl />', () => {
getByRole('textbox', { name: /Repository/i }),
'https://my-repository-2',
);
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
});
expect(onAnalysisFn).toBeCalledTimes(0);
@@ -360,7 +360,7 @@ describe('<StepInitAnalyzeUrl />', () => {
getByRole('textbox', { name: /Repository/i }),
'https://my-repository-2',
);
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
});
expect(onAnalysisFn).toBeCalledTimes(0);
@@ -389,7 +389,7 @@ describe('<StepInitAnalyzeUrl />', () => {
getByRole('textbox', { name: /Repository/i }),
'https://my-repository-2',
);
userEvent.click(getByRole('button', { name: /Analyze/i }));
await userEvent.click(getByRole('button', { name: /Analyze/i }));
});
expect(onAnalysisFn).toBeCalledTimes(0);
@@ -39,7 +39,7 @@ describe('<PreparePullRequestForm />', () => {
);
await act(async () => {
userEvent.click(getByRole('button', { name: /submit/i }));
await userEvent.click(getByRole('button', { name: /submit/i }));
});
expect(onSubmitFn).toBeCalledTimes(1);
@@ -69,7 +69,7 @@ describe('<PreparePullRequestForm />', () => {
await act(async () => {
userEvent.clear(getByLabelText('Main Field'));
await userEvent.type(getByLabelText('Main Field'), 'My Text');
userEvent.click(getByRole('button', { name: /submit/i }));
await userEvent.click(getByRole('button', { name: /submit/i }));
});
expect(onSubmitFn).toBeCalledTimes(1);
@@ -104,7 +104,7 @@ describe('<PreparePullRequestForm />', () => {
expect(queryByText('Error in required main field')).not.toBeInTheDocument();
await act(async () => {
userEvent.click(getByRole('button', { name: /submit/i }));
await userEvent.click(getByRole('button', { name: /submit/i }));
});
expect(onSubmitFn).not.toBeCalled();
@@ -168,9 +168,9 @@ describe('<StepPrepareCreatePullRequest />', () => {
},
);
userEvent.type(await screen.findByLabelText('name'), '-changed');
userEvent.type(await screen.findByLabelText('owner'), '-changed');
userEvent.click(screen.getByRole('button', { name: /Create PR/i }));
await userEvent.type(await screen.findByLabelText('name'), '-changed');
await userEvent.type(await screen.findByLabelText('owner'), '-changed');
await userEvent.click(screen.getByRole('button', { name: /Create PR/i }));
});
expect(catalogImportApi.submitPullRequest).toBeCalledTimes(1);
@@ -244,7 +244,7 @@ spec:
},
);
userEvent.click(
await userEvent.click(
await screen.findByRole('button', { name: /Create PR/i }),
);
});
@@ -124,14 +124,14 @@ describe('<StepPrepareSelectLocations />', () => {
expect(getByRole('button', { name: /Review/i })).toBeDisabled();
await act(async () => {
userEvent.click(getByRole('button', { name: /Select All/i }));
await userEvent.click(getByRole('button', { name: /Select All/i }));
});
checkboxes.forEach(c => expect(c).toBeChecked());
expect(getByRole('button', { name: /Review/i })).not.toBeDisabled();
await act(async () => {
userEvent.click(getByRole('button', { name: /Select All/i }));
await userEvent.click(getByRole('button', { name: /Select All/i }));
});
checkboxes.forEach(c => expect(c).not.toBeChecked());
@@ -171,7 +171,7 @@ describe('<StepPrepareSelectLocations />', () => {
checkboxes.forEach(c => expect(c).not.toBeChecked());
await act(async () => {
userEvent.click(checkboxes[1]);
await userEvent.click(checkboxes[1]);
});
expect(checkboxes[0]).not.toBeChecked();
@@ -179,7 +179,7 @@ describe('<StepPrepareSelectLocations />', () => {
expect(checkboxes[2]).not.toBeChecked();
await act(async () => {
userEvent.click(checkboxes[1]);
await userEvent.click(checkboxes[1]);
});
checkboxes.forEach(c => expect(c).not.toBeChecked());
@@ -197,7 +197,7 @@ describe('<StepPrepareSelectLocations />', () => {
);
await act(async () => {
userEvent.click(getByRole('button', { name: /Back/i }));
await userEvent.click(getByRole('button', { name: /Back/i }));
});
expect(onGoBack).toBeCalledTimes(1);
@@ -217,11 +217,11 @@ describe('<StepPrepareSelectLocations />', () => {
const checkboxes = getAllByRole('checkbox');
await act(async () => {
userEvent.click(checkboxes[1]);
await userEvent.click(checkboxes[1]);
});
await act(async () => {
userEvent.click(getByRole('button', { name: /Review/i }));
await userEvent.click(getByRole('button', { name: /Review/i }));
});
expect(onPrepare).toBeCalledTimes(1);
+1 -1
View File
@@ -71,7 +71,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/jwt-decode": "^3.1.0",
"@types/zen-observable": "^0.8.0",
@@ -98,7 +98,7 @@ describe('UnregisterEntityDialog', () => {
},
);
userEvent.click(screen.getByText('Cancel'));
await userEvent.click(screen.getByText('Cancel'));
await waitFor(() => {
expect(onClose).toBeCalled();
@@ -187,13 +187,13 @@ describe('UnregisterEntityDialog', () => {
expect(screen.getByText(/You cannot unregister/)).toBeInTheDocument();
});
userEvent.click(screen.getByText('Advanced Options'));
await userEvent.click(screen.getByText('Advanced Options'));
await waitFor(() => {
expect(screen.getByText(/option to delete/)).toBeInTheDocument();
});
userEvent.click(screen.getByText('Delete Entity'));
await userEvent.click(screen.getByText('Delete Entity'));
await waitFor(() => {
expect(deleteEntity).toBeCalled();
@@ -233,7 +233,7 @@ describe('UnregisterEntityDialog', () => {
).toBeInTheDocument();
});
userEvent.click(screen.getByText('Delete Entity'));
await userEvent.click(screen.getByText('Delete Entity'));
await waitFor(() => {
expect(deleteEntity).toBeCalled();
@@ -281,7 +281,7 @@ describe('UnregisterEntityDialog', () => {
expect(screen.getByText(/k2:ns2\/n2/)).toBeInTheDocument();
});
userEvent.click(screen.getByText('Unregister Location'));
await userEvent.click(screen.getByText('Unregister Location'));
await waitFor(() => {
expect(unregisterLocation).toBeCalled();
@@ -329,7 +329,7 @@ describe('UnregisterEntityDialog', () => {
expect(screen.getByText(/k2:ns2\/n2/)).toBeInTheDocument();
});
userEvent.click(screen.getByText('Advanced Options'));
await userEvent.click(screen.getByText('Advanced Options'));
await waitFor(() => {
expect(
@@ -337,7 +337,7 @@ describe('UnregisterEntityDialog', () => {
).toBeInTheDocument();
});
userEvent.click(screen.getByText('Delete Entity'));
await userEvent.click(screen.getByText('Delete Entity'));
await waitFor(() => {
expect(deleteEntity).toBeCalled();
+1 -1
View File
@@ -67,7 +67,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"cross-fetch": "^3.1.5"
},
@@ -298,7 +298,7 @@ describe('<AboutCard />', () => {
'component:default/software',
);
userEvent.click(getByTitle('Schedule entity refresh'));
await userEvent.click(getByTitle('Schedule entity refresh'));
expect(catalogApi.refreshEntity).toHaveBeenCalledWith(
'component:default/software',
@@ -77,7 +77,7 @@ describe('DeleteEntityDialog', () => {
</Wrapper>,
);
userEvent.click(screen.getByText('Cancel'));
await userEvent.click(screen.getByText('Cancel'));
await waitFor(() => {
expect(onClose).toBeCalled();
@@ -98,7 +98,7 @@ describe('DeleteEntityDialog', () => {
</Wrapper>,
);
userEvent.click(screen.getByText('Delete'));
await userEvent.click(screen.getByText('Delete'));
await waitFor(() => {
expect(catalogClient.removeEntityByUid).toBeCalledWith('123');
@@ -121,7 +121,7 @@ describe('DeleteEntityDialog', () => {
);
catalogClient.removeEntityByUid.mockRejectedValue(new Error('no no no'));
userEvent.click(screen.getByText('Delete'));
await userEvent.click(screen.getByText('Delete'));
await waitFor(() => {
expect(catalogClient.removeEntityByUid).toBeCalledWith('123');
+1 -1
View File
@@ -61,7 +61,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/humanize-duration": "^3.25.1",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
+1 -1
View File
@@ -58,7 +58,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -45,7 +45,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/humanize-duration": "^3.27.1",
"@types/jest": "^26.0.7",
"@types/luxon": "^2.0.9",
+1 -1
View File
@@ -52,7 +52,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/highlightjs": "^10.1.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
+1 -1
View File
@@ -47,7 +47,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -66,7 +66,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/pluralize": "^0.0.29",
@@ -16,7 +16,7 @@
import React from 'react';
import { CostInsightsTabs } from './CostInsightsTabs';
import UserEvent from '@testing-library/user-event';
import userEvent from '@testing-library/user-event';
import { Group } from '../../types';
import { MockFilterProvider, MockLoadingProvider } from '../../testUtils';
import { renderInTestApp } from '@backstage/test-utils';
@@ -65,8 +65,8 @@ describe('<CostInsightsTabs />', () => {
const rendered = await renderWrapped(
<CostInsightsTabs groups={mockGroups} />,
);
UserEvent.click(rendered.getByTestId('cost-insights-groups-tab'));
UserEvent.click(rendered.getByTestId('test-group-1'));
await userEvent.click(rendered.getByTestId('cost-insights-groups-tab'));
await userEvent.click(rendered.getByTestId('test-group-1'));
expect(mockSetPageFilters).toHaveBeenCalledWith(selectedGroup);
});
@@ -74,7 +74,7 @@ describe('<CostInsightsTabs />', () => {
const rendered = await renderWrapped(
<CostInsightsTabs groups={mockGroups} />,
);
UserEvent.click(rendered.getByTestId('cost-insights-groups-tab'));
await userEvent.click(rendered.getByTestId('cost-insights-groups-tab'));
mockGroups.forEach(group =>
expect(rendered.getByText(group.id)).toBeInTheDocument(),
);
@@ -15,7 +15,7 @@
*/
import React from 'react';
import { waitFor } from '@testing-library/react';
import UserEvent from '@testing-library/user-event';
import userEvent from '@testing-library/user-event';
import { MetricSelect, MetricSelectProps } from './MetricSelect';
import { renderInTestApp } from '@backstage/test-utils';
@@ -46,7 +46,7 @@ describe('<MetricSelect />', () => {
);
const button = getByRole('button');
UserEvent.click(button);
await userEvent.click(button);
await waitFor(() => getAllByText(/None/));
@@ -17,7 +17,7 @@
import React from 'react';
import { getByRole, waitFor } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import UserEvent from '@testing-library/user-event';
import userEvent from '@testing-library/user-event';
import { PeriodSelect, getDefaultOptions } from './PeriodSelect';
import { getDefaultPageFilters } from '../../utils/filters';
import { MockBillingDateProvider } from '../../testUtils';
@@ -55,7 +55,7 @@ describe('<PeriodSelect />', () => {
);
const periodSelectContainer = rendered.getByTestId('period-select');
const button = getByRole(periodSelectContainer, 'button');
UserEvent.click(button);
await userEvent.click(button);
await waitFor(() => rendered.getByText('Past 60 Days'));
options.forEach(option =>
expect(
@@ -88,8 +88,10 @@ describe('<PeriodSelect />', () => {
const periodSelect = rendered.getByTestId('period-select');
const button = getByRole(periodSelect, 'button');
UserEvent.click(button);
UserEvent.click(rendered.getByTestId(`period-select-option-${duration}`));
await userEvent.click(button);
await userEvent.click(
rendered.getByTestId(`period-select-option-${duration}`),
);
expect(mockOnSelect).toHaveBeenLastCalledWith(duration);
});
});
@@ -16,7 +16,7 @@
import React from 'react';
import { getByRole, waitFor } from '@testing-library/react';
import UserEvent from '@testing-library/user-event';
import userEvent from '@testing-library/user-event';
import { ProjectSelect } from './ProjectSelect';
import { MockFilterProvider } from '../../testUtils';
import { renderInTestApp } from '@backstage/test-utils';
@@ -52,7 +52,7 @@ describe('<ProjectSelect />', () => {
'project-filter-select',
);
const button = getByRole(projectSelectContainer, 'button');
UserEvent.click(button);
await userEvent.click(button);
await waitFor(() => rendered.getByTestId('option-all'));
mockProjects.forEach(project =>
+1 -1
View File
@@ -41,7 +41,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -59,7 +59,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -45,7 +45,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -59,7 +59,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"msw": "^0.35.0"
+1 -1
View File
@@ -48,7 +48,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/dompurify": "^2.3.3",
"@types/gapi": "^0.0.41",
"@types/gapi.auth2": "^0.0.56",
+1 -1
View File
@@ -53,7 +53,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -50,7 +50,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/recharts": "^1.8.15",
+1 -1
View File
@@ -61,7 +61,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -49,7 +49,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -54,7 +54,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -55,7 +55,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/lodash": "^4.14.173",
"@types/luxon": "^2.0.4",
+1 -1
View File
@@ -54,7 +54,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/codemirror": "^0.0.108",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
+1 -1
View File
@@ -60,7 +60,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
@@ -46,7 +46,7 @@ describe('<ComponentTabs>', () => {
});
});
test('should switch tab on click', () => {
test('should switch tab on click', async () => {
const { getByText } = render(
<ComponentTabs
title="Random Jokes"
@@ -67,7 +67,7 @@ describe('<ComponentTabs>', () => {
display: 'none',
});
userEvent.click(getByText('TabB'));
await userEvent.click(getByText('TabB'));
expect(getByText('ContentA')).toHaveStyle({
display: 'none',
+1 -1
View File
@@ -49,7 +49,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -60,7 +60,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/testing-library__jest-dom": "^5.9.1",
+1 -1
View File
@@ -46,7 +46,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -64,7 +64,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -58,7 +58,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/react": "^16.13.1 || ^17.0.0",
+1 -1
View File
@@ -53,7 +53,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -55,7 +55,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -58,7 +58,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -48,7 +48,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/luxon": "^2.0.4",
"@types/node": "^14.14.32",
+1 -1
View File
@@ -60,7 +60,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"@types/react": "^16.13.1 || ^17.0.0",
+1 -1
View File
@@ -87,7 +87,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/humanize-duration": "^3.18.1",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
+1 -1
View File
@@ -63,7 +63,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
@@ -108,6 +108,7 @@ describe('SearchBar', () => {
});
it('Updates term state when text is entered', async () => {
const user = userEvent.setup({ delay: null });
jest.useFakeTimers();
const defaultDebounceTime = 200;
@@ -124,7 +125,7 @@ describe('SearchBar', () => {
const value = 'value';
userEvent.type(textbox, value);
await user.type(textbox, value);
act(() => {
jest.advanceTimersByTime(defaultDebounceTime);
@@ -137,6 +138,7 @@ describe('SearchBar', () => {
expect(query).toHaveBeenLastCalledWith(
expect.objectContaining({ term: value }),
);
jest.useRealTimers();
});
it('Clear button clears term state', async () => {
@@ -152,7 +154,7 @@ describe('SearchBar', () => {
expect(screen.getByRole('textbox', { name })).toHaveValue(term);
});
userEvent.click(screen.getByRole('button', { name: 'Clear' }));
await userEvent.click(screen.getByRole('button', { name: 'Clear' }));
await waitFor(() => {
expect(screen.getByRole('textbox', { name })).toHaveValue('');
@@ -172,12 +174,15 @@ describe('SearchBar', () => {
</ApiProvider>,
);
expect(
screen.queryByRole('button', { name: 'Clear' }),
).not.toBeInTheDocument();
await waitFor(() => {
expect(
screen.queryByRole('button', { name: 'Clear' }),
).not.toBeInTheDocument();
});
});
it('Adheres to provided debounceTime', async () => {
const user = userEvent.setup({ delay: null });
jest.useFakeTimers();
const debounceTime = 600;
@@ -199,7 +204,7 @@ describe('SearchBar', () => {
const value = 'value';
userEvent.type(textbox, value);
await user.type(textbox, value);
expect(query).not.toHaveBeenLastCalledWith(
expect.objectContaining({ term: value }),
@@ -208,17 +213,16 @@ describe('SearchBar', () => {
act(() => {
jest.advanceTimersByTime(debounceTime);
});
await waitFor(() => {
expect(textbox).toHaveValue(value);
});
expect(textbox).toHaveValue(value);
expect(query).toHaveBeenLastCalledWith(
expect.objectContaining({ term: value }),
);
jest.useRealTimers();
});
it('does not capture analytics event if not enabled in app', async () => {
const user = userEvent.setup({ delay: null });
jest.useFakeTimers();
const debounceTime = 600;
@@ -240,7 +244,7 @@ describe('SearchBar', () => {
const value = 'value';
userEvent.type(textbox, value);
await user.type(textbox, value);
act(() => {
jest.advanceTimersByTime(debounceTime);
@@ -249,9 +253,11 @@ describe('SearchBar', () => {
await waitFor(() => expect(textbox).toHaveValue(value));
expect(analyticsApiSpy.getEvents()).toHaveLength(0);
jest.useRealTimers();
});
it('captures analytics events if enabled in app', async () => {
const user = userEvent.setup({ delay: null });
jest.useFakeTimers();
const debounceTime = 600;
@@ -296,7 +302,7 @@ describe('SearchBar', () => {
const value = 'value';
userEvent.type(textbox, value);
await user.type(textbox, value);
expect(analyticsApiSpy.getEvents()).toHaveLength(0);
@@ -318,10 +324,10 @@ describe('SearchBar', () => {
subject: 'value',
});
userEvent.clear(textbox);
await user.clear(textbox);
// make sure new term is captured
userEvent.type(textbox, 'new value');
await user.type(textbox, 'new value');
act(() => {
jest.advanceTimersByTime(debounceTime);
@@ -340,5 +346,6 @@ describe('SearchBar', () => {
},
subject: 'new value',
});
jest.useRealTimers();
});
});
@@ -54,7 +54,7 @@ describe('SearchFilter.Autocomplete', () => {
const autocomplete = screen.getByRole('combobox');
const input = within(autocomplete).getByRole('textbox');
userEvent.click(input);
await userEvent.click(input);
await waitFor(() => {
screen.getByRole('listbox');
@@ -75,7 +75,7 @@ describe('SearchFilter.Autocomplete', () => {
const autocomplete = screen.getByRole('combobox');
const input = within(autocomplete).getByRole('textbox');
userEvent.click(input);
await userEvent.click(input);
await waitFor(() => {
screen.getByRole('listbox');
@@ -109,11 +109,11 @@ describe('SearchFilter.Autocomplete', () => {
// Select a value from the autocomplete filter.
const autocomplete = screen.getByRole('combobox');
const input = within(autocomplete).getByRole('textbox');
userEvent.click(input);
await userEvent.click(input);
await waitFor(() => {
screen.getByRole('listbox');
});
userEvent.click(screen.getByRole('option', { name: values[1] }));
await userEvent.click(screen.getByRole('option', { name: values[1] }));
// Wait for the autocomplete filter's value to change.
await waitFor(() => {
@@ -193,11 +193,11 @@ describe('SearchFilter.Autocomplete', () => {
// Select the first option in the autocomplete.
const autocomplete = screen.getByRole('combobox');
const input = within(autocomplete).getByRole('textbox');
userEvent.click(input);
await userEvent.click(input);
await waitFor(() => {
screen.getByRole('listbox');
});
userEvent.click(screen.getByRole('option', { name: values[0] }));
await userEvent.click(screen.getByRole('option', { name: values[0] }));
// The value should be present in the context.
await waitFor(() => {
@@ -208,7 +208,7 @@ describe('SearchFilter.Autocomplete', () => {
// Click the "Clear" button to remove the value.
const clearButton = within(autocomplete).getByLabelText('Clear');
userEvent.click(clearButton);
await userEvent.click(clearButton);
// That value should have been unset from the context.
await waitFor(() => {
@@ -284,11 +284,11 @@ describe('SearchFilter.Autocomplete', () => {
const input = within(autocomplete).getByRole('textbox');
// Select the second value.
userEvent.click(input);
await userEvent.click(input);
await waitFor(() => {
screen.getByRole('listbox');
});
userEvent.click(screen.getByRole('option', { name: values[1] }));
await userEvent.click(screen.getByRole('option', { name: values[1] }));
await waitFor(() => {
expect(
screen.getByRole('button', { name: values[1] }),
@@ -296,11 +296,11 @@ describe('SearchFilter.Autocomplete', () => {
});
// Select the first value.
userEvent.click(input);
await userEvent.click(input);
await waitFor(() => {
screen.getByRole('listbox');
});
userEvent.click(screen.getByRole('option', { name: values[0] }));
await userEvent.click(screen.getByRole('option', { name: values[0] }));
await waitFor(() => {
expect(
screen.getByRole('button', { name: values[0] }),
@@ -329,16 +329,16 @@ describe('SearchFilter.Autocomplete', () => {
// Select both values in the autocomplete.
const input = within(autocomplete).getByRole('textbox');
userEvent.click(input);
await userEvent.click(input);
await waitFor(() => {
screen.getByRole('listbox');
});
userEvent.click(screen.getByRole('option', { name: values[0] }));
userEvent.click(input);
await userEvent.click(screen.getByRole('option', { name: values[0] }));
await userEvent.click(input);
await waitFor(() => {
screen.getByRole('listbox');
});
userEvent.click(screen.getByRole('option', { name: values[1] }));
await userEvent.click(screen.getByRole('option', { name: values[1] }));
// Both options should be present in the context.
await waitFor(() => {
@@ -349,7 +349,7 @@ describe('SearchFilter.Autocomplete', () => {
// Click the "Clear" button to remove the value.
const clearButton = within(autocomplete).getByLabelText('Clear');
userEvent.click(clearButton);
await userEvent.click(clearButton);
// There should be no content in the filter context.
await waitFor(() => {
@@ -134,7 +134,7 @@ describe('SearchFilter', () => {
const checkBox = screen.getByRole('checkbox', { name: values[0] });
// Check the box.
userEvent.click(checkBox);
await userEvent.click(checkBox);
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
expect.objectContaining({ filters: { field: [values[0]] } }),
@@ -142,7 +142,7 @@ describe('SearchFilter', () => {
});
// Uncheck the box.
userEvent.click(checkBox);
await userEvent.click(checkBox);
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
expect.objectContaining({ filters: {} }),
@@ -164,7 +164,7 @@ describe('SearchFilter', () => {
const checkBox = screen.getByRole('checkbox', { name: values[0] });
// Check the box.
userEvent.click(checkBox);
await userEvent.click(checkBox);
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
expect.objectContaining({
@@ -174,7 +174,7 @@ describe('SearchFilter', () => {
});
// Uncheck the box.
userEvent.click(checkBox);
await userEvent.click(checkBox);
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
expect.objectContaining({ filters }),
@@ -195,7 +195,7 @@ describe('SearchFilter', () => {
expect(screen.getByText(label)).toBeInTheDocument();
});
userEvent.click(screen.getByRole('button'));
await userEvent.click(screen.getByRole('button'));
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
@@ -227,7 +227,7 @@ describe('SearchFilter', () => {
).not.toBe('true');
});
userEvent.click(screen.getByRole('button'));
await userEvent.click(screen.getByRole('button'));
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
@@ -259,7 +259,7 @@ describe('SearchFilter', () => {
expect(screen.getByText(label)).toBeInTheDocument();
});
userEvent.click(screen.getByRole('button'));
await userEvent.click(screen.getByRole('button'));
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
@@ -293,7 +293,7 @@ describe('SearchFilter', () => {
expect(screen.getByText(label)).toBeInTheDocument();
});
userEvent.click(screen.getByRole('button'));
await userEvent.click(screen.getByRole('button'));
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
@@ -324,13 +324,13 @@ describe('SearchFilter', () => {
const button = screen.getByRole('button');
userEvent.click(button);
await userEvent.click(button);
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
});
userEvent.click(screen.getByRole('option', { name: values[0] }));
await userEvent.click(screen.getByRole('option', { name: values[0] }));
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
@@ -340,13 +340,13 @@ describe('SearchFilter', () => {
);
});
userEvent.click(button);
await userEvent.click(button);
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
});
userEvent.click(screen.getByRole('option', { name: 'All' }));
await userEvent.click(screen.getByRole('option', { name: 'All' }));
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
@@ -375,13 +375,13 @@ describe('SearchFilter', () => {
const button = screen.getByRole('button');
userEvent.click(button);
await userEvent.click(button);
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
});
userEvent.click(screen.getByRole('option', { name: values[0] }));
await userEvent.click(screen.getByRole('option', { name: values[0] }));
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
@@ -391,13 +391,13 @@ describe('SearchFilter', () => {
);
});
userEvent.click(button);
await userEvent.click(button);
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
});
userEvent.click(screen.getByRole('option', { name: 'All' }));
await userEvent.click(screen.getByRole('option', { name: 'All' }));
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
@@ -68,7 +68,7 @@ describe('SearchModal', () => {
);
expect(query).toHaveBeenCalledTimes(1);
userEvent.keyboard('{esc}');
await userEvent.keyboard('{Escape}');
expect(toggleModal).toHaveBeenCalledTimes(1);
});
@@ -42,17 +42,14 @@ describe('SearchResultPager', () => {
await waitFor(() => {
expect(getByLabelText('previous page')).toBeInTheDocument();
userEvent.click(getByLabelText('previous page'));
});
await userEvent.click(getByLabelText('previous page'));
expect(fetchPreviousPage).toBeCalled();
await waitFor(() => {
expect(getByLabelText('next page')).toBeInTheDocument();
userEvent.click(getByLabelText('next page'));
});
await userEvent.click(getByLabelText('next page'));
expect(fetchNextPage).toBeCalled();
});
@@ -78,19 +78,19 @@ describe('SearchType.Accordion', () => {
await act(() => Promise.resolve());
});
it('should set entire types array when a type is selected', () => {
it('should set entire types array when a type is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Accordion name={expectedLabel} types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(contextSpy.setTypes).toHaveBeenCalledWith([expectedType.value]);
});
it('should reset types array when all is selected', () => {
it('should reset types array when all is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Accordion
@@ -101,31 +101,31 @@ describe('SearchType.Accordion', () => {
</SearchContext.Provider>,
);
user.click(getByText('All'));
await user.click(getByText('All'));
expect(contextSpy.setTypes).toHaveBeenCalledWith([]);
});
it('should reset page cursor when a new type is selected', () => {
it('should reset page cursor when a new type is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Accordion name={expectedLabel} types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(contextSpy.setPageCursor).toHaveBeenCalledWith(undefined);
});
it('should collapse when a new type is selected', () => {
it('should collapse when a new type is selected', async () => {
const { getByText, queryByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Accordion name={expectedLabel} types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(queryByText('Collapse')).not.toBeInTheDocument();
});
@@ -70,19 +70,19 @@ describe('SearchType.Tabs', () => {
await act(() => Promise.resolve());
});
it('should set entire types array when a type is selected', () => {
it('should set entire types array when a type is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Tabs types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(contextSpy.setTypes).toHaveBeenCalledWith([expectedType.value]);
});
it('should reset types array when all is selected', () => {
it('should reset types array when all is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Tabs
@@ -92,19 +92,19 @@ describe('SearchType.Tabs', () => {
</SearchContext.Provider>,
);
user.click(getByText('All'));
await user.click(getByText('All'));
expect(contextSpy.setTypes).toHaveBeenCalledWith([]);
});
it('should reset page cursor when a new type is selected', () => {
it('should reset page cursor when a new type is selected', async () => {
const { getByText } = render(
<SearchContext.Provider value={contextSpy}>
<SearchType.Tabs types={[expectedType]} />
</SearchContext.Provider>,
);
user.click(getByText(expectedType.name));
await user.click(getByText(expectedType.name));
expect(contextSpy.setPageCursor).toHaveBeenCalledWith(undefined);
});
@@ -56,7 +56,7 @@ describe('SearchType', () => {
expect(screen.getByText(name)).toBeInTheDocument();
});
userEvent.click(screen.getByRole('button'));
await userEvent.click(screen.getByRole('button'));
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
@@ -86,7 +86,7 @@ describe('SearchType', () => {
expect(screen.getByText(name)).toBeInTheDocument();
});
userEvent.click(screen.getByRole('button'));
await userEvent.click(screen.getByRole('button'));
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
@@ -112,7 +112,7 @@ describe('SearchType', () => {
expect(screen.getByText(name)).toBeInTheDocument();
});
userEvent.click(screen.getByRole('button'));
await userEvent.click(screen.getByRole('button'));
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
@@ -140,13 +140,13 @@ describe('SearchType', () => {
const button = screen.getByRole('button');
userEvent.click(button);
await userEvent.click(button);
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
});
userEvent.click(screen.getByRole('option', { name: values[0] }));
await userEvent.click(screen.getByRole('option', { name: values[0] }));
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
@@ -156,7 +156,7 @@ describe('SearchType', () => {
);
});
userEvent.click(button);
await userEvent.click(button);
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
@@ -181,13 +181,13 @@ describe('SearchType', () => {
const button = screen.getByRole('button');
userEvent.click(button);
await userEvent.click(button);
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
});
userEvent.click(screen.getByRole('option', { name: values[0] }));
await userEvent.click(screen.getByRole('option', { name: values[0] }));
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(
@@ -197,13 +197,13 @@ describe('SearchType', () => {
);
});
userEvent.click(button);
await userEvent.click(button);
await waitFor(() => {
expect(screen.getByRole('listbox')).toBeInTheDocument();
});
userEvent.click(screen.getByRole('option', { name: values[0] }));
await userEvent.click(screen.getByRole('option', { name: values[0] }));
await waitFor(() => {
expect(query).toHaveBeenLastCalledWith(expect.objectContaining([]));
+1 -1
View File
@@ -59,7 +59,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/luxon": "^2.0.4",
"@types/node": "^14.14.32",
+1 -1
View File
@@ -48,7 +48,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -59,7 +59,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"msw": "^0.35.0"
+1 -1
View File
@@ -57,7 +57,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/luxon": "^2.0.4",
"@types/node": "^14.14.32",
+1 -1
View File
@@ -47,7 +47,7 @@
"@backstage/dev-utils": "^1.0.1-next.0",
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"msw": "^0.35.0"
+1 -1
View File
@@ -53,7 +53,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -55,7 +55,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/color": "^3.0.1",
"@types/d3-force": "^2.1.1",
"@types/jest": "^26.0.7",
@@ -61,7 +61,7 @@ describe('RadarEntry', () => {
expect(screen.getByText(String(minProps.value))).toBeInTheDocument();
});
it('should render with description', () => {
it('should render with description', async () => {
render(
<ThemeProvider theme={lightTheme}>
<svg>
@@ -70,7 +70,7 @@ describe('RadarEntry', () => {
</ThemeProvider>,
);
userEvent.click(screen.getByRole('button'));
await userEvent.click(screen.getByRole('button'));
const radarEntry = screen.getByTestId('radar-entry');
expect(radarEntry).toBeInTheDocument();
+1 -1
View File
@@ -71,7 +71,7 @@
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/dompurify": "^2.2.2",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
+1 -1
View File
@@ -51,7 +51,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -53,7 +53,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32",
"cross-fetch": "^3.1.5",
+1 -1
View File
@@ -46,7 +46,7 @@
"@backstage/test-utils": "^1.0.1-next.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.1.8",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/luxon": "^2.0.4",
"@types/node": "^14.14.32",
@@ -45,7 +45,7 @@ describe('Accordion', () => {
expect(rendered.getByText('Content')).not.toBeVisible();
userEvent.click(rendered.getByRole('button'));
await userEvent.click(rendered.getByRole('button'));
expect(await rendered.findByText('Content')).toBeVisible();
});
});
@@ -52,8 +52,10 @@ describe('BuildList', () => {
</TestApiProvider>,
);
userEvent.click(
(await rendered.findAllByLabelText('Detail panel visiblity toggle'))[0],
await userEvent.click(
(
await rendered.findAllByLabelText('Detail panel visiblity toggle')
)[0],
);
expect(await rendered.findByText('BuildDetails')).toBeInTheDocument();
});
@@ -44,21 +44,21 @@ const renderWithFiltersVisible = async (
</TestApiProvider>,
);
userEvent.click(rendered.getByLabelText('show filters'));
await userEvent.click(rendered.getByLabelText('show filters'));
return rendered;
};
const setStatusFilter = async (rendered: RenderResult, option: string) => {
const statusSelect = rendered.getAllByTestId('select')[0];
userEvent.click(statusSelect);
userEvent.click((await rendered.findAllByText(option))[0]);
await userEvent.click(statusSelect);
await userEvent.click((await rendered.findAllByText(option))[0]);
};
const setProjectFilter = async (rendered: RenderResult, option: string) => {
const statusSelect = rendered.getAllByTestId('select')[1];
userEvent.click(statusSelect);
await userEvent.click(statusSelect);
const options = await rendered.findAllByText(option);
userEvent.click(options[options.length - 1]);
await userEvent.click(options[options.length - 1]);
};
describe('BuildListFilter', () => {
@@ -82,7 +82,7 @@ describe('BuildListFilter', () => {
expect(await rendered.findByText('Status')).toBeInTheDocument();
expect(await rendered.findByText('Project')).toBeInTheDocument();
userEvent.click(rendered.getByLabelText('hide filters'));
await userEvent.click(rendered.getByLabelText('hide filters'));
expect(rendered.queryByText('DatePicker')).toBeNull();
expect(rendered.queryByText('Status')).toBeNull();
expect(rendered.queryByText('Project')).toBeNull();
@@ -91,7 +91,7 @@ describe('BuildListFilter', () => {
it('should load projects', async () => {
const callback = jest.fn();
const rendered = await renderWithFiltersVisible(callback);
userEvent.click((await rendered.findAllByText('All'))[1]);
await userEvent.click((await rendered.findAllByText('All'))[1]);
expect(
await rendered.findByText(client.mockBuild.projectName),
@@ -143,7 +143,7 @@ describe('BuildListFilter', () => {
await setProjectFilter(rendered, client.mockBuild.projectName);
callback.mockClear();
userEvent.click(await rendered.findByText('Clear all'));
await userEvent.click(await rendered.findByText('Clear all'));
expect(callback).toHaveBeenCalledWith(initialValues);
expect(await rendered.findByText('Filters (0)')).toBeInTheDocument();
@@ -33,7 +33,7 @@ describe('DatePicker', () => {
);
const input = rendered.getByLabelText(label);
userEvent.type(input, '2020-02-02');
await userEvent.type(input, '2020-02-02');
expect(callback).toBeCalledWith('2020-02-02');
});
@@ -45,7 +45,7 @@ describe('DatePicker', () => {
);
const input = rendered.getByLabelText(label);
userEvent.type(input, 'test');
await userEvent.type(input, 'test');
expect(callback).not.toHaveBeenCalled();
});
});
@@ -53,8 +53,8 @@ describe('OverviewTrends', () => {
</TestApiProvider>,
);
userEvent.click(rendered.getByText('14 days'));
userEvent.click(await rendered.findByText('30 days'));
await userEvent.click(rendered.getByText('14 days'));
await userEvent.click(await rendered.findByText('30 days'));
expect(await rendered.findByText('30 days')).toBeInTheDocument();
});
@@ -38,7 +38,7 @@ describe('StatusCell', () => {
</TestApiProvider>,
);
userEvent.hover(rendered.getByTestId(client.mockBuild.id));
await userEvent.hover(rendered.getByTestId(client.mockBuild.id));
expect(
await rendered.findByText(formatStatus(client.mockBuild.buildStatus)),
).toBeInTheDocument();
@@ -51,7 +51,7 @@ describe('XcmetricsLayout', () => {
</TestApiProvider>,
);
userEvent.click(rendered.getByText('Builds'));
await userEvent.click(rendered.getByText('Builds'));
expect(await rendered.findByText('BuildList')).toBeInTheDocument();
});
});