some more progress toward ubiquitous eslint-plugin-testing-library
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
+184
-172
@@ -50,179 +50,191 @@ module.exports = {
|
||||
'testing-library/no-await-sync-query': 'error',
|
||||
'testing-library/prefer-wait-for': 'error',
|
||||
'testing-library/no-dom-import': 'error',
|
||||
'testing-library/no-wait-for-side-effects': 'error',
|
||||
'testing-library/no-wait-for-empty-callback': 'error',
|
||||
'no-restricted-globals': [
|
||||
'error',
|
||||
'postMessage',
|
||||
'blur',
|
||||
'focus',
|
||||
'close',
|
||||
'frames',
|
||||
'self',
|
||||
'parent',
|
||||
'opener',
|
||||
'top',
|
||||
'length',
|
||||
'closed',
|
||||
'location',
|
||||
'origin',
|
||||
'name',
|
||||
'locationbar',
|
||||
'menubar',
|
||||
'personalbar',
|
||||
'scrollbars',
|
||||
'statusbar',
|
||||
'toolbar',
|
||||
'status',
|
||||
'frameElement',
|
||||
'navigator',
|
||||
'customElements',
|
||||
'external',
|
||||
'screen',
|
||||
'innerWidth',
|
||||
'innerHeight',
|
||||
'scrollX',
|
||||
'pageXOffset',
|
||||
'scrollY',
|
||||
'pageYOffset',
|
||||
'screenX',
|
||||
'screenY',
|
||||
'outerWidth',
|
||||
'outerHeight',
|
||||
'devicePixelRatio',
|
||||
'clientInformation',
|
||||
'screenLeft',
|
||||
'screenTop',
|
||||
'defaultStatus',
|
||||
'defaultstatus',
|
||||
'styleMedia',
|
||||
'onanimationend',
|
||||
'onanimationiteration',
|
||||
'onanimationstart',
|
||||
'onsearch',
|
||||
'ontransitionend',
|
||||
'onwebkitanimationend',
|
||||
'onwebkitanimationiteration',
|
||||
'onwebkitanimationstart',
|
||||
'onwebkittransitionend',
|
||||
'isSecureContext',
|
||||
'onabort',
|
||||
'onblur',
|
||||
'oncancel',
|
||||
'oncanplay',
|
||||
'oncanplaythrough',
|
||||
'onchange',
|
||||
'onclick',
|
||||
'onclose',
|
||||
'oncontextmenu',
|
||||
'oncuechange',
|
||||
'ondblclick',
|
||||
'ondrag',
|
||||
'ondragend',
|
||||
'ondragenter',
|
||||
'ondragleave',
|
||||
'ondragover',
|
||||
'ondragstart',
|
||||
'ondrop',
|
||||
'ondurationchange',
|
||||
'onemptied',
|
||||
'onended',
|
||||
'onerror',
|
||||
'onfocus',
|
||||
'oninput',
|
||||
'oninvalid',
|
||||
'onkeydown',
|
||||
'onkeypress',
|
||||
'onkeyup',
|
||||
'onload',
|
||||
'onloadeddata',
|
||||
'onloadedmetadata',
|
||||
'onloadstart',
|
||||
'onmousedown',
|
||||
'onmouseenter',
|
||||
'onmouseleave',
|
||||
'onmousemove',
|
||||
'onmouseout',
|
||||
'onmouseover',
|
||||
'onmouseup',
|
||||
'onmousewheel',
|
||||
'onpause',
|
||||
'onplay',
|
||||
'onplaying',
|
||||
'onprogress',
|
||||
'onratechange',
|
||||
'onreset',
|
||||
'onresize',
|
||||
'onscroll',
|
||||
'onseeked',
|
||||
'onseeking',
|
||||
'onselect',
|
||||
'onstalled',
|
||||
'onsubmit',
|
||||
'onsuspend',
|
||||
'ontimeupdate',
|
||||
'ontoggle',
|
||||
'onvolumechange',
|
||||
'onwaiting',
|
||||
'onwheel',
|
||||
'onauxclick',
|
||||
'ongotpointercapture',
|
||||
'onlostpointercapture',
|
||||
'onpointerdown',
|
||||
'onpointermove',
|
||||
'onpointerup',
|
||||
'onpointercancel',
|
||||
'onpointerover',
|
||||
'onpointerout',
|
||||
'onpointerenter',
|
||||
'onpointerleave',
|
||||
'onafterprint',
|
||||
'onbeforeprint',
|
||||
'onbeforeunload',
|
||||
'onhashchange',
|
||||
'onlanguagechange',
|
||||
'onmessage',
|
||||
'onmessageerror',
|
||||
'onoffline',
|
||||
'ononline',
|
||||
'onpagehide',
|
||||
'onpageshow',
|
||||
'onpopstate',
|
||||
'onrejectionhandled',
|
||||
'onstorage',
|
||||
'onunhandledrejection',
|
||||
'onunload',
|
||||
'performance',
|
||||
'stop',
|
||||
'open',
|
||||
'print',
|
||||
'captureEvents',
|
||||
'releaseEvents',
|
||||
'getComputedStyle',
|
||||
'matchMedia',
|
||||
'moveTo',
|
||||
'moveBy',
|
||||
'resizeTo',
|
||||
'resizeBy',
|
||||
'getSelection',
|
||||
'find',
|
||||
'createImageBitmap',
|
||||
'scroll',
|
||||
'scrollTo',
|
||||
'scrollBy',
|
||||
'onappinstalled',
|
||||
'onbeforeinstallprompt',
|
||||
'crypto',
|
||||
'ondevicemotion',
|
||||
'ondeviceorientation',
|
||||
'ondeviceorientationabsolute',
|
||||
'indexedDB',
|
||||
'webkitStorageInfo',
|
||||
'chrome',
|
||||
'visualViewport',
|
||||
'speechSynthesis',
|
||||
'webkitRequestFileSystem',
|
||||
'webkitResolveLocalFileSystemURL',
|
||||
'openDatabase',
|
||||
],
|
||||
[
|
||||
'blur',
|
||||
'captureEvents',
|
||||
'chrome',
|
||||
'clientInformation',
|
||||
'close',
|
||||
'closed',
|
||||
'createImageBitmap',
|
||||
'crypto',
|
||||
'customElements',
|
||||
'defaultstatus',
|
||||
'defaultStatus',
|
||||
'devicePixelRatio',
|
||||
'external',
|
||||
'find',
|
||||
'focus',
|
||||
'frameElement',
|
||||
'frames',
|
||||
'getComputedStyle',
|
||||
'getSelection',
|
||||
'indexedDB',
|
||||
'innerHeight',
|
||||
'innerWidth',
|
||||
'isSecureContext',
|
||||
'length',
|
||||
'location',
|
||||
'locationbar',
|
||||
'matchMedia',
|
||||
'menubar',
|
||||
'moveBy',
|
||||
'moveTo',
|
||||
'name',
|
||||
'navigator',
|
||||
'onabort',
|
||||
'onafterprint',
|
||||
'onanimationend',
|
||||
'onanimationiteration',
|
||||
'onanimationstart',
|
||||
'onappinstalled',
|
||||
'onauxclick',
|
||||
'onbeforeinstallprompt',
|
||||
'onbeforeprint',
|
||||
'onbeforeunload',
|
||||
'onblur',
|
||||
'oncancel',
|
||||
'oncanplay',
|
||||
'oncanplaythrough',
|
||||
'onchange',
|
||||
'onclick',
|
||||
'onclose',
|
||||
'oncontextmenu',
|
||||
'oncuechange',
|
||||
'ondblclick',
|
||||
'ondevicemotion',
|
||||
'ondeviceorientation',
|
||||
'ondeviceorientationabsolute',
|
||||
'ondrag',
|
||||
'ondragend',
|
||||
'ondragenter',
|
||||
'ondragleave',
|
||||
'ondragover',
|
||||
'ondragstart',
|
||||
'ondrop',
|
||||
'ondurationchange',
|
||||
'onemptied',
|
||||
'onended',
|
||||
'onerror',
|
||||
'onfocus',
|
||||
'ongotpointercapture',
|
||||
'onhashchange',
|
||||
'oninput',
|
||||
'oninvalid',
|
||||
'onkeydown',
|
||||
'onkeypress',
|
||||
'onkeyup',
|
||||
'onlanguagechange',
|
||||
'onload',
|
||||
'onloadeddata',
|
||||
'onloadedmetadata',
|
||||
'onloadstart',
|
||||
'onlostpointercapture',
|
||||
'onmessage',
|
||||
'onmessageerror',
|
||||
'onmousedown',
|
||||
'onmouseenter',
|
||||
'onmouseleave',
|
||||
'onmousemove',
|
||||
'onmouseout',
|
||||
'onmouseover',
|
||||
'onmouseup',
|
||||
'onmousewheel',
|
||||
'onoffline',
|
||||
'ononline',
|
||||
'onpagehide',
|
||||
'onpageshow',
|
||||
'onpause',
|
||||
'onplay',
|
||||
'onplaying',
|
||||
'onpointercancel',
|
||||
'onpointerdown',
|
||||
'onpointerenter',
|
||||
'onpointerleave',
|
||||
'onpointermove',
|
||||
'onpointerout',
|
||||
'onpointerover',
|
||||
'onpointerup',
|
||||
'onpopstate',
|
||||
'onprogress',
|
||||
'onratechange',
|
||||
'onrejectionhandled',
|
||||
'onreset',
|
||||
'onresize',
|
||||
'onscroll',
|
||||
'onsearch',
|
||||
'onseeked',
|
||||
'onseeking',
|
||||
'onselect',
|
||||
'onstalled',
|
||||
'onstorage',
|
||||
'onsubmit',
|
||||
'onsuspend',
|
||||
'ontimeupdate',
|
||||
'ontoggle',
|
||||
'ontransitionend',
|
||||
'onunhandledrejection',
|
||||
'onunload',
|
||||
'onvolumechange',
|
||||
'onwaiting',
|
||||
'onwebkitanimationend',
|
||||
'onwebkitanimationiteration',
|
||||
'onwebkitanimationstart',
|
||||
'onwebkittransitionend',
|
||||
'onwheel',
|
||||
'open',
|
||||
'openDatabase',
|
||||
'opener',
|
||||
'origin',
|
||||
'outerHeight',
|
||||
'outerWidth',
|
||||
'pageXOffset',
|
||||
'pageYOffset',
|
||||
'parent',
|
||||
'performance',
|
||||
'personalbar',
|
||||
'postMessage',
|
||||
'print',
|
||||
'releaseEvents',
|
||||
'resizeBy',
|
||||
'resizeTo',
|
||||
'screen',
|
||||
'screenLeft',
|
||||
'screenTop',
|
||||
'screenX',
|
||||
'screenY',
|
||||
'scroll',
|
||||
'scrollbars',
|
||||
'scrollBy',
|
||||
'scrollTo',
|
||||
'scrollX',
|
||||
'scrollY',
|
||||
'self',
|
||||
'speechSynthesis',
|
||||
'status',
|
||||
'statusbar',
|
||||
'stop',
|
||||
'styleMedia',
|
||||
'toolbar',
|
||||
'top',
|
||||
'visualViewport',
|
||||
'webkitRequestFileSystem',
|
||||
'webkitResolveLocalFileSystemURL',
|
||||
'webkitStorageInfo',
|
||||
].map(function f(name) {
|
||||
return {
|
||||
name: name,
|
||||
message:
|
||||
'Avoid using implicitly global variables. Use e.g. window.' +
|
||||
name +
|
||||
' instead if this was your intent.',
|
||||
};
|
||||
}),
|
||||
].flat(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import React from 'react';
|
||||
import { FeatureFlagged } from './FeatureFlagged';
|
||||
import { render } from '@testing-library/react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { LocalStorageFeatureFlags } from '../apis';
|
||||
import { TestApiProvider } from '@backstage/test-utils';
|
||||
import { featureFlagsApiRef } from '@backstage/core-plugin-api';
|
||||
@@ -35,7 +35,7 @@ describe('FeatureFlagged', () => {
|
||||
.spyOn(mockFeatureFlagsApi, 'isActive')
|
||||
.mockImplementation(() => true);
|
||||
|
||||
const { queryByText } = render(
|
||||
render(
|
||||
<Wrapper>
|
||||
<div>
|
||||
<FeatureFlagged with="hello-flag">
|
||||
@@ -45,14 +45,14 @@ describe('FeatureFlagged', () => {
|
||||
</Wrapper>,
|
||||
);
|
||||
|
||||
expect(queryByText('BACKSTAGE!')).toBeInTheDocument();
|
||||
expect(screen.getByText('BACKSTAGE!')).toBeInTheDocument();
|
||||
});
|
||||
it('should not render contents when the feature flag is disabled', async () => {
|
||||
jest
|
||||
.spyOn(mockFeatureFlagsApi, 'isActive')
|
||||
.mockImplementation(() => false);
|
||||
|
||||
const { queryByText } = render(
|
||||
render(
|
||||
<Wrapper>
|
||||
<div>
|
||||
<FeatureFlagged with="hello-flag">
|
||||
@@ -62,7 +62,7 @@ describe('FeatureFlagged', () => {
|
||||
</Wrapper>,
|
||||
);
|
||||
|
||||
expect(queryByText('BACKSTAGE!')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('BACKSTAGE!')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
describe('without', () => {
|
||||
@@ -71,7 +71,7 @@ describe('FeatureFlagged', () => {
|
||||
.spyOn(mockFeatureFlagsApi, 'isActive')
|
||||
.mockImplementation(() => true);
|
||||
|
||||
const { queryByText } = render(
|
||||
render(
|
||||
<Wrapper>
|
||||
<div>
|
||||
<FeatureFlagged without="hello-flag">
|
||||
@@ -81,14 +81,14 @@ describe('FeatureFlagged', () => {
|
||||
</Wrapper>,
|
||||
);
|
||||
|
||||
expect(queryByText('BACKSTAGE!')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('BACKSTAGE!')).not.toBeInTheDocument();
|
||||
});
|
||||
it('should render contents when the feature flag is disabled', async () => {
|
||||
jest
|
||||
.spyOn(mockFeatureFlagsApi, 'isActive')
|
||||
.mockImplementation(() => false);
|
||||
|
||||
const { queryByText } = render(
|
||||
render(
|
||||
<Wrapper>
|
||||
<div>
|
||||
<FeatureFlagged without="hello-flag">
|
||||
@@ -98,7 +98,7 @@ describe('FeatureFlagged', () => {
|
||||
</Wrapper>,
|
||||
);
|
||||
|
||||
expect(queryByText('BACKSTAGE!')).toBeInTheDocument();
|
||||
expect(screen.getByText('BACKSTAGE!')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { AlertDisplay } from './AlertDisplay';
|
||||
import { alertApiRef } from '@backstage/core-plugin-api';
|
||||
import { AlertApiForwarder } from '@backstage/core-app-api';
|
||||
@@ -34,7 +35,7 @@ describe('<AlertDisplay />', () => {
|
||||
});
|
||||
|
||||
it('renders with message', async () => {
|
||||
const { queryByText } = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
[
|
||||
@@ -52,7 +53,7 @@ describe('<AlertDisplay />', () => {
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
expect(queryByText(TEST_MESSAGE)).toBeInTheDocument();
|
||||
expect(screen.getByText(TEST_MESSAGE)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('with multiple messages', () => {
|
||||
@@ -73,23 +74,23 @@ describe('<AlertDisplay />', () => {
|
||||
] as const;
|
||||
|
||||
it('renders first message', async () => {
|
||||
const { queryByText } = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<TestApiProvider apis={apis}>
|
||||
<AlertDisplay />
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
expect(queryByText('message one')).toBeInTheDocument();
|
||||
expect(screen.getByText('message one')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a count of remaining messages', async () => {
|
||||
const { queryByText } = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<TestApiProvider apis={apis}>
|
||||
<AlertDisplay />
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
expect(queryByText('(2 older messages)')).toBeInTheDocument();
|
||||
expect(screen.getByText('(2 older messages)')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -60,11 +60,11 @@ describe('RealLogViewer', () => {
|
||||
await userEvent.keyboard('{shift>}{enter}{/shift}');
|
||||
expect(rendered.getByText('3/3')).toBeInTheDocument();
|
||||
|
||||
expect(rendered.queryByText('Some Log Line')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Some Log Line')).toBeInTheDocument();
|
||||
await userEvent.keyboard('{meta>}{enter}{/meta}');
|
||||
expect(rendered.queryByText('Some Log Line')).not.toBeInTheDocument();
|
||||
await userEvent.keyboard('{meta>}{enter}{/meta}');
|
||||
expect(rendered.queryByText('Some Log Line')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Some Log Line')).toBeInTheDocument();
|
||||
|
||||
// Tab down to line #2 and click
|
||||
await userEvent.tab();
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { fireEvent, screen } from '@testing-library/react';
|
||||
import { configApiRef } from '@backstage/core-plugin-api';
|
||||
import {
|
||||
MockConfigApi,
|
||||
renderInTestApp,
|
||||
TestApiProvider,
|
||||
} from '@backstage/test-utils';
|
||||
import { act, fireEvent, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { SupportButton } from './SupportButton';
|
||||
import { configApiRef } from '@backstage/core-plugin-api';
|
||||
|
||||
const configApi = new MockConfigApi({
|
||||
app: {
|
||||
@@ -45,8 +45,9 @@ const POPOVER_ID = 'support-button-popover';
|
||||
describe('<SupportButton />', () => {
|
||||
it('renders without exploding', async () => {
|
||||
await renderInTestApp(<SupportButton />);
|
||||
|
||||
expect(screen.getByTestId(SUPPORT_BUTTON_ID)).toBeInTheDocument();
|
||||
await expect(
|
||||
screen.findByTestId(SUPPORT_BUTTON_ID),
|
||||
).resolves.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('supports passing a title', async () => {
|
||||
@@ -96,11 +97,13 @@ describe('<SupportButton />', () => {
|
||||
it('shows popover on click', async () => {
|
||||
await renderInTestApp(<SupportButton />);
|
||||
|
||||
const supportButton = screen.getByTestId(SUPPORT_BUTTON_ID);
|
||||
expect(supportButton).toBeInTheDocument();
|
||||
await expect(
|
||||
screen.findByTestId(SUPPORT_BUTTON_ID),
|
||||
).resolves.toBeInTheDocument();
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByTestId(SUPPORT_BUTTON_ID));
|
||||
});
|
||||
|
||||
fireEvent.click(supportButton);
|
||||
|
||||
expect(screen.getByTestId(POPOVER_ID)).toBeInTheDocument();
|
||||
await expect(screen.findByTestId(POPOVER_ID)).resolves.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { act, fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
@@ -65,14 +66,14 @@ describe('RoutedTabs', () => {
|
||||
expect(rendered.queryByText('tabbed-test-content')).not.toBeInTheDocument();
|
||||
|
||||
expect(rendered.getByText('tabbed-test-title-2')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
expect(rendered.getByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
|
||||
const thirdTab = rendered.queryAllByRole('tab')[2];
|
||||
act(() => {
|
||||
fireEvent.click(thirdTab);
|
||||
});
|
||||
expect(rendered.getByText('tabbed-test-title-3')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('tabbed-test-content-3')).toBeInTheDocument();
|
||||
expect(rendered.getByText('tabbed-test-content-3')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('correctly delegates nested links', () => {
|
||||
@@ -113,9 +114,9 @@ describe('RoutedTabs', () => {
|
||||
expect(
|
||||
rendered.queryByText('tabbed-test-content'),
|
||||
).not.toBeInTheDocument();
|
||||
expect(rendered.queryByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
expect(rendered.getByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
expect(
|
||||
rendered.queryByText('tabbed-test-nested-content-2'),
|
||||
rendered.getByText('tabbed-test-nested-content-2'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -125,7 +126,7 @@ describe('RoutedTabs', () => {
|
||||
expect(
|
||||
rendered.queryByText('tabbed-test-content'),
|
||||
).not.toBeInTheDocument();
|
||||
expect(rendered.queryByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
expect(rendered.getByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
expect(
|
||||
rendered.queryByText('tabbed-test-nested-content-2'),
|
||||
).not.toBeInTheDocument();
|
||||
@@ -142,7 +143,7 @@ describe('RoutedTabs', () => {
|
||||
expect(rendered.queryByText('tabbed-test-content')).not.toBeInTheDocument();
|
||||
|
||||
expect(rendered.getByText('tabbed-test-title-2')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
expect(rendered.getByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('redirects to the top level when no route is matching the url', async () => {
|
||||
|
||||
@@ -79,6 +79,6 @@ describe('TabbedLayout', () => {
|
||||
expect(queryByText('tabbed-test-content')).not.toBeInTheDocument();
|
||||
|
||||
expect(getByText('tabbed-test-title-2')).toBeInTheDocument();
|
||||
expect(queryByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
expect(getByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('<ComponentContextMenu />', () => {
|
||||
await fireEvent.click(rendered.queryByText('Some label') as Node);
|
||||
expect(onClickFunction).toHaveBeenCalled();
|
||||
// We do not expect the dropdown to disappear after click
|
||||
expect(rendered.queryByText('Some label')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Some label')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Disabled', async () => {
|
||||
@@ -80,7 +80,7 @@ describe('<ComponentContextMenu />', () => {
|
||||
await fireEvent.click(rendered.queryByText('Secondary label') as Node);
|
||||
expect(onClickFunction).toHaveBeenCalled();
|
||||
// We do not expect the dropdown to disappear after click
|
||||
expect(rendered.queryByText('Some label')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Some label')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should close when hitting escape', async () => {
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ describe('<PreparePullRequestForm />', () => {
|
||||
|
||||
expect(onSubmitFn).not.toHaveBeenCalled();
|
||||
expect(
|
||||
screen.queryByText('Error in required main field'),
|
||||
screen.getByText('Error in required main field'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ describe('<StepPrepareSelectLocations />', () => {
|
||||
expect(screen.getByText('url-1')).toBeInTheDocument();
|
||||
expect(screen.getByText('url-2')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByText(/Select one or more locations/),
|
||||
screen.getByText(/Select one or more locations/),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByText(/locations already exist/),
|
||||
@@ -104,7 +104,7 @@ describe('<StepPrepareSelectLocations />', () => {
|
||||
);
|
||||
|
||||
expect(screen.getByText(/my-target/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/locations already exist/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/locations already exist/)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByText(/Select one or more locations/),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
@@ -151,8 +151,8 @@ describe('<UserListPicker />', () => {
|
||||
</ApiProvider>,
|
||||
);
|
||||
|
||||
expect(screen.queryByText('Personal')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Test Company')).toBeInTheDocument();
|
||||
expect(screen.getByText('Personal')).toBeInTheDocument();
|
||||
expect(screen.getByText('Test Company')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders filters', () => {
|
||||
|
||||
@@ -190,7 +190,7 @@ describe('EntityLayout', () => {
|
||||
expect(screen.queryByText('tabbed-test-content')).not.toBeInTheDocument();
|
||||
|
||||
expect(screen.getByText('tabbed-test-title-2')).toBeInTheDocument();
|
||||
expect(screen.queryByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
expect(screen.getByText('tabbed-test-content-2')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should conditionally render tabs', async () => {
|
||||
@@ -228,8 +228,8 @@ describe('EntityLayout', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(screen.queryByText('tabbed-test-title')).toBeInTheDocument();
|
||||
expect(screen.getByText('tabbed-test-title')).toBeInTheDocument();
|
||||
expect(screen.queryByText('tabbed-test-title-2')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('tabbed-test-title-3')).toBeInTheDocument();
|
||||
expect(screen.getByText('tabbed-test-title-3')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('EntityLinksCard', () => {
|
||||
),
|
||||
);
|
||||
|
||||
expect(screen.queryByText('admin dashboard')).toBeInTheDocument();
|
||||
expect(screen.getByText('admin dashboard')).toBeInTheDocument();
|
||||
expect(screen.queryByText('derp')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('EntityLinksCard', () => {
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.queryByText(/.*No links defined for this entity.*/),
|
||||
screen.getByText(/.*No links defined for this entity.*/),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.queryByText('admin dashboard')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -33,6 +33,6 @@ describe('IconLink', () => {
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
expect(screen.queryByText('I am Link')).toBeInTheDocument();
|
||||
expect(screen.getByText('I am Link')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ describe('<EntityProcessErrors />', () => {
|
||||
expect(screen.getByText('Error: Foo')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Error: This should not be rendered')).toBeNull();
|
||||
expect(
|
||||
screen.queryByText('The error below originates from'),
|
||||
screen.getByText('The error below originates from'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('EntitySwitch', () => {
|
||||
</Wrapper>,
|
||||
);
|
||||
|
||||
expect(screen.queryByText('A')).toBeInTheDocument();
|
||||
expect(screen.getByText('A')).toBeInTheDocument();
|
||||
expect(screen.queryByText('B')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('C')).not.toBeInTheDocument();
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('EntitySwitch', () => {
|
||||
);
|
||||
|
||||
expect(screen.queryByText('A')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('B')).toBeInTheDocument();
|
||||
expect(screen.getByText('B')).toBeInTheDocument();
|
||||
expect(screen.queryByText('C')).not.toBeInTheDocument();
|
||||
|
||||
rendered.rerender(
|
||||
@@ -84,7 +84,7 @@ describe('EntitySwitch', () => {
|
||||
|
||||
expect(screen.queryByText('A')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('B')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('C')).toBeInTheDocument();
|
||||
expect(screen.getByText('C')).toBeInTheDocument();
|
||||
|
||||
rendered.rerender(
|
||||
<Wrapper>
|
||||
@@ -96,7 +96,7 @@ describe('EntitySwitch', () => {
|
||||
|
||||
expect(screen.queryByText('A')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('B')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('C')).toBeInTheDocument();
|
||||
expect(screen.getByText('C')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should switch child when filters switch', () => {
|
||||
@@ -113,7 +113,7 @@ describe('EntitySwitch', () => {
|
||||
</Wrapper>,
|
||||
);
|
||||
|
||||
expect(screen.queryByText('A')).toBeInTheDocument();
|
||||
expect(screen.getByText('A')).toBeInTheDocument();
|
||||
expect(screen.queryByText('B')).not.toBeInTheDocument();
|
||||
|
||||
rendered.rerender(
|
||||
@@ -128,7 +128,7 @@ describe('EntitySwitch', () => {
|
||||
);
|
||||
|
||||
expect(screen.queryByText('A')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('B')).toBeInTheDocument();
|
||||
expect(screen.getByText('B')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should switch with async condition that is true', async () => {
|
||||
|
||||
@@ -67,8 +67,8 @@ describe('<SystemDiagramCard />', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(screen.queryByText(/System Diagram/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/namespace2\/system2/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/System Diagram/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/namespace2\/system2/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/namespace\/entity/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('<BarChart />', () => {
|
||||
|
||||
it('should display stepper if displaying more than 6 resources', async () => {
|
||||
const rendered = await renderWithProps({} as BarChartProps);
|
||||
expect(rendered.queryByTestId('bar-chart-stepper')).toBeInTheDocument();
|
||||
expect(rendered.getByTestId('bar-chart-stepper')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should display the next step button if resources are remaining', async () => {
|
||||
@@ -114,7 +114,7 @@ describe('<BarChart />', () => {
|
||||
rendered.queryByTestId('bar-chart-stepper-button-back'),
|
||||
).not.toBeInTheDocument();
|
||||
expect(
|
||||
rendered.queryByTestId('bar-chart-stepper-button-next'),
|
||||
rendered.getByTestId('bar-chart-stepper-button-next'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -27,6 +27,6 @@ describe('<BarChartLegend />', () => {
|
||||
</MockConfigProvider>,
|
||||
);
|
||||
expect(rendered.getByText(/\$1,000/)).toBeInTheDocument();
|
||||
expect(rendered.queryByText(/\$5,000/)).toBeInTheDocument();
|
||||
expect(rendered.getByText(/\$5,000/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
import { CostInsightsHeader } from './CostInsightsHeader';
|
||||
import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils';
|
||||
import React from 'react';
|
||||
|
||||
import { ApiProvider } from '@backstage/core-app-api';
|
||||
import { IdentityApi, identityApiRef } from '@backstage/core-plugin-api';
|
||||
|
||||
@@ -43,7 +42,7 @@ describe('<CostInsightsHeader/>', () => {
|
||||
</ApiProvider>,
|
||||
);
|
||||
|
||||
expect(rendered.queryByText(/doing great/)).toBeInTheDocument();
|
||||
expect(rendered.getByText(/doing great/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Shows work to do when alerts > 1', async () => {
|
||||
@@ -57,7 +56,7 @@ describe('<CostInsightsHeader/>', () => {
|
||||
/>
|
||||
</ApiProvider>,
|
||||
);
|
||||
expect(rendered.queryByText(/few things/)).toBeInTheDocument();
|
||||
expect(rendered.getByText(/few things/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Handles grammar with a single alert', async () => {
|
||||
@@ -73,7 +72,7 @@ describe('<CostInsightsHeader/>', () => {
|
||||
);
|
||||
|
||||
expect(rendered.queryByText(/things/)).not.toBeInTheDocument();
|
||||
expect(rendered.queryByText(/one thing/)).toBeInTheDocument();
|
||||
expect(rendered.getByText(/one thing/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Shows no costs when hasCostData is false', async () => {
|
||||
@@ -87,7 +86,7 @@ describe('<CostInsightsHeader/>', () => {
|
||||
/>
|
||||
</ApiProvider>,
|
||||
);
|
||||
expect(rendered.queryByText(/this is awkward/)).toBeInTheDocument();
|
||||
expect(rendered.getByText(/this is awkward/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe.each`
|
||||
@@ -109,9 +108,7 @@ describe('<CostInsightsHeader/>', () => {
|
||||
/>
|
||||
</ApiProvider>,
|
||||
);
|
||||
expect(
|
||||
rendered.queryByText(/Test group display name/),
|
||||
).toBeInTheDocument();
|
||||
expect(rendered.getByText(/Test group display name/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Fallbacks to group id when display name not available', async () => {
|
||||
@@ -125,7 +122,7 @@ describe('<CostInsightsHeader/>', () => {
|
||||
/>
|
||||
</ApiProvider>,
|
||||
);
|
||||
expect(rendered.queryByText(/test-user-group-1/)).toBeInTheDocument();
|
||||
expect(rendered.getByText(/test-user-group-1/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { getByRole, waitFor } from '@testing-library/react';
|
||||
import { getByRole, screen, waitFor } from '@testing-library/react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { PeriodSelect, getDefaultOptions } from './PeriodSelect';
|
||||
@@ -29,7 +29,7 @@ const options = getDefaultOptions(lastCompleteBillingDate);
|
||||
|
||||
describe('<PeriodSelect />', () => {
|
||||
it('Renders without exploding', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<MockBillingDateProvider
|
||||
lastCompleteBillingDate={lastCompleteBillingDate}
|
||||
>
|
||||
@@ -39,11 +39,11 @@ describe('<PeriodSelect />', () => {
|
||||
/>
|
||||
</MockBillingDateProvider>,
|
||||
);
|
||||
expect(rendered.getByTestId('period-select')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('period-select')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Should display all costGrowth period options', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<MockBillingDateProvider
|
||||
lastCompleteBillingDate={lastCompleteBillingDate}
|
||||
>
|
||||
@@ -53,13 +53,13 @@ describe('<PeriodSelect />', () => {
|
||||
/>
|
||||
</MockBillingDateProvider>,
|
||||
);
|
||||
const periodSelectContainer = rendered.getByTestId('period-select');
|
||||
const periodSelectContainer = screen.getByTestId('period-select');
|
||||
const button = getByRole(periodSelectContainer, 'button');
|
||||
await userEvent.click(button);
|
||||
await waitFor(() => rendered.getByText('Past 60 Days'));
|
||||
await waitFor(() => screen.getByText('Past 60 Days'));
|
||||
options.forEach(option =>
|
||||
expect(
|
||||
rendered.getByTestId(`period-select-option-${option.value}`),
|
||||
screen.getByTestId(`period-select-option-${option.value}`),
|
||||
).toBeInTheDocument(),
|
||||
);
|
||||
});
|
||||
@@ -78,19 +78,19 @@ describe('<PeriodSelect />', () => {
|
||||
? Duration.P30D
|
||||
: DefaultPageFilters.duration;
|
||||
|
||||
const rendered = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<MockBillingDateProvider
|
||||
lastCompleteBillingDate={lastCompleteBillingDate}
|
||||
>
|
||||
<PeriodSelect duration={mockAggregation} onSelect={mockOnSelect} />,
|
||||
</MockBillingDateProvider>,
|
||||
);
|
||||
const periodSelect = rendered.getByTestId('period-select');
|
||||
const periodSelect = screen.getByTestId('period-select');
|
||||
const button = getByRole(periodSelect, 'button');
|
||||
|
||||
await userEvent.click(button);
|
||||
await userEvent.click(
|
||||
rendered.getByTestId(`period-select-option-${duration}`),
|
||||
screen.getByTestId(`period-select-option-${duration}`),
|
||||
);
|
||||
expect(mockOnSelect).toHaveBeenLastCalledWith(duration);
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { getByRole, waitFor } from '@testing-library/react';
|
||||
import { getByRole, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { ProjectSelect } from './ProjectSelect';
|
||||
import { MockFilterProvider } from '../../testUtils';
|
||||
@@ -42,23 +42,19 @@ describe('<ProjectSelect />', () => {
|
||||
});
|
||||
|
||||
it('Renders without exploding', async () => {
|
||||
const rendered = await renderInTestApp(Component);
|
||||
expect(rendered.getByText('All Projects')).toBeInTheDocument();
|
||||
await renderInTestApp(Component);
|
||||
expect(screen.getByText('All Projects')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows all projects in the filter select', async () => {
|
||||
const rendered = await renderInTestApp(Component);
|
||||
const projectSelectContainer = rendered.getByTestId(
|
||||
'project-filter-select',
|
||||
);
|
||||
await renderInTestApp(Component);
|
||||
const projectSelectContainer = screen.getByTestId('project-filter-select');
|
||||
const button = getByRole(projectSelectContainer, 'button');
|
||||
await userEvent.click(button);
|
||||
await waitFor(() => rendered.getByTestId('option-all'));
|
||||
await waitFor(() => screen.getByTestId('option-all'));
|
||||
|
||||
mockProjects.forEach(project =>
|
||||
expect(
|
||||
rendered.getByText(project.name ?? project.id),
|
||||
).toBeInTheDocument(),
|
||||
expect(screen.getByText(project.name ?? project.id)).toBeInTheDocument(),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
|
||||
import { AttendeeChip } from './AttendeeChip';
|
||||
import { EventAttendee, ResponseStatus } from '../../api';
|
||||
|
||||
@@ -27,8 +27,8 @@ describe('<AttendeeChip />', () => {
|
||||
email,
|
||||
responseStatus: ResponseStatus.needsAction,
|
||||
};
|
||||
const { queryByText } = await renderInTestApp(<AttendeeChip user={user} />);
|
||||
expect(queryByText(email)).toBeInTheDocument();
|
||||
await renderInTestApp(<AttendeeChip user={user} />);
|
||||
expect(screen.getByText(email)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders accepted icon', async () => {
|
||||
@@ -37,8 +37,8 @@ describe('<AttendeeChip />', () => {
|
||||
email,
|
||||
responseStatus: ResponseStatus.accepted,
|
||||
};
|
||||
const { getByTestId } = await renderInTestApp(<AttendeeChip user={user} />);
|
||||
expect(getByTestId('accepted-icon')).toBeInTheDocument();
|
||||
await renderInTestApp(<AttendeeChip user={user} />);
|
||||
expect(screen.getByTestId('accepted-icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders declined icon', async () => {
|
||||
@@ -47,7 +47,7 @@ describe('<AttendeeChip />', () => {
|
||||
email,
|
||||
responseStatus: ResponseStatus.declined,
|
||||
};
|
||||
const { getByTestId } = await renderInTestApp(<AttendeeChip user={user} />);
|
||||
expect(getByTestId('declined-icon')).toBeInTheDocument();
|
||||
await renderInTestApp(<AttendeeChip user={user} />);
|
||||
expect(screen.getByTestId('declined-icon')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { fireEvent } from '@testing-library/react';
|
||||
import { screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
|
||||
import { CalendarEvent } from './CalendarEvent';
|
||||
|
||||
describe('<CalendarEvent />', () => {
|
||||
@@ -42,16 +42,14 @@ describe('<CalendarEvent />', () => {
|
||||
};
|
||||
|
||||
it('should render calendar event', async () => {
|
||||
const { queryByText, queryByTestId } = await renderInTestApp(
|
||||
<CalendarEvent event={event} />,
|
||||
);
|
||||
expect(queryByText(event.summary)).toBeInTheDocument();
|
||||
expect(queryByTestId('calendar-event-zoom-link')).toBeInTheDocument();
|
||||
expect(queryByTestId('calendar-event-zoom-link')).toHaveAttribute(
|
||||
await renderInTestApp(<CalendarEvent event={event} />);
|
||||
expect(screen.getByText(event.summary)).toBeInTheDocument();
|
||||
expect(screen.getByTestId('calendar-event-zoom-link')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('calendar-event-zoom-link')).toHaveAttribute(
|
||||
'href',
|
||||
event.conferenceData.entryPoints[0].uri,
|
||||
);
|
||||
expect(queryByTestId('calendar-event-time')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('calendar-event-time')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render time for events longer than 1 day', async () => {
|
||||
@@ -64,20 +62,18 @@ describe('<CalendarEvent />', () => {
|
||||
date: '2022-02-19',
|
||||
},
|
||||
};
|
||||
const { queryByText, queryByTestId } = await renderInTestApp(
|
||||
<CalendarEvent event={allDayEvent} />,
|
||||
);
|
||||
expect(queryByText(allDayEvent.summary)).toBeInTheDocument();
|
||||
expect(queryByTestId('calendar-event-time')).not.toBeInTheDocument();
|
||||
await renderInTestApp(<CalendarEvent event={allDayEvent} />);
|
||||
expect(screen.getByText(allDayEvent.summary)).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('calendar-event-time')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should show popover on click', async () => {
|
||||
const { queryByTestId, getByTestId } = await renderInTestApp(
|
||||
<CalendarEvent event={event} />,
|
||||
);
|
||||
expect(queryByTestId('calendar-event-popover')).not.toBeInTheDocument();
|
||||
await renderInTestApp(<CalendarEvent event={event} />);
|
||||
expect(
|
||||
screen.queryByTestId('calendar-event-popover'),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(getByTestId('calendar-event'));
|
||||
expect(queryByTestId('calendar-event-popover')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByTestId('calendar-event'));
|
||||
expect(screen.getByTestId('calendar-event-popover')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
+12
-15
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { screen } from '@testing-library/react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
|
||||
import { CalendarEventPopoverContent } from './CalendarEventPopoverContent';
|
||||
|
||||
describe('<CalendarEventPopoverContent />', () => {
|
||||
@@ -35,21 +35,18 @@ describe('<CalendarEventPopoverContent />', () => {
|
||||
};
|
||||
|
||||
it('should render event info', async () => {
|
||||
const { queryByText, queryByTestId } = await renderInTestApp(
|
||||
<CalendarEventPopoverContent event={event} />,
|
||||
);
|
||||
expect(queryByText(event.summary)).toBeInTheDocument();
|
||||
expect(queryByText(event.description)).toBeInTheDocument();
|
||||
expect(queryByText(event.attendees[0].email)).toBeInTheDocument();
|
||||
expect(queryByText('Join Zoom Meeting')).toBeInTheDocument();
|
||||
expect(queryByText('Join Zoom Meeting')?.closest('a')).toHaveAttribute(
|
||||
'href',
|
||||
event.conferenceData.entryPoints[0].uri,
|
||||
);
|
||||
expect(queryByTestId('open-calendar-link')).toHaveAttribute(
|
||||
await renderInTestApp(<CalendarEventPopoverContent event={event} />);
|
||||
expect(screen.getByText(event.summary)).toBeInTheDocument();
|
||||
expect(screen.getByText(event.description)).toBeInTheDocument();
|
||||
expect(screen.getByText(event.attendees[0].email)).toBeInTheDocument();
|
||||
expect(screen.getByText('Join Zoom Meeting')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByText('Join Zoom Meeting')?.closest('a'),
|
||||
).toHaveAttribute('href', event.conferenceData.entryPoints[0].uri);
|
||||
expect(screen.queryByTestId('open-calendar-link')).toHaveAttribute(
|
||||
'href',
|
||||
event.htmlLink,
|
||||
);
|
||||
expect(queryByText(event.attendees[0].email)).toBeInTheDocument();
|
||||
expect(screen.getByText(event.attendees[0].email)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ describe('AuditListTable', () => {
|
||||
if (!website)
|
||||
throw new Error('https://anchor.fm must be present in fixture');
|
||||
expect(
|
||||
rendered.queryByText(formatTime(website.lastAudit.timeCreated)),
|
||||
rendered.getByText(formatTime(website.lastAudit.timeCreated)),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ describe('AuditView', () => {
|
||||
|
||||
websiteResponse.audits.forEach(a => {
|
||||
expect(
|
||||
rendered.queryByText(formatTime(a.timeCreated)),
|
||||
rendered.getByText(formatTime(a.timeCreated)),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -199,7 +199,7 @@ describe('AuditView', () => {
|
||||
|
||||
await rendered.findByTestId('audit-sidebar');
|
||||
|
||||
expect(rendered.queryByTestId('progress')).toBeInTheDocument();
|
||||
expect(rendered.getByTestId('progress')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -219,7 +219,7 @@ describe('AuditView', () => {
|
||||
|
||||
await rendered.findByTestId('audit-sidebar');
|
||||
|
||||
expect(rendered.queryByText(/This audit failed/)).toBeInTheDocument();
|
||||
expect(rendered.getByText(/This audit failed/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('LighthouseIntro', () => {
|
||||
it('renders successfully', () => {
|
||||
const rendered = render(wrapInTestApp(<LighthouseIntro />));
|
||||
expect(
|
||||
rendered.queryByText('Welcome to Lighthouse in Backstage!'),
|
||||
rendered.getByText('Welcome to Lighthouse in Backstage!'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('LighthouseIntro', () => {
|
||||
|
||||
it('selects the first text element', () => {
|
||||
const rendered = render(wrapInTestApp(<LighthouseIntro />));
|
||||
expect(rendered.queryByText(firstTabRe)).toBeInTheDocument();
|
||||
expect(rendered.getByText(firstTabRe)).toBeInTheDocument();
|
||||
expect(rendered.queryByText(secondTabRe)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('LighthouseIntro', () => {
|
||||
const rendered = render(wrapInTestApp(<LighthouseIntro />));
|
||||
fireEvent.click(rendered.getByText('Setup'));
|
||||
expect(rendered.queryByText(firstTabRe)).not.toBeInTheDocument();
|
||||
expect(rendered.queryByText(secondTabRe)).toBeInTheDocument();
|
||||
expect(rendered.getByText(secondTabRe)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { render, waitFor } from '@testing-library/react';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { Incidents } from './Incidents';
|
||||
import { TestApiRegistry, wrapInTestApp } from '@backstage/test-utils';
|
||||
import { pagerDutyApiRef } from '../../api';
|
||||
@@ -32,15 +33,15 @@ describe('Incidents', () => {
|
||||
.fn()
|
||||
.mockImplementationOnce(async () => ({ incidents: [] }));
|
||||
|
||||
const { getByText, queryByTestId } = render(
|
||||
render(
|
||||
wrapInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<Incidents serviceId="abc" refreshIncidents={false} />
|
||||
</ApiProvider>,
|
||||
),
|
||||
);
|
||||
await waitFor(() => !queryByTestId('progress'));
|
||||
expect(getByText('Nice! No incidents found!')).toBeInTheDocument();
|
||||
await waitFor(() => !screen.queryByTestId('progress'));
|
||||
expect(screen.getByText('Nice! No incidents found!')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Renders all incidents', async () => {
|
||||
@@ -85,25 +86,25 @@ describe('Incidents', () => {
|
||||
},
|
||||
] as PagerDutyIncident[],
|
||||
}));
|
||||
const { getByText, getAllByTitle, queryByTestId } = render(
|
||||
render(
|
||||
wrapInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<Incidents serviceId="abc" refreshIncidents={false} />
|
||||
</ApiProvider>,
|
||||
),
|
||||
);
|
||||
await waitFor(() => !queryByTestId('progress'));
|
||||
expect(getByText('title1')).toBeInTheDocument();
|
||||
expect(getByText('title2')).toBeInTheDocument();
|
||||
expect(getByText('person1')).toBeInTheDocument();
|
||||
expect(getByText('person2')).toBeInTheDocument();
|
||||
expect(getByText('triggered')).toBeInTheDocument();
|
||||
expect(getByText('acknowledged')).toBeInTheDocument();
|
||||
expect(queryByTestId('chip-triggered')).toBeInTheDocument();
|
||||
expect(queryByTestId('chip-acknowledged')).toBeInTheDocument();
|
||||
await waitFor(() => !screen.queryByTestId('progress'));
|
||||
expect(screen.getByText('title1')).toBeInTheDocument();
|
||||
expect(screen.getByText('title2')).toBeInTheDocument();
|
||||
expect(screen.getByText('person1')).toBeInTheDocument();
|
||||
expect(screen.getByText('person2')).toBeInTheDocument();
|
||||
expect(screen.getByText('triggered')).toBeInTheDocument();
|
||||
expect(screen.getByText('acknowledged')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('chip-triggered')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('chip-acknowledged')).toBeInTheDocument();
|
||||
|
||||
// assert links, mailto and hrefs, date calculation
|
||||
expect(getAllByTitle('View in PagerDuty').length).toEqual(2);
|
||||
expect(screen.getAllByTitle('View in PagerDuty').length).toEqual(2);
|
||||
});
|
||||
|
||||
it('Handle errors', async () => {
|
||||
@@ -111,16 +112,18 @@ describe('Incidents', () => {
|
||||
.fn()
|
||||
.mockRejectedValueOnce(new Error('Error occurred'));
|
||||
|
||||
const { getByText, queryByTestId } = render(
|
||||
render(
|
||||
wrapInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<Incidents serviceId="abc" refreshIncidents={false} />
|
||||
</ApiProvider>,
|
||||
),
|
||||
);
|
||||
await waitFor(() => !queryByTestId('progress'));
|
||||
await waitFor(() => !screen.queryByTestId('progress'));
|
||||
expect(
|
||||
getByText('Error encountered while fetching information. Error occurred'),
|
||||
screen.getByText(
|
||||
'Error encountered while fetching information. Error occurred',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,6 @@ import { fireEvent, waitFor } from '@testing-library/react';
|
||||
import { act } from '@testing-library/react-hooks';
|
||||
import React from 'react';
|
||||
import { SWRConfig } from 'swr';
|
||||
|
||||
import { PlaylistApi, playlistApiRef } from '../../api';
|
||||
import { rootRouteRef } from '../../routes';
|
||||
import { CreatePlaylistButton } from './CreatePlaylistButton';
|
||||
@@ -103,7 +102,7 @@ describe('<CreatePlaylistButton/>', () => {
|
||||
fireEvent.click(rendered.getByRole('button'));
|
||||
});
|
||||
expect(
|
||||
rendered.queryByTestId('mock-playlist-edit-dialog'),
|
||||
rendered.getByTestId('mock-playlist-edit-dialog'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import { fireEvent, getByRole, waitFor } from '@testing-library/react';
|
||||
import { act } from '@testing-library/react-hooks';
|
||||
import React from 'react';
|
||||
import { SWRConfig } from 'swr';
|
||||
|
||||
import { PlaylistApi, playlistApiRef } from '../../api';
|
||||
import { rootRouteRef } from '../../routes';
|
||||
import { EntityPlaylistDialog } from './EntityPlaylistDialog';
|
||||
@@ -182,7 +181,7 @@ describe('EntityPlaylistDialog', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
rendered.queryByTestId('mock-playlist-edit-dialog'),
|
||||
rendered.getByTestId('mock-playlist-edit-dialog'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
act(() => {
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { Playlist } from '@backstage/plugin-playlist-common';
|
||||
import { MockStorageApi, TestApiRegistry } from '@backstage/test-utils';
|
||||
import { fireEvent, render, waitFor } from '@testing-library/react';
|
||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { MockPlaylistListProvider } from '../../testUtils';
|
||||
@@ -94,7 +94,7 @@ describe('<PersonalListPicker />', () => {
|
||||
});
|
||||
|
||||
it('renders filter groups', async () => {
|
||||
const { queryByText } = render(
|
||||
render(
|
||||
<ApiProvider apis={apis}>
|
||||
<MockPlaylistListProvider value={{ backendPlaylists }}>
|
||||
<PersonalListPicker />
|
||||
@@ -103,8 +103,8 @@ describe('<PersonalListPicker />', () => {
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(queryByText('Personal')).toBeInTheDocument();
|
||||
expect(queryByText('Test Company')).toBeInTheDocument();
|
||||
expect(screen.getByText('Personal')).toBeInTheDocument();
|
||||
expect(screen.getByText('Test Company')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import { fireEvent, waitFor } from '@testing-library/react';
|
||||
import { act } from '@testing-library/react-hooks';
|
||||
import React from 'react';
|
||||
import { SWRConfig } from 'swr';
|
||||
|
||||
import { PlaylistApi, playlistApiRef } from '../../api';
|
||||
import { PlaylistEntitiesTable } from './PlaylistEntitiesTable';
|
||||
|
||||
@@ -158,7 +157,7 @@ describe('PlaylistEntitiesTable', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
rendered.queryByTestId('mock-add-entities-drawer'),
|
||||
rendered.getByTestId('mock-add-entities-drawer'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
act(() => {
|
||||
|
||||
@@ -31,7 +31,6 @@ import { fireEvent, waitFor } from '@testing-library/react';
|
||||
import { act } from '@testing-library/react-hooks';
|
||||
import React from 'react';
|
||||
import { SWRConfig } from 'swr';
|
||||
|
||||
import { PlaylistApi, playlistApiRef } from '../../api';
|
||||
import { rootRouteRef } from '../../routes';
|
||||
import { PlaylistHeader } from './PlaylistHeader';
|
||||
@@ -122,7 +121,7 @@ describe('PlaylistHeader', () => {
|
||||
|
||||
testPlaylist.public = false;
|
||||
rendered.rerender(element);
|
||||
expect(rendered.queryByText('private')).toBeInTheDocument();
|
||||
expect(rendered.getByText('private')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('has edit and delete options enabled if authorized', async () => {
|
||||
@@ -202,7 +201,7 @@ describe('PlaylistHeader', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
rendered.queryByTestId('mock-playlist-edit-dialog'),
|
||||
rendered.getByTestId('mock-playlist-edit-dialog'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
act(() => {
|
||||
|
||||
@@ -65,9 +65,9 @@ describe('TemplatePage', () => {
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(rendered.queryByText('Test title')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('example description')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('foobar')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Test title')).toBeInTheDocument();
|
||||
expect(rendered.getByText('example description')).toBeInTheDocument();
|
||||
expect(rendered.getByText('foobar')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('output')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -109,10 +109,10 @@ describe('TemplatePage', () => {
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(rendered.queryByText('Test title')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('example description')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('foobar')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('Test output')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Test title')).toBeInTheDocument();
|
||||
expect(rendered.getByText('example description')).toBeInTheDocument();
|
||||
expect(rendered.getByText('foobar')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Test output')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders action with oneOf input', async () => {
|
||||
@@ -160,10 +160,10 @@ describe('TemplatePage', () => {
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(rendered.queryByText('oneOf')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('Foo title')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('Foo description')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('Bar title')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('Bar description')).toBeInTheDocument();
|
||||
expect(rendered.getByText('oneOf')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Foo title')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Foo description')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Bar title')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Bar description')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ describe('ScaffolderPageContextMenu', () => {
|
||||
|
||||
await userEvent.click(screen.getByTestId('container').firstElementChild!);
|
||||
|
||||
expect(screen.queryByText('Template Editor')).toBeInTheDocument();
|
||||
expect(screen.getByText('Template Editor')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Installed Actions')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('ScaffolderPageContextMenu', () => {
|
||||
await userEvent.click(screen.getByTestId('container').firstElementChild!);
|
||||
|
||||
expect(screen.queryByText('Template Editor')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Installed Actions')).toBeInTheDocument();
|
||||
expect(screen.getByText('Installed Actions')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders all options', async () => {
|
||||
@@ -77,7 +77,7 @@ describe('ScaffolderPageContextMenu', () => {
|
||||
|
||||
await userEvent.click(screen.getByTestId('container').firstElementChild!);
|
||||
|
||||
expect(screen.queryByText('Template Editor')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Installed Actions')).toBeInTheDocument();
|
||||
expect(screen.getByText('Template Editor')).toBeInTheDocument();
|
||||
expect(screen.getByText('Installed Actions')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,6 +33,6 @@ describe('IconLink', () => {
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
expect(rendered.queryByText('I am Link')).toBeInTheDocument();
|
||||
expect(rendered.getByText('I am Link')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
+4
-4
@@ -70,7 +70,7 @@ describe('DryRunResultsList', () => {
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
expect(screen.queryByText('Result 1')).toBeInTheDocument();
|
||||
expect(screen.getByText('Result 1')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Result 2')).not.toBeInTheDocument();
|
||||
|
||||
await act(async () => {
|
||||
@@ -84,12 +84,12 @@ describe('DryRunResultsList', () => {
|
||||
);
|
||||
});
|
||||
|
||||
expect(screen.queryByText('Result 1')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Result 2')).toBeInTheDocument();
|
||||
expect(screen.getByText('Result 1')).toBeInTheDocument();
|
||||
expect(screen.getByText('Result 2')).toBeInTheDocument();
|
||||
|
||||
await userEvent.click(screen.getAllByLabelText('delete')[0]);
|
||||
|
||||
expect(screen.queryByText('Result 1')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Result 2')).toBeInTheDocument();
|
||||
expect(screen.getByText('Result 2')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
renderInTestApp,
|
||||
TestApiRegistry,
|
||||
} from '@backstage/test-utils';
|
||||
import { act, fireEvent, within } from '@testing-library/react';
|
||||
import { act, fireEvent, screen, within } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { Route, Routes } from 'react-router';
|
||||
import { scaffolderApiRef } from '../../api';
|
||||
@@ -31,7 +31,6 @@ import {
|
||||
FeatureFlagsApi,
|
||||
analyticsApiRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
|
||||
import { ApiProvider } from '@backstage/core-app-api';
|
||||
import { errorApiRef } from '@backstage/core-plugin-api';
|
||||
|
||||
@@ -135,8 +134,8 @@ describe('TemplatePage', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(rendered.queryByText('Create a New Component')).toBeInTheDocument();
|
||||
expect(rendered.queryByText('React SSR Template')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Create a New Component')).toBeInTheDocument();
|
||||
expect(rendered.getByText('React SSR Template')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders spinner while loading', async () => {
|
||||
@@ -156,8 +155,8 @@ describe('TemplatePage', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(rendered.queryByText('Create a New Component')).toBeInTheDocument();
|
||||
expect(rendered.queryByTestId('loading-progress')).toBeInTheDocument();
|
||||
expect(rendered.getByText('Create a New Component')).toBeInTheDocument();
|
||||
expect(rendered.getByTestId('loading-progress')).toBeInTheDocument();
|
||||
|
||||
await act(async () => {
|
||||
resolve!({
|
||||
@@ -248,7 +247,7 @@ describe('TemplatePage', () => {
|
||||
expect(
|
||||
rendered.queryByText('Create a New Component'),
|
||||
).not.toBeInTheDocument();
|
||||
expect(rendered.queryByText('This is root')).toBeInTheDocument();
|
||||
expect(rendered.getByText('This is root')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('display template with oneOf', async () => {
|
||||
@@ -330,7 +329,7 @@ describe('TemplatePage', () => {
|
||||
schemaMockValue,
|
||||
);
|
||||
|
||||
const { queryByText } = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<TemplatePage />
|
||||
</ApiProvider>,
|
||||
@@ -341,9 +340,9 @@ describe('TemplatePage', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(queryByText('Name')).not.toBeInTheDocument();
|
||||
expect(queryByText('Description')).toBeInTheDocument();
|
||||
expect(queryByText('Owner')).toBeInTheDocument();
|
||||
expect(queryByText('Send data')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Name')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Owner')).toBeInTheDocument();
|
||||
expect(screen.getByText('Send data')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { screen } from '@testing-library/react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import React from 'react';
|
||||
import { RegisterExistingButton } from './RegisterExistingButton';
|
||||
@@ -30,28 +32,22 @@ describe('RegisterExistingButton', () => {
|
||||
it('should not render if to is unset', async () => {
|
||||
(usePermission as jest.Mock).mockReturnValue({ allowed: true });
|
||||
|
||||
const { queryByText } = await renderInTestApp(
|
||||
<RegisterExistingButton title="Pick me" />,
|
||||
);
|
||||
await renderInTestApp(<RegisterExistingButton title="Pick me" />);
|
||||
|
||||
expect(queryByText('Pick me')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Pick me')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render if permissions are not allowed', async () => {
|
||||
(usePermission as jest.Mock).mockReturnValue({ allowed: false });
|
||||
const { queryByText } = await renderInTestApp(
|
||||
<RegisterExistingButton title="Pick me" to="blah" />,
|
||||
);
|
||||
await renderInTestApp(<RegisterExistingButton title="Pick me" to="blah" />);
|
||||
|
||||
expect(queryByText('Pick me')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Pick me')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render the button with the text', async () => {
|
||||
(usePermission as jest.Mock).mockReturnValue({ allowed: true });
|
||||
const { queryByText } = await renderInTestApp(
|
||||
<RegisterExistingButton title="Pick me" to="blah" />,
|
||||
);
|
||||
await renderInTestApp(<RegisterExistingButton title="Pick me" to="blah" />);
|
||||
|
||||
expect(queryByText('Pick me')).toBeInTheDocument();
|
||||
expect(screen.getByText('Pick me')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -103,9 +103,9 @@ describe('Entity List Docs Grid', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(screen.queryByText('All Documentation')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Documentation #1')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Documentation #2')).toBeInTheDocument();
|
||||
expect(screen.getByText('All Documentation')).toBeInTheDocument();
|
||||
expect(screen.getByText('Documentation #1')).toBeInTheDocument();
|
||||
expect(screen.getByText('Documentation #2')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('doc-not-found')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -131,8 +131,8 @@ describe('Entity List Docs Grid', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(screen.queryByText('Curated Documentation')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Documentation #1')).toBeInTheDocument();
|
||||
expect(screen.getByText('Curated Documentation')).toBeInTheDocument();
|
||||
expect(screen.getByText('Documentation #1')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Documentation #2')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('doc-not-found')).not.toBeInTheDocument();
|
||||
});
|
||||
@@ -182,6 +182,6 @@ describe('Entity List Docs Grid', () => {
|
||||
expect(screen.queryByText('All Documentation')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Documentation #1')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Documentation #2')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('doc-not-found')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('doc-not-found')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user