mirror of
https://github.com/apache/superset.git
synced 2026-07-27 09:02:29 +00:00
Compare commits
1 Commits
enxdev/fix
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
141722e679 |
@@ -53,7 +53,7 @@
|
||||
"@emotion/core": "^11.0.0",
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@fontsource/fira-code": "^5.2.7",
|
||||
"@fontsource/fira-code": "^5.3.0",
|
||||
"@fontsource/ibm-plex-mono": "^5.2.7",
|
||||
"@fontsource/inter": "^5.2.8",
|
||||
"@mdx-js/react": "^3.1.1",
|
||||
|
||||
@@ -2529,10 +2529,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-5.5.3.tgz#18e3af6b8eae7984072bbeb0c0858474d7c4cefe"
|
||||
integrity sha512-R11tGE6yIFwqpaIqcfkcg7AICXzFg14+5h5v0TfF/9+RMDL6jhzCy/pxHVOfbALGdtVYdt6JdR21tuxEgl34dw==
|
||||
|
||||
"@fontsource/fira-code@^5.2.7":
|
||||
version "5.2.7"
|
||||
resolved "https://registry.yarnpkg.com/@fontsource/fira-code/-/fira-code-5.2.7.tgz#9ecbd909d53e7196a5d895b601747fe34491fc6a"
|
||||
integrity sha512-tnB9NNund9TwIym8/7DMJe573nlPEQb+fKUV5GL8TBYXjIhDvL0D7mgmNVNQUPhXp+R7RylQeiBdkA4EbOHPGQ==
|
||||
"@fontsource/fira-code@^5.3.0":
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/@fontsource/fira-code/-/fira-code-5.3.0.tgz#487475cedfa1f7ba7650810ddce00b6c7b1b7a25"
|
||||
integrity sha512-EJL968RJRkakubAj/coU8pSUaeTE5UNoRjtzAr6kGiSZ3jWuN8/AKWHwym/PFUaQL1q7IL/H+EXs4358YhrTBQ==
|
||||
|
||||
"@fontsource/ibm-plex-mono@^5.2.7":
|
||||
version "5.2.7"
|
||||
|
||||
@@ -48,50 +48,10 @@ const mockProps: TabsRendererProps = {
|
||||
tabBarPaddingLeft: 16,
|
||||
};
|
||||
|
||||
// Mirrors the tab label markup of Tab.tsx: the title lives in a
|
||||
// .dragdroppable-tab container and renders as a textarea via EditableTitle
|
||||
const draggableTabProps: TabsRendererProps = {
|
||||
...mockProps,
|
||||
editMode: true,
|
||||
tabItems: [
|
||||
{
|
||||
...mockTabItems[0],
|
||||
label: (
|
||||
<div className="dragdroppable-tab">
|
||||
<span className="editable-title">
|
||||
<textarea defaultValue="Tab 1" />
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
mockTabItems[1],
|
||||
],
|
||||
};
|
||||
|
||||
// jsdom implements no PointerEvent, so @dnd-kit's PointerSensor never activates
|
||||
class MockPointerEvent extends MouseEvent {
|
||||
isPrimary: boolean;
|
||||
|
||||
pointerId: number;
|
||||
|
||||
constructor(type: string, init: PointerEventInit = {}) {
|
||||
super(type, init);
|
||||
this.isPrimary = init.isPrimary ?? true;
|
||||
this.pointerId = init.pointerId ?? 1;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('TabsRenderer', () => {
|
||||
const { PointerEvent: OriginalPointerEvent } = globalThis;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
globalThis.PointerEvent = MockPointerEvent as typeof PointerEvent;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
globalThis.PointerEvent = OriginalPointerEvent;
|
||||
});
|
||||
|
||||
test('renders tabs container with correct test attributes', () => {
|
||||
@@ -239,29 +199,4 @@ describe('TabsRenderer', () => {
|
||||
expect(screen.getByText('Tab 1 Content')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Tab 2 Content')).not.toBeInTheDocument(); // Not active
|
||||
});
|
||||
|
||||
test('drags from the tab title and shows the drag indicator only then', () => {
|
||||
render(<TabsRenderer {...draggableTabProps} />);
|
||||
const container = screen.getByTestId('dashboard-component-tabs');
|
||||
const title = container.querySelector('textarea') as HTMLTextAreaElement;
|
||||
|
||||
// At rest the title keeps the text cursor it sets on itself
|
||||
expect(container).not.toHaveStyleRule('cursor', 'move', {
|
||||
target: '.dragdroppable-tab *',
|
||||
});
|
||||
|
||||
// Pressing on the title and moving past the sensor's distance constraint
|
||||
// has to start a drag: the title covers most of the tab, so a tab that
|
||||
// cannot be dragged from there cannot really be dragged at all
|
||||
fireEvent.pointerDown(title, { button: 0, isPrimary: true, clientX: 0 });
|
||||
fireEvent.pointerMove(document, {
|
||||
button: 0,
|
||||
isPrimary: true,
|
||||
clientX: 50,
|
||||
});
|
||||
|
||||
expect(container).toHaveStyleRule('cursor', 'move', {
|
||||
target: '.dragdroppable-tab *',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -72,16 +72,10 @@ const StyledTabsContainer = styled.div<{ isDragging?: boolean }>`
|
||||
}
|
||||
}
|
||||
|
||||
/* Hide ink-bar during drag */
|
||||
${({ isDragging }) =>
|
||||
isDragging &&
|
||||
`
|
||||
/* Show the drag indicator during drag, over the tab title textarea too.
|
||||
The doubled parent outranks the title's own cursor; a single & loses. */
|
||||
&& .dragdroppable-tab * {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
/* Hide ink-bar during drag */
|
||||
.ant-tabs-card > .ant-tabs-nav .ant-tabs-ink-bar,
|
||||
.ant-tabs > .ant-tabs-nav .ant-tabs-ink-bar {
|
||||
display: none !important;
|
||||
|
||||
Reference in New Issue
Block a user