mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
refactor(switch): Base UI migration with loading/skeleton variants (#33345)
Signed-off-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -117,9 +117,8 @@ describe('Operations', () => {
|
||||
|
||||
it('should render disabled switch when embeddingAvailable is false in list scene', () => {
|
||||
render(<Operations {...defaultProps} embeddingAvailable={false} scene="list" />)
|
||||
// Switch component uses opacity-50 class when disabled
|
||||
const disabledSwitch = document.querySelector('.\\!opacity-50')
|
||||
expect(disabledSwitch).toBeInTheDocument()
|
||||
const disabledSwitch = screen.getByRole('switch')
|
||||
expect(disabledSwitch).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ describe('SegmentCard', () => {
|
||||
)
|
||||
|
||||
const switchElement = screen.getByRole('switch')
|
||||
expect(switchElement).toHaveClass('!cursor-not-allowed')
|
||||
expect(switchElement).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
|
||||
it('should show action buttons when embeddingAvailable is true', () => {
|
||||
@ -792,9 +792,8 @@ describe('SegmentCard', () => {
|
||||
/>,
|
||||
)
|
||||
|
||||
// The Switch component uses CSS classes for disabled state, not the native disabled attribute
|
||||
const switchElement = screen.getByRole('switch')
|
||||
expect(switchElement).toHaveClass('!cursor-not-allowed', '!opacity-50')
|
||||
expect(switchElement).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
|
||||
it('should handle zero word count', () => {
|
||||
@ -877,7 +876,7 @@ describe('SegmentCard', () => {
|
||||
)
|
||||
|
||||
const switchElement = screen.getByRole('switch')
|
||||
expect(switchElement).toHaveClass('bg-components-toggle-bg')
|
||||
expect(switchElement).toHaveAttribute('aria-checked', 'true')
|
||||
})
|
||||
|
||||
it('should render real Switch component with unchecked state', () => {
|
||||
@ -893,7 +892,7 @@ describe('SegmentCard', () => {
|
||||
)
|
||||
|
||||
const switchElement = screen.getByRole('switch')
|
||||
expect(switchElement).toHaveClass('bg-components-toggle-bg-unchecked')
|
||||
expect(switchElement).toHaveAttribute('aria-checked', 'false')
|
||||
})
|
||||
|
||||
it('should render real SegmentIndexTag with position formatting', () => {
|
||||
|
||||
@ -169,9 +169,8 @@ describe('StatusItem', () => {
|
||||
datasetId="dataset-1"
|
||||
/>,
|
||||
)
|
||||
const switchElement = document.querySelector('[role="switch"]')
|
||||
// Switch component uses opacity-50 and cursor-not-allowed when disabled
|
||||
expect(switchElement).toHaveClass('!opacity-50')
|
||||
const switchElement = screen.getByRole('switch')
|
||||
expect(switchElement).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
|
||||
it('should render switch as disabled when embedding (queuing status)', () => {
|
||||
@ -187,9 +186,8 @@ describe('StatusItem', () => {
|
||||
datasetId="dataset-1"
|
||||
/>,
|
||||
)
|
||||
const switchElement = document.querySelector('[role="switch"]')
|
||||
// Switch component uses opacity-50 and cursor-not-allowed when disabled
|
||||
expect(switchElement).toHaveClass('!opacity-50')
|
||||
const switchElement = screen.getByRole('switch')
|
||||
expect(switchElement).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
|
||||
it('should render switch as disabled when embedding (indexing status)', () => {
|
||||
@ -205,9 +203,8 @@ describe('StatusItem', () => {
|
||||
datasetId="dataset-1"
|
||||
/>,
|
||||
)
|
||||
const switchElement = document.querySelector('[role="switch"]')
|
||||
// Switch component uses opacity-50 and cursor-not-allowed when disabled
|
||||
expect(switchElement).toHaveClass('!opacity-50')
|
||||
const switchElement = screen.getByRole('switch')
|
||||
expect(switchElement).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
|
||||
it('should render switch as disabled when embedding (paused status)', () => {
|
||||
@ -223,9 +220,8 @@ describe('StatusItem', () => {
|
||||
datasetId="dataset-1"
|
||||
/>,
|
||||
)
|
||||
const switchElement = document.querySelector('[role="switch"]')
|
||||
// Switch component uses opacity-50 and cursor-not-allowed when disabled
|
||||
expect(switchElement).toHaveClass('!opacity-50')
|
||||
const switchElement = screen.getByRole('switch')
|
||||
expect(switchElement).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user