优化
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import ElementPlus from 'element-plus'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { enableAutoUnmount, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
@@ -15,6 +17,8 @@ import {
|
||||
} from '../api/platformPallets'
|
||||
import PalletsView from './PalletsView.vue'
|
||||
|
||||
const palletsSource = readFileSync(resolve(process.cwd(), 'src/modules/warehouse-resources/pallets/pages/PalletsView.vue'), 'utf8')
|
||||
|
||||
vi.mock('@/modules/warehouses', () => ({ listAllPlatformWarehouses: vi.fn() }))
|
||||
vi.mock('../api/platformPallets', () => ({
|
||||
listPlatformPallets: vi.fn(),
|
||||
@@ -108,6 +112,13 @@ enableAutoUnmount(afterEach)
|
||||
afterAll(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('PalletsView', () => {
|
||||
it('uses the prototype-sized centered editor while retaining the detail drawer', () => {
|
||||
expect(palletsSource).toContain('<AppDrawer v-model="detailOpen"')
|
||||
expect(palletsSource).toContain('<AppDialog v-model="editorOpen" :title="editorTitle" width="min(560px, calc(100vw - 28px))"')
|
||||
expect(palletsSource).not.toContain('<el-drawer v-model="editorOpen"')
|
||||
expect(palletsSource).toContain(':global(.pallet-editor-dialog .el-dialog__body) { min-height: 0; overflow-y: auto; }')
|
||||
expect(palletsSource).toContain('.editor-field-grid { grid-template-columns: minmax(0, 1fr); }')
|
||||
})
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('ResizeObserver', ResizeObserverStub)
|
||||
document.body.innerHTML = ''
|
||||
@@ -272,12 +283,9 @@ describe('PalletsView', () => {
|
||||
await createButton?.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(document.body.querySelector('.pallet-editor-header')?.textContent).toContain('新增托盘')
|
||||
expect(document.body.querySelector('.pallet-editor-header')?.textContent).toContain('录入归属仓库与基础规格')
|
||||
const editorDialog = document.body.querySelector('.pallet-editor-drawer[role="dialog"]')
|
||||
const labelledBy = editorDialog?.getAttribute('aria-labelledby')
|
||||
expect(labelledBy).toBeTruthy()
|
||||
expect(document.getElementById(labelledBy || '')?.textContent).toBe('新增托盘')
|
||||
const editorDialog = document.body.querySelector('.pallet-editor-dialog')
|
||||
expect(editorDialog?.textContent).toContain('新增托盘')
|
||||
expect(editorDialog?.querySelector('.el-dialog__title')?.textContent).toBe('新增托盘')
|
||||
expect(document.body.querySelectorAll('.editor-section')).toHaveLength(2)
|
||||
expect(document.body.querySelector('#pallet-ownership-heading')?.textContent).toBe('归属仓库')
|
||||
expect(document.body.querySelector('#pallet-spec-heading')?.textContent).toBe('托盘规格')
|
||||
|
||||
Reference in New Issue
Block a user