mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
test: Fix act errors in DatabaseList test (#22970)
This commit is contained in:
parent
deba0fd7c1
commit
39f15b8d95
@ -64,6 +64,14 @@ jest.mock('react-redux', () => ({
|
|||||||
useSelector: jest.fn(),
|
useSelector: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
jest.mock('src/components/Icons/Icon', () => ({
|
||||||
|
__esModule: true,
|
||||||
|
default: ({ fileName, role }) => (
|
||||||
|
<span role={role ?? 'img'} aria-label={fileName.replace('_', '-')} />
|
||||||
|
),
|
||||||
|
StyledIcon: () => <span />,
|
||||||
|
}));
|
||||||
|
|
||||||
fetchMock.get(databasesInfoEndpoint, {
|
fetchMock.get(databasesInfoEndpoint, {
|
||||||
permissions: ['can_write'],
|
permissions: ['can_write'],
|
||||||
});
|
});
|
||||||
@ -131,27 +139,27 @@ describe('Admin DatabaseList', () => {
|
|||||||
await waitForComponentToPaint(wrapper);
|
await waitForComponentToPaint(wrapper);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders', () => {
|
test('renders', () => {
|
||||||
expect(wrapper.find(DatabaseList)).toExist();
|
expect(wrapper.find(DatabaseList)).toExist();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders a SubMenu', () => {
|
test('renders a SubMenu', () => {
|
||||||
expect(wrapper.find(SubMenu)).toExist();
|
expect(wrapper.find(SubMenu)).toExist();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders a SubMenu with no tabs', () => {
|
test('renders a SubMenu with no tabs', () => {
|
||||||
expect(wrapper.find(SubMenu).props().tabs).toBeUndefined();
|
expect(wrapper.find(SubMenu).props().tabs).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders a DatabaseModal', () => {
|
test('renders a DatabaseModal', () => {
|
||||||
expect(wrapper.find(DatabaseModal)).toExist();
|
expect(wrapper.find(DatabaseModal)).toExist();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders a ListView', () => {
|
test('renders a ListView', () => {
|
||||||
expect(wrapper.find(ListView)).toExist();
|
expect(wrapper.find(ListView)).toExist();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fetches Databases', () => {
|
test('fetches Databases', () => {
|
||||||
const callsD = fetchMock.calls(/database\/\?q/);
|
const callsD = fetchMock.calls(/database\/\?q/);
|
||||||
expect(callsD).toHaveLength(2);
|
expect(callsD).toHaveLength(2);
|
||||||
expect(callsD[0][0]).toMatchInlineSnapshot(
|
expect(callsD[0][0]).toMatchInlineSnapshot(
|
||||||
@ -159,7 +167,7 @@ describe('Admin DatabaseList', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('deletes', async () => {
|
test('deletes', async () => {
|
||||||
act(() => {
|
act(() => {
|
||||||
wrapper.find('[data-test="database-delete"]').first().props().onClick();
|
wrapper.find('[data-test="database-delete"]').first().props().onClick();
|
||||||
});
|
});
|
||||||
@ -189,7 +197,7 @@ describe('Admin DatabaseList', () => {
|
|||||||
expect(fetchMock.calls(/database\/0/, 'DELETE')).toHaveLength(1);
|
expect(fetchMock.calls(/database\/0/, 'DELETE')).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('filters', async () => {
|
test('filters', async () => {
|
||||||
const filtersWrapper = wrapper.find(Filters);
|
const filtersWrapper = wrapper.find(Filters);
|
||||||
act(() => {
|
act(() => {
|
||||||
filtersWrapper
|
filtersWrapper
|
||||||
@ -217,7 +225,7 @@ describe('Admin DatabaseList', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not render dropdown menu button if user is not admin', () => {
|
test('should not render dropdown menu button if user is not admin', async () => {
|
||||||
userSelectorMock.mockReturnValue({
|
userSelectorMock.mockReturnValue({
|
||||||
createdOn: '2021-05-27T18:12:38.952304',
|
createdOn: '2021-05-27T18:12:38.952304',
|
||||||
email: 'alpha@gmail.com',
|
email: 'alpha@gmail.com',
|
||||||
@ -240,6 +248,8 @@ describe('Admin DatabaseList', () => {
|
|||||||
<DatabaseList />
|
<DatabaseList />
|
||||||
</Provider>,
|
</Provider>,
|
||||||
);
|
);
|
||||||
|
await waitForComponentToPaint(newWrapper);
|
||||||
|
|
||||||
expect(newWrapper.find('.dropdown-menu-links')).not.toExist();
|
expect(newWrapper.find('.dropdown-menu-links')).not.toExist();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user