-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
refactor: clean up codes #22002
refactor: clean up codes #22002
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ import { testWithId } from 'src/utils/testUtils'; | |
import { FeatureFlag } from 'src/featureFlags'; | ||
import { Preset } from '@superset-ui/core'; | ||
import { TimeFilterPlugin, SelectFilterPlugin } from 'src/filters/components'; | ||
import { DATE_FILTER_CONTROL_TEST_ID } from 'src/explore/components/controls/DateFilterControl'; | ||
import { DATE_FILTER_TEST_KEY } from 'src/explore/components/controls/DateFilterControl'; | ||
import fetchMock from 'fetch-mock'; | ||
import { waitFor } from '@testing-library/react'; | ||
import FilterBar, { FILTER_BAR_TEST_ID } from '.'; | ||
|
@@ -71,10 +71,6 @@ fetchMock.get('glob:*/api/v1/dataset/7', { | |
|
||
const getTestId = testWithId<string>(FILTER_BAR_TEST_ID, true); | ||
const getModalTestId = testWithId<string>(FILTERS_CONFIG_MODAL_TEST_ID, true); | ||
const getDateControlTestId = testWithId<string>( | ||
DATE_FILTER_CONTROL_TEST_ID, | ||
true, | ||
); | ||
|
||
const FILTER_NAME = 'Time filter 1'; | ||
const FILTER_SET_NAME = 'New filter set'; | ||
|
@@ -121,7 +117,7 @@ const changeFilterValue = async () => { | |
userEvent.click(screen.getAllByText('No filter')[0]); | ||
userEvent.click(screen.getByDisplayValue('Last day')); | ||
expect(await screen.findByText(/2021-04-13/)).toBeInTheDocument(); | ||
userEvent.click(screen.getByTestId(getDateControlTestId('apply-button'))); | ||
userEvent.click(screen.getByTestId(DATE_FILTER_TEST_KEY.applyButton)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep simple logic for a simple use case. |
||
}; | ||
|
||
describe('FilterBar', () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ import React, { useState, useEffect, useMemo } from 'react'; | |
import { css, styled, t, useTheme, NO_TIME_RANGE } from '@superset-ui/core'; | ||
import Button from 'src/components/Button'; | ||
import ControlHeader from 'src/explore/components/ControlHeader'; | ||
import Label, { Type } from 'src/components/Label'; | ||
import Label from 'src/components/Label'; | ||
import Modal from 'src/components/Modal'; | ||
import { Divider } from 'src/components'; | ||
import Icons from 'src/components/Icons'; | ||
|
@@ -36,7 +36,6 @@ import { | |
DATE_FILTER_TEST_KEY, | ||
fetchTimeRange, | ||
FRAME_OPTIONS, | ||
getDateFilterControlTestId, | ||
guessFrame, | ||
useDefaultTimeFilter, | ||
} from './utils'; | ||
|
@@ -124,7 +123,6 @@ const IconWrapper = styled.span` | |
export default function DateFilterLabel(props: DateFilterControlProps) { | ||
const { | ||
onChange, | ||
type, | ||
onOpenPopover = noOp, | ||
onClosePopover = noOp, | ||
overlayStyle = 'Popover', | ||
|
@@ -174,11 +172,6 @@ export default function DateFilterLabel(props: DateFilterControlProps) { | |
guessedFrame === 'No filter' | ||
) { | ||
setActualTimeRange(value); | ||
setTooltipTitle( | ||
type === ('error' as Type) | ||
? t('Default value is required') | ||
: actualRange || '', | ||
); | ||
Comment on lines
-177
to
-181
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the default value always gets from So the type in the |
||
} else { | ||
setActualTimeRange(actualRange || ''); | ||
setTooltipTitle(value || ''); | ||
|
@@ -302,7 +295,7 @@ export default function DateFilterLabel(props: DateFilterControlProps) { | |
disabled={!validTimeRange} | ||
key="apply" | ||
onClick={onSave} | ||
{...getDateFilterControlTestId('apply-button')} | ||
data-test={DATE_FILTER_TEST_KEY.applyButton} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep simple too. |
||
> | ||
{t('APPLY')} | ||
</Button> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace
isNullish
withisDefined