diff --git a/src/App.spec.ts b/src/App.spec.ts index 787d06c..5e01a05 100644 --- a/src/App.spec.ts +++ b/src/App.spec.ts @@ -5,6 +5,7 @@ import { createMemoryHistory } from 'vue-router' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { SCHEMA_VERSION } from '@/data/schema' +import { useTaskStore } from '@/stores/tasks' import App from './App.vue' import { createAppRouter } from './router' @@ -98,6 +99,22 @@ describe('App 端到端(真实 localStorage)', () => { expect(wrapper.findComponent({ name: 'PwaUpdatePrompt' }).exists()).toBe(true) wrapper.unmount() }) + + it('存储异常提示在应用级可见,切换视图也不消失', async () => { + const { wrapper, router } = await mountApp('/today') + + const store = useTaskStore() + store.notice = '本地存储不可用' + await nextTick() + + expect(wrapper.find('[role="alert"]').text()).toContain('本地存储不可用') + + await router.push('/') + await nextTick() + + expect(wrapper.find('[role="alert"]').text()).toContain('本地存储不可用') + wrapper.unmount() + }) }) describe('App 路由', () => { diff --git a/src/App.vue b/src/App.vue index 698b746..de95107 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,4 +1,5 @@