Files
admin-web/src/modules/container-loading/components/SmartLoadingDialog.test.ts
T

46 lines
2.1 KiB
TypeScript
Raw Normal View History

2026-09-03 10:27:31 +08:00
import ElementPlus from 'element-plus'
import { flushPromises, mount } from '@vue/test-utils'
import { afterEach, describe, expect, it } from 'vitest'
2026-09-03 13:49:40 +08:00
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
2026-09-03 10:27:31 +08:00
import SmartLoadingDialog from './SmartLoadingDialog.vue'
describe('SmartLoadingDialog', () => {
afterEach(() => { document.body.innerHTML = '' })
2026-09-04 10:51:31 +08:00
it('opens fullscreen by default, can return to normal size, and reopens fullscreen', async () => {
2026-09-03 10:27:31 +08:00
const wrapper = mount(SmartLoadingDialog, {
attachTo: document.body,
props: { modelValue: true },
global: {
plugins: [ElementPlus],
stubs: { GlobalSmartLoadingView: { template: '<div>智能装柜工作台</div>' } },
},
})
await flushPromises()
2026-09-03 11:47:32 +08:00
expect(wrapper.find('.smart-loading-dialog__warehouses').exists()).toBe(false)
2026-09-03 13:49:40 +08:00
expect(document.querySelector('.smart-loading-dialog .el-dialog__body')?.classList.contains('el-dialog__body')).toBe(true)
2026-09-03 10:27:31 +08:00
expect(document.querySelector('.smart-loading-dialog.is-fullscreen')).not.toBeNull()
expect(wrapper.find('button[aria-label="退出全屏"]').exists()).toBe(true)
await wrapper.get('button[aria-label="退出全屏"]').trigger('click')
expect(document.querySelector('.smart-loading-dialog.is-fullscreen')).toBeNull()
expect(wrapper.find('button[aria-label="展开全屏"]').exists()).toBe(true)
2026-09-04 10:51:31 +08:00
await wrapper.setProps({ modelValue: false })
await flushPromises()
await wrapper.setProps({ modelValue: true })
await flushPromises()
expect(document.querySelector('.smart-loading-dialog.is-fullscreen')).not.toBeNull()
expect(wrapper.find('button[aria-label="退出全屏"]').exists()).toBe(true)
2026-09-03 10:27:31 +08:00
})
2026-09-03 13:49:40 +08:00
it('keeps the outer dialog fixed so only workbench data panes scroll', () => {
const source = readFileSync(resolve(process.cwd(), 'src/modules/container-loading/components/SmartLoadingDialog.vue'), 'utf8')
expect(source).toContain('height: 94vh; max-height: 94vh;')
expect(source).toContain('flex: 1; padding: 0; overflow: hidden;')
expect(source).toContain('min-height: 0; flex: 1; overflow: hidden;')
})
2026-09-03 10:27:31 +08:00
})