提交 744a8039 authored 作者: 王鹏飞's avatar 王鹏飞

docs: strengthen learning state proof

上级 d96aed69
...@@ -885,7 +885,7 @@ describe('useLibraryQueryState', () => { ...@@ -885,7 +885,7 @@ describe('useLibraryQueryState', () => {
it('restores typed state from the URL', () => { it('restores typed state from the URL', () => {
const { result } = renderHook(() => useLibraryQueryState(), { const { result } = renderHook(() => useLibraryQueryState(), {
wrapper: withNuqsTestingAdapter({ wrapper: withNuqsTestingAdapter({
searchParams: '?q=AI&category=12&sort=latest&page=2&tab=all', searchParams: '?q=AI&category=12&sort=latest&page=2&tab=all&dialog=book&bookId=100',
}), }),
}) })
...@@ -895,6 +895,8 @@ describe('useLibraryQueryState', () => { ...@@ -895,6 +895,8 @@ describe('useLibraryQueryState', () => {
sort: 'latest', sort: 'latest',
page: 2, page: 2,
tab: 'all', tab: 'all',
dialog: 'book',
bookId: '100',
}) })
}) })
...@@ -920,13 +922,14 @@ Create `apps/learning/src/modules/library/query.test.ts`: ...@@ -920,13 +922,14 @@ Create `apps/learning/src/modules/library/query.test.ts`:
```ts ```ts
import { describe, expect, it } from 'vitest' import { describe, expect, it } from 'vitest'
import { libraryKeys } from './query' import { libraryKeys } from './query'
import type { LibrarySearchState } from './query-state'
describe('libraryKeys', () => { describe('libraryKeys', () => {
it('includes server inputs and excludes dialog state', () => { it('includes server inputs and excludes dialog state', () => {
const state = { const state = {
q: 'AI', category: '12', sort: 'latest', page: 2, q: 'AI', category: '12', sort: 'latest', page: 2,
tab: 'all' as const, dialog: 'book' as const, bookId: '100', tab: 'all', dialog: 'book', bookId: '100',
} } satisfies LibrarySearchState
expect(libraryKeys.list(state)).toEqual([ expect(libraryKeys.list(state)).toEqual([
'library', 'library',
'list', 'list',
...@@ -1205,10 +1208,11 @@ Run: ...@@ -1205,10 +1208,11 @@ Run:
```bash ```bash
pnpm test:learning pnpm test:learning
pnpm build:learning pnpm build:learning
pnpm lint:learning
test -f dist/learning/index.html test -f dist/learning/index.html
``` ```
Expected: all tests pass and the build exits 0. Expected: all tests, lint, and the build exit 0.
- [ ] **Step 8: Verify forbidden state dependencies are absent** - [ ] **Step 8: Verify forbidden state dependencies are absent**
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论