diff --git a/src/modules/container-loading/components/SmartLoadingDialog.test.ts b/src/modules/container-loading/components/SmartLoadingDialog.test.ts new file mode 100644 index 00000000..9090f471 --- /dev/null +++ b/src/modules/container-loading/components/SmartLoadingDialog.test.ts @@ -0,0 +1,30 @@ +import ElementPlus from 'element-plus' +import { flushPromises, mount } from '@vue/test-utils' +import { afterEach, describe, expect, it } from 'vitest' +import SmartLoadingDialog from './SmartLoadingDialog.vue' + +describe('SmartLoadingDialog', () => { + afterEach(() => { document.body.innerHTML = '' }) + + it('expands to the viewport and can return to the normal dialog size', async () => { + const wrapper = mount(SmartLoadingDialog, { + attachTo: document.body, + props: { modelValue: true }, + global: { + plugins: [ElementPlus], + stubs: { GlobalSmartLoadingView: { template: '
智能装柜工作台
' } }, + }, + }) + await flushPromises() + + expect(wrapper.findAll('.smart-loading-dialog__warehouses [role="tab"]').map((tab) => tab.text())).toEqual(['义乌仓', '东莞仓']) + const expand = wrapper.get('button[aria-label="展开全屏"]') + await expand.trigger('click') + 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) + }) +}) diff --git a/src/modules/container-loading/components/SmartLoadingDialog.vue b/src/modules/container-loading/components/SmartLoadingDialog.vue index 9542f7fb..eca851e0 100644 --- a/src/modules/container-loading/components/SmartLoadingDialog.vue +++ b/src/modules/container-loading/components/SmartLoadingDialog.vue @@ -1,8 +1,25 @@