Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix act errors in DatabaseModal test #22846

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ jest.mock('@superset-ui/core', () => ({
isFeatureEnabled: () => true,
}));

jest.mock('src/components/Icons/Icon', () => ({
__esModule: true,
default: ({
fileName,
role,
...rest
}: {
fileName: string;
role: string;
}) => (
<span
role={role ?? 'img'}
aria-label={fileName.replace('_', '-')}
{...rest}
/>
),
StyledIcon: () => <span />,
}));

const dbProps = {
show: true,
database_name: 'my database',
Expand Down Expand Up @@ -354,11 +373,6 @@ describe('DatabaseModal', () => {
const preferredDbTextSQLite = within(preferredDbButtonSQLite).getByText(
/sqlite/i,
);
// All dbs render with this icon in this testing environment,
// The Icon count should equal the count of databases rendered
const preferredDbIcon = screen.getAllByRole('img', {
name: /default-icon/i,
});
// renderAvailableSelector() => <Select> - Supported databases selector
const supportedDbsHeader = screen.getByRole('heading', {
name: /or choose from a list of other databases we support:/i,
Expand Down Expand Up @@ -399,10 +413,6 @@ describe('DatabaseModal', () => {
preferredDbButtonPresto,
preferredDbButtonMySQL,
preferredDbButtonSQLite,
preferredDbIcon[0],
preferredDbIcon[1],
preferredDbIcon[2],
preferredDbIcon[3],
preferredDbTextPostgreSQL,
preferredDbTextPresto,
preferredDbTextMySQL,
Expand All @@ -414,9 +424,6 @@ describe('DatabaseModal', () => {
});
// there should be a footer but it should not have any buttons in it
expect(footer[0]).toBeEmptyDOMElement();

// This is how many preferred databases are rendered
expect(preferredDbIcon).toHaveLength(5);
});

test('renders the "Basic" tab of SQL Alchemy form (step 2 of 2) correctly', async () => {
Expand Down