test: 主题相关测试显式固定浅色环境避免默认玻璃主题影响断言

This commit is contained in:
jxxghp
2026-08-16 09:05:02 +08:00
parent 7b1765e43a
commit 5bb93bd26b
2 changed files with 5 additions and 0 deletions
@@ -1,5 +1,6 @@
import SiteUserDataDialog from '@/components/dialog/SiteUserDataDialog.vue'
import type { SiteUserData } from '@/api/types'
import vuetify from '@/plugins/vuetify'
import { fireEvent, screen, waitFor } from '@testing-library/vue'
import { createSite, createSiteUserData } from '@tests/support/factories/site'
import { refreshSiteUserDataHandler, siteUserDataHandler } from '@tests/support/msw/handlers/site'
@@ -97,6 +98,8 @@ function getRetryButton() {
describe('SiteUserDataDialog projections', () => {
beforeEach(() => {
chartInputs.length = 0
// 图表明暗断言基于浅色环境,显式固定主题避免受应用默认主题影响。
vuetify.theme.global.name.value = 'light'
vi.spyOn(console, 'error').mockImplementation(() => {})
vi.spyOn(console, 'log').mockImplementation(() => {})
})
@@ -232,6 +232,8 @@ describe('AccountSettingNotification', () => {
it('loads, edits, and saves a template while pausing refresh and following the active theme', async () => {
const previousTheme = vuetify.theme.global.name.value
// 从浅色主题起步验证编辑器跟随主题切换,不受应用默认主题影响。
vuetify.theme.global.name.value = 'light'
const controller = createDialogController()
mocks.openSharedDialog.mockReturnValue(controller)