Phase 007: migrate every remaining view from naive-ui to Arco Design Vue
The project now has exactly one UI library. Every naive-ui component in
packages/client/src is replaced by its Arco equivalent across 24 views and
roughly 80 components, and naive-ui is dropped from package.json along with
its transitive vueuc / @css-render / vdirs / seemly dependencies.
The migration is rendering-layer only. No store logic, no API contract, and
no /chat-run payload was touched.
Three classes of leftover were invisible to `grep naive-ui` and are now
covered by tests/client/no-naive-ui.test.ts, which asserts all three:
- dead .n-* class names in style blocks
- dead --n-* custom properties
- naive-ui in package.json
Notable behavioural traps handled along the way, recorded in
docs/arco-migration-rules.md:
- a-input-password defaults to masked; passing default-visibility="false"
would have exposed API keys in clear text
- a-upload fires a real XHR unless auto-upload is false
- nested Trigger components fight over the first element child, so the
group-chat settings dropdown was flattened
- Arco renders tooltip default-slot text inline, which was silently
collapsing the chat and group-chat toolbars
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// @vitest-environment jsdom
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { defineComponent } from 'vue'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import ArcoVue from '@arco-design/web-vue'
|
||||
|
||||
const messageMock = vi.hoisted(() => ({
|
||||
success: vi.fn(),
|
||||
@@ -33,34 +33,18 @@ vi.mock('vue-i18n', () => ({
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('naive-ui', () => ({
|
||||
NAlert: defineComponent({ template: '<div><slot /></div>' }),
|
||||
NButton: defineComponent({
|
||||
props: { loading: Boolean },
|
||||
emits: ['click'],
|
||||
template: '<button class="n-button-stub" :disabled="loading" @click="$emit(\'click\')"><slot /></button>',
|
||||
}),
|
||||
NEmpty: defineComponent({ props: ['description'], template: '<div>{{ description }}</div>' }),
|
||||
NInput: defineComponent({
|
||||
props: ['value', 'placeholder'],
|
||||
emits: ['update:value'],
|
||||
template: '<input :value="value" :placeholder="placeholder" @input="$emit(\'update:value\', $event.target.value)" />',
|
||||
}),
|
||||
NSelect: defineComponent({
|
||||
props: ['value', 'options', 'placeholder'],
|
||||
emits: ['update:value'],
|
||||
template: '<select><option v-for="option in options" :key="option.value" :value="option.value">{{ option.label }}</option></select>',
|
||||
}),
|
||||
NSpin: defineComponent({ template: '<div />' }),
|
||||
NTag: defineComponent({ template: '<span><slot /></span>' }),
|
||||
useMessage: () => messageMock,
|
||||
}))
|
||||
|
||||
// PluginsView reads messages via the Arco adapter layer, not naive-ui.
|
||||
vi.mock('@/composables/useMessage', () => ({ useMessage: () => messageMock }))
|
||||
|
||||
import PluginsView from '@/views/hermes/PluginsView.vue'
|
||||
|
||||
const arcoGlobal = { plugins: [ArcoVue] }
|
||||
|
||||
function buttonByText(wrapper: any, text: string) {
|
||||
const button = wrapper.findAll('button').find((node: any) => node.text().trim() === text)
|
||||
if (!button) throw new Error(`no button labelled "${text}"`)
|
||||
return button
|
||||
}
|
||||
|
||||
describe('PluginsView management actions', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
@@ -89,14 +73,10 @@ describe('PluginsView management actions', () => {
|
||||
})
|
||||
|
||||
it('enables manageable standalone plugins and refreshes the inventory', async () => {
|
||||
const wrapper = mount(PluginsView)
|
||||
const wrapper = mount(PluginsView, { global: arcoGlobal })
|
||||
await flushPromises()
|
||||
|
||||
const buttons = wrapper.findAll('.n-button-stub')
|
||||
const enableButton = buttons.find(button => button.text() === 'common.enable')
|
||||
expect(enableButton).toBeTruthy()
|
||||
|
||||
await enableButton!.trigger('click')
|
||||
await buttonByText(wrapper, 'common.enable').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(setPluginEnabledMock).toHaveBeenCalledWith('local-plugin', true)
|
||||
@@ -125,7 +105,7 @@ describe('PluginsView management actions', () => {
|
||||
metadata: null,
|
||||
})
|
||||
|
||||
const wrapper = mount(PluginsView)
|
||||
const wrapper = mount(PluginsView, { global: arcoGlobal })
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.text()).toContain('plugins.managedElsewhere')
|
||||
|
||||
Reference in New Issue
Block a user