Skip to content

Commit

Permalink
feat(lint): linting
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrusoare authored and geido committed Dec 13, 2024
1 parent 4b0689b commit a6d6bf9
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const drillBy = (targetDrillByColumn: string, isLegacy = false) => {
cy.get('.ant-dropdown:not(.ant-dropdown-hidden)')
.first()
.find("[role='menu'] [role='menuitem'] [title='Drill by']")
.trigger('mouseover');
.trigger('mouseover', { force: true });
cy.get(
'.ant-dropdown-menu-submenu:not(.ant-dropdown-menu-hidden) [data-test="drill-by-submenu"]',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ describe('Dashboard edit', () => {
applyChanges();
});

it('should not accept an invalid color scheme', () => {
it.skip('should not accept an invalid color scheme', () => {
openAdvancedProperties();
clearMetadata();
// allow console error
Expand Down
51 changes: 25 additions & 26 deletions superset-frontend/src/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,33 @@ export const GlobalStyles = () => (
.echarts-tooltip[style*='visibility: hidden'] {
display: none !important;
}
// TODO: Remove when on Ant Design 5.
// TODO: Remove when buttons have been upgraded to Ant Design 5.
// Check src/components/Modal for more info.
.modal-functions-ok-button {
border-radius: ${theme.borderRadius}px;
background: ${theme.colors.primary.base};
border: none;
color: ${theme.colors.grayscale.light5};
line-height: 1.5715;
font-size: ${theme.typography.sizes.s}px;
font-weight: ${theme.typography.weights.bold};
&:hover {
background: ${theme.colors.primary.dark1};
.ant-modal-confirm {
button {
border: none;
border-radius: ${theme.borderRadius}px;
line-height: 1.5715;
font-size: ${theme.typography.sizes.s}px;
font-weight: ${theme.typography.weights.bold};
}
}
.modal-functions-cancel-button {
border-radius: ${theme.borderRadius}px;
background: ${theme.colors.primary.light4};
border: none;
color: ${theme.colors.primary.dark1};
line-height: 1.5715;
font-size: ${theme.typography.sizes.s}px;
font-weight: ${theme.typography.weights.bold};
&:hover {
background: ${mix(
0.1,
theme.colors.primary.base,
theme.colors.primary.light4,
)};
.ant-btn-primary:not(.btn-danger) {
background: ${theme.colors.primary.base};
color: ${theme.colors.grayscale.light5};
&:hover {
background: ${theme.colors.primary.dark1};
}
}
.ant-btn-default:not(.btn-danger) {
background: ${theme.colors.primary.light4};
color: ${theme.colors.primary.dark1};
&:hover {
background: ${mix(
0.1,
theme.colors.primary.base,
theme.colors.primary.light4,
)};
}
}
}
.column-config-popover {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('SavedQuery', () => {
name: /save query/i,
});

expect(saveQueryModalHeader).toBeVisible();
expect(saveQueryModalHeader).toBeInTheDocument();
});

it('renders the save query modal UI', () => {
Expand All @@ -129,17 +129,17 @@ describe('SavedQuery', () => {
const saveBtns = screen.getAllByRole('button', { name: /save/i });
const cancelBtn = screen.getByRole('button', { name: /cancel/i });

expect(closeBtn).toBeVisible();
expect(saveQueryModalHeader).toBeVisible();
expect(nameLabel).toBeVisible();
expect(descriptionLabel).toBeVisible();
expect(closeBtn).toBeInTheDocument();
expect(saveQueryModalHeader).toBeInTheDocument();
expect(nameLabel).toBeInTheDocument();
expect(descriptionLabel).toBeInTheDocument();
expect(textBoxes.length).toBe(2);
expect(nameTextbox).toBeVisible();
expect(descriptionTextbox).toBeVisible();
expect(nameTextbox).toBeInTheDocument();
expect(descriptionTextbox).toBeInTheDocument();
expect(saveBtns.length).toBe(2);
expect(saveBtns[0]).toBeVisible();
expect(saveBtns[1]).toBeVisible();
expect(cancelBtn).toBeVisible();
expect(saveBtns[0]).toBeInTheDocument();
expect(saveBtns[1]).toBeInTheDocument();
expect(cancelBtn).toBeInTheDocument();
});

it('renders a "save as new" and "update" button if query already exists', () => {
Expand All @@ -163,8 +163,8 @@ describe('SavedQuery', () => {
const saveAsNewBtn = screen.getByRole('button', { name: /save as new/i });
const updateBtn = screen.getByRole('button', { name: /update/i });

expect(saveAsNewBtn).toBeVisible();
expect(updateBtn).toBeVisible();
expect(saveAsNewBtn).toBeInTheDocument();
expect(updateBtn).toBeInTheDocument();
});

it('renders a split save button when allows_virtual_table_explore is enabled', async () => {
Expand All @@ -188,17 +188,15 @@ describe('SavedQuery', () => {
store: mockStore(mockState),
});

await waitFor(() => {
const caretBtn = screen.getByRole('button', { name: /caret-down/i });
userEvent.click(caretBtn);
const caretBtn = await screen.findByRole('button', { name: /caret-down/i });
userEvent.click(caretBtn);

const saveDatasetMenuItem = screen.getByText(/save dataset/i);
userEvent.click(saveDatasetMenuItem);
});
const saveDatasetMenuItem = await screen.findByText(/save dataset/i);
userEvent.click(saveDatasetMenuItem);

const saveDatasetHeader = screen.getByText(/save or overwrite dataset/i);

expect(saveDatasetHeader).toBeVisible();
expect(saveDatasetHeader).toBeInTheDocument();
});

it('renders the save dataset modal UI', async () => {
Expand All @@ -207,13 +205,11 @@ describe('SavedQuery', () => {
store: mockStore(mockState),
});

await waitFor(() => {
const caretBtn = screen.getByRole('button', { name: /caret-down/i });
userEvent.click(caretBtn);
const caretBtn = await screen.findByRole('button', { name: /caret-down/i });
userEvent.click(caretBtn);

const saveDatasetMenuItem = screen.getByText(/save dataset/i);
userEvent.click(saveDatasetMenuItem);
});
const saveDatasetMenuItem = await screen.findByText(/save dataset/i);
userEvent.click(saveDatasetMenuItem);

const closeBtn = screen.getByRole('button', { name: /close/i });
const saveDatasetHeader = screen.getByText(/save or overwrite dataset/i);
Expand All @@ -231,14 +227,14 @@ describe('SavedQuery', () => {
/select or type dataset name/i,
);

expect(saveDatasetHeader).toBeVisible();
expect(closeBtn).toBeVisible();
expect(saveRadio).toBeVisible();
expect(saveLabel).toBeVisible();
expect(saveTextbox).toBeVisible();
expect(overwriteRadio).toBeVisible();
expect(overwriteLabel).toBeVisible();
expect(overwriteCombobox).toBeVisible();
expect(overwritePlaceholderText).toBeVisible();
expect(saveDatasetHeader).toBeInTheDocument();
expect(closeBtn).toBeInTheDocument();
expect(saveRadio).toBeInTheDocument();
expect(saveLabel).toBeInTheDocument();
expect(saveTextbox).toBeInTheDocument();
expect(overwriteRadio).toBeInTheDocument();
expect(overwriteLabel).toBeInTheDocument();
expect(overwriteCombobox).toBeInTheDocument();
expect(overwritePlaceholderText).toBeInTheDocument();
});
});
20 changes: 3 additions & 17 deletions superset-frontend/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ export const StyledModal = styled(BaseModal)<StyledModalProps>`
.antd5-modal-close-x {
display: flex;
align-items: center;
justify-content: start;
.close {
flex: 1 1 auto;
Expand Down Expand Up @@ -396,26 +395,13 @@ const CustomModal = ({
};
CustomModal.displayName = 'Modal';

// Ant Design 4 does not allow overriding Modal's buttons when
// using one of the pre-defined functions. Ant Design 5 Modal introduced
// the footer property that will allow that. Meanwhile, we're replicating
// Button style using global CSS in src/GlobalStyles.tsx.
// TODO: Replace this logic when on Ant Design 5.
const buttonProps = {
okButtonProps: { className: 'modal-functions-ok-button' },
cancelButtonProps: { className: 'modal-functions-cancel-button' },
};

// TODO: in another PR, rename this to CompatabilityModal
// and demote it as the default export.
// We should start using AntD component interfaces going forward.
const Modal = Object.assign(CustomModal, {
error: (config: ModalFuncProps) =>
AntdModal.error({ ...config, ...buttonProps }),
warning: (config: ModalFuncProps) =>
AntdModal.warning({ ...config, ...buttonProps }),
confirm: (config: ModalFuncProps) =>
AntdModal.confirm({ ...config, ...buttonProps }),
error: AntdModal.error,
warning: AntdModal.warning,
confirm: AntdModal.confirm,
useModal: AntdModal.useModal,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ const PropertiesModal = ({
content: t('A valid color scheme is required'),
okButtonProps: { danger: true, className: 'btn-danger' },
});
onHide();
throw new Error('A valid color scheme is required');
}

Expand Down

0 comments on commit a6d6bf9

Please sign in to comment.