@estiva-app/ui 0.98.0 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/AppProvider.d.ts +6 -3
- package/dist/AppProvider.d.ts.map +1 -1
- package/dist/ArchiveDialog.d.ts +35 -0
- package/dist/ArchiveDialog.d.ts.map +1 -0
- package/dist/AttachedCard.d.ts +13 -2
- package/dist/AttachedCard.d.ts.map +1 -1
- package/dist/Card.d.ts +6 -1
- package/dist/Card.d.ts.map +1 -1
- package/dist/ChipInput.d.ts +3 -1
- package/dist/ChipInput.d.ts.map +1 -1
- package/dist/CollapsibleSection.d.ts +27 -2
- package/dist/CollapsibleSection.d.ts.map +1 -1
- package/dist/CommentBox.d.ts +2 -2
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ConfirmDialog.d.ts +15 -2
- package/dist/ConfirmDialog.d.ts.map +1 -1
- package/dist/ConversationCard.d.ts +6 -1
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/ConversationLayout.d.ts +19 -4
- package/dist/ConversationLayout.d.ts.map +1 -1
- package/dist/ConversationPlace.d.ts +17 -0
- package/dist/ConversationPlace.d.ts.map +1 -0
- package/dist/DocumentEditor.d.ts +38 -0
- package/dist/DocumentEditor.d.ts.map +1 -1
- package/dist/DocumentField.d.ts +50 -0
- package/dist/DocumentField.d.ts.map +1 -0
- package/dist/EditableText.d.ts +38 -4
- package/dist/EditableText.d.ts.map +1 -1
- package/dist/EmptyState.d.ts +10 -5
- package/dist/EmptyState.d.ts.map +1 -1
- package/dist/FormDialog.d.ts +38 -0
- package/dist/FormDialog.d.ts.map +1 -0
- package/dist/InlineText.d.ts.map +1 -1
- package/dist/MoveDialog.d.ts +61 -0
- package/dist/MoveDialog.d.ts.map +1 -0
- package/dist/NavItem.d.ts +9 -2
- package/dist/NavItem.d.ts.map +1 -1
- package/dist/NavTree.d.ts +16 -3
- package/dist/NavTree.d.ts.map +1 -1
- package/dist/PinnedComment.d.ts +3 -1
- package/dist/PinnedComment.d.ts.map +1 -1
- package/dist/ReactionHorizon.d.ts +5 -1
- package/dist/ReactionHorizon.d.ts.map +1 -1
- package/dist/ResolveDialog.d.ts +3 -1
- package/dist/ResolveDialog.d.ts.map +1 -1
- package/dist/SelectionToolbar.d.ts +2 -2
- package/dist/Thread.d.ts +6 -3
- package/dist/Thread.d.ts.map +1 -1
- package/dist/commentBoxFrame.d.ts.map +1 -1
- package/dist/conversation.examples.d.ts +4 -1
- package/dist/conversation.examples.d.ts.map +1 -1
- package/dist/conversationScroll.d.ts +80 -0
- package/dist/conversationScroll.d.ts.map +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +228 -69
- package/dist/editor.js.map +4 -4
- package/dist/eslint/index.js +2 -2
- package/dist/eslint/index.js.map +2 -2
- package/dist/eslint/no-field-outside-a-form.d.ts +2 -2
- package/dist/eslint/no-field-outside-a-form.d.ts.map +1 -1
- package/dist/eslint/no-native-title.d.ts +1 -1
- package/dist/eslint/no-native-title.d.ts.map +1 -1
- package/dist/formBusy.d.ts +5 -2
- package/dist/formBusy.d.ts.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2210 -1458
- package/dist/index.js.map +4 -4
- package/dist/looks.d.ts +8 -0
- package/dist/looks.d.ts.map +1 -1
- package/dist/seenOnScreen.d.ts +27 -0
- package/dist/seenOnScreen.d.ts.map +1 -0
- package/dist/showInConversation.d.ts +31 -0
- package/dist/showInConversation.d.ts.map +1 -0
- package/dist/threadCard.d.ts +13 -0
- package/dist/threadCard.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +904 -139
- package/src/AppProvider.mdx +4 -0
- package/src/AppProvider.test.tsx +34 -2
- package/src/AppProvider.tsx +17 -6
- package/src/ArchiveDialog.mdx +70 -0
- package/src/ArchiveDialog.stories.tsx +64 -0
- package/src/ArchiveDialog.test.tsx +90 -0
- package/src/ArchiveDialog.tsx +70 -0
- package/src/AttachedCard.mdx +6 -0
- package/src/AttachedCard.stories.tsx +9 -1
- package/src/AttachedCard.test.tsx +111 -2
- package/src/AttachedCard.tsx +77 -7
- package/src/Card.mdx +20 -1
- package/src/Card.stories.tsx +20 -0
- package/src/Card.test.tsx +87 -1
- package/src/Card.tsx +51 -3
- package/src/ChipInput.mdx +7 -1
- package/src/ChipInput.stories.tsx +9 -0
- package/src/ChipInput.test.tsx +42 -0
- package/src/ChipInput.tsx +7 -3
- package/src/CollapsibleSection.mdx +20 -1
- package/src/CollapsibleSection.stories.tsx +19 -1
- package/src/CollapsibleSection.test.tsx +85 -2
- package/src/CollapsibleSection.tsx +54 -15
- package/src/CommentBox.mdx +2 -1
- package/src/CommentBox.test.tsx +81 -1
- package/src/CommentBox.tsx +32 -11
- package/src/ConfirmDialog.mdx +25 -3
- package/src/ConfirmDialog.stories.tsx +27 -0
- package/src/ConfirmDialog.test.tsx +87 -1
- package/src/ConfirmDialog.tsx +39 -8
- package/src/ConversationCard.mdx +4 -0
- package/src/ConversationCard.stories.tsx +11 -1
- package/src/ConversationCard.test.tsx +116 -0
- package/src/ConversationCard.tsx +53 -36
- package/src/ConversationLayout.mdx +30 -4
- package/src/ConversationLayout.scroll.test.tsx +411 -0
- package/src/ConversationLayout.stories.tsx +79 -1
- package/src/ConversationLayout.test.tsx +79 -0
- package/src/ConversationLayout.tsx +136 -15
- package/src/ConversationPlace.mdx +53 -0
- package/src/ConversationPlace.stories.tsx +48 -0
- package/src/ConversationPlace.test.tsx +51 -0
- package/src/ConversationPlace.tsx +30 -0
- package/src/DocumentEditor.mdx +2 -1
- package/src/DocumentEditor.tsx +118 -64
- package/src/DocumentField.mdx +83 -0
- package/src/DocumentField.stories.tsx +110 -0
- package/src/DocumentField.test.tsx +281 -0
- package/src/DocumentField.tsx +199 -0
- package/src/EditableText.buttons.test.tsx +318 -0
- package/src/EditableText.mdx +50 -2
- package/src/EditableText.stories.tsx +96 -2
- package/src/EditableText.tsx +189 -5
- package/src/EmptyState.mdx +33 -8
- package/src/EmptyState.stories.tsx +26 -1
- package/src/EmptyState.test.tsx +63 -2
- package/src/EmptyState.tsx +28 -6
- package/src/Form.mdx +3 -1
- package/src/FormDialog.mdx +78 -0
- package/src/FormDialog.stories.tsx +90 -0
- package/src/FormDialog.test.tsx +183 -0
- package/src/FormDialog.tsx +93 -0
- package/src/InlineText.mdx +1 -0
- package/src/InlineText.tsx +2 -1
- package/src/MoveDialog.mdx +74 -0
- package/src/MoveDialog.stories.tsx +121 -0
- package/src/MoveDialog.test.tsx +203 -0
- package/src/MoveDialog.tsx +183 -0
- package/src/NavItem.mdx +15 -0
- package/src/NavItem.stories.tsx +15 -0
- package/src/NavItem.test.tsx +64 -1
- package/src/NavItem.tsx +10 -2
- package/src/NavTree.mdx +26 -4
- package/src/NavTree.stories.tsx +59 -0
- package/src/NavTree.test.tsx +232 -2
- package/src/NavTree.tsx +93 -43
- package/src/PinnedComment.mdx +6 -1
- package/src/PinnedComment.stories.tsx +11 -1
- package/src/PinnedComment.tsx +15 -2
- package/src/ReactionHorizon.mdx +3 -0
- package/src/ReactionHorizon.stories.tsx +3 -0
- package/src/ReactionHorizon.test.tsx +55 -0
- package/src/ReactionHorizon.tsx +30 -11
- package/src/ReplyCard.mdx +3 -0
- package/src/ReplyCard.stories.tsx +19 -1
- package/src/ResolveDialog.mdx +2 -0
- package/src/ResolveDialog.test.tsx +21 -0
- package/src/ResolveDialog.tsx +11 -39
- package/src/SelectionToolbar.tsx +2 -2
- package/src/Textarea.mdx +1 -0
- package/src/Thread.mdx +18 -1
- package/src/Thread.stories.tsx +55 -3
- package/src/Thread.test.tsx +11 -0
- package/src/Thread.tsx +53 -11
- package/src/commentBoxFrame.tsx +2 -2
- package/src/conversation.examples.tsx +10 -2
- package/src/conversationScroll.ts +155 -0
- package/src/editor.ts +1 -0
- package/src/editorSelection.test.tsx +53 -0
- package/src/eslint/no-field-outside-a-form.test.ts +4 -0
- package/src/eslint/no-field-outside-a-form.ts +2 -2
- package/src/eslint/no-native-title.ts +1 -1
- package/src/formBusy.ts +5 -2
- package/src/index.ts +16 -6
- package/src/looks.ts +10 -0
- package/src/registry/registry.test.ts +12 -6
- package/src/seenOnScreen.test.tsx +182 -0
- package/src/seenOnScreen.ts +146 -0
- package/src/showInConversation.test.tsx +168 -0
- package/src/showInConversation.ts +93 -0
- package/src/threadCard.ts +16 -0
- package/stories/Choosing.mdx +7 -2
- package/tailwind-preset.js +7 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
/**
|
|
3
|
+
* Where a conversation scrolls (C1 of the audit of 2 November): Peek's own, moved into ConversationLayout and Thread so
|
|
4
|
+
* every app's conversation reads the same. Two columns open at the newest comment, come back to where the reader left
|
|
5
|
+
* them (by the name the app gives, `rememberAs`), follow what arrives only while the reader is at the bottom, and go
|
|
6
|
+
* down to the reader's own comment as it is sent. A thread opens at its newest reply and goes to each new one. jsdom
|
|
7
|
+
* has no layout: every box here says the same heights, and only the scrolling box's offset is read.
|
|
8
|
+
*/
|
|
9
|
+
import { useContext, type ReactNode } from 'react'
|
|
10
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
11
|
+
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
|
12
|
+
import { ConversationCard, ReplyCard } from './ConversationCard'
|
|
13
|
+
import { ConversationLayout, type ConversationItem } from './ConversationLayout'
|
|
14
|
+
import { isNearBottom, NEAR_BOTTOM_PX, places, sendsInLayout, useLeftAt } from './conversationScroll'
|
|
15
|
+
import { Thread } from './Thread'
|
|
16
|
+
|
|
17
|
+
const ONE = { name: 'Person one' }
|
|
18
|
+
|
|
19
|
+
/** What every box says of its heights, as a test sets them. */
|
|
20
|
+
const heights = { scroll: 1000, client: 400 }
|
|
21
|
+
const props = ['scrollHeight', 'clientHeight'] as const
|
|
22
|
+
const kept = props.map((p) => [p, Object.getOwnPropertyDescriptor(HTMLElement.prototype, p)] as const)
|
|
23
|
+
beforeAll(() => {
|
|
24
|
+
Object.defineProperty(HTMLElement.prototype, 'scrollHeight', { configurable: true, get: () => heights.scroll })
|
|
25
|
+
Object.defineProperty(HTMLElement.prototype, 'clientHeight', { configurable: true, get: () => heights.client })
|
|
26
|
+
})
|
|
27
|
+
afterAll(() => {
|
|
28
|
+
for (const [p, d] of kept) if (d) Object.defineProperty(HTMLElement.prototype, p, d)
|
|
29
|
+
})
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
heights.scroll = 1000
|
|
32
|
+
heights.client = 400
|
|
33
|
+
})
|
|
34
|
+
afterEach(cleanup)
|
|
35
|
+
|
|
36
|
+
const card = (id: string) => ({
|
|
37
|
+
id,
|
|
38
|
+
card: (
|
|
39
|
+
<ConversationCard author={ONE} time="11:08 AM">
|
|
40
|
+
{`Comment ${id}`}
|
|
41
|
+
</ConversationCard>
|
|
42
|
+
),
|
|
43
|
+
})
|
|
44
|
+
const many = (n: number): ConversationItem[] => Array.from({ length: n }, (_, i) => card(`c${i}`))
|
|
45
|
+
|
|
46
|
+
/** The comments' scrolling box, as the layout lends it. */
|
|
47
|
+
function Layout({ items, loading = false, rememberAs, box, boxRef }: { items: ConversationItem[]; loading?: boolean; rememberAs?: string; box?: ReactNode; boxRef: { current: HTMLDivElement | null } }) {
|
|
48
|
+
return <ConversationLayout threads="beside" items={items} loading={loading} rememberAs={rememberAs} box={box} bodyRef={boxRef} />
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The reader scrolls the box to `top`. */
|
|
52
|
+
function scrollTo(el: HTMLElement, top: number) {
|
|
53
|
+
el.scrollTop = top
|
|
54
|
+
fireEvent.scroll(el)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
describe('isNearBottom (Peek’s scroll policy, ported)', () => {
|
|
58
|
+
const el = (scrollHeight: number, scrollTop: number, clientHeight: number) => ({ scrollHeight, scrollTop, clientHeight }) as HTMLElement
|
|
59
|
+
|
|
60
|
+
it('is true when pinned to the bottom', () => {
|
|
61
|
+
expect(isNearBottom(el(1000, 600, 400))).toBe(true)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('is false once you have scrolled up to read', () => {
|
|
65
|
+
expect(isNearBottom(el(1000, 200, 400))).toBe(false)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('tolerates the sub-pixel gap a strict check would trip on', () => {
|
|
69
|
+
expect(isNearBottom(el(1000.4, 599.7, 400))).toBe(true)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('holds exactly at the threshold, and lets go one pixel past it', () => {
|
|
73
|
+
expect(isNearBottom(el(1000, 600 - NEAR_BOTTOM_PX, 400))).toBe(true)
|
|
74
|
+
expect(isNearBottom(el(1000, 600 - NEAR_BOTTOM_PX - 1, 400))).toBe(false)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('is true when there is nothing to scroll', () => {
|
|
78
|
+
expect(isNearBottom(el(400, 0, 400))).toBe(true)
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
describe('ConversationLayout, two columns, where it scrolls', () => {
|
|
83
|
+
it('opens at the newest comment, once the comments are read', () => {
|
|
84
|
+
const box = { current: null as HTMLDivElement | null }
|
|
85
|
+
const { rerender } = render(<Layout items={[]} loading boxRef={box} />)
|
|
86
|
+
expect(box.current!.scrollTop).toBe(0)
|
|
87
|
+
rerender(<Layout items={many(8)} boxRef={box} />)
|
|
88
|
+
expect(box.current!.scrollTop).toBe(1000)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('follows a new comment while the reader is at the bottom, and not once they scrolled up to read', () => {
|
|
92
|
+
const box = { current: null as HTMLDivElement | null }
|
|
93
|
+
const { rerender } = render(<Layout items={many(8)} boxRef={box} />)
|
|
94
|
+
heights.scroll = 1200
|
|
95
|
+
rerender(<Layout items={many(9)} boxRef={box} />)
|
|
96
|
+
expect(box.current!.scrollTop).toBe(1200)
|
|
97
|
+
scrollTo(box.current!, 300)
|
|
98
|
+
heights.scroll = 1400
|
|
99
|
+
rerender(<Layout items={many(10)} boxRef={box} />)
|
|
100
|
+
expect(box.current!.scrollTop).toBe(300)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('comes back to where it was left, by the name the app gave it', () => {
|
|
104
|
+
const box = { current: null as HTMLDivElement | null }
|
|
105
|
+
const { unmount } = render(<Layout items={many(8)} rememberAs="left-up" boxRef={box} />)
|
|
106
|
+
scrollTo(box.current!, 250)
|
|
107
|
+
unmount()
|
|
108
|
+
render(<Layout items={many(8)} rememberAs="left-up" boxRef={box} />)
|
|
109
|
+
expect(box.current!.scrollTop).toBe(250)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('comes back to the newest when it was left at the bottom, with what arrived meanwhile in view', () => {
|
|
113
|
+
const box = { current: null as HTMLDivElement | null }
|
|
114
|
+
const { unmount } = render(<Layout items={many(8)} rememberAs="left-down" boxRef={box} />)
|
|
115
|
+
unmount()
|
|
116
|
+
heights.scroll = 1300
|
|
117
|
+
render(<Layout items={many(10)} rememberAs="left-down" boxRef={box} />)
|
|
118
|
+
expect(box.current!.scrollTop).toBe(1300)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('opens another conversation at its newest, and the first where it was left, in one layout', () => {
|
|
122
|
+
const box = { current: null as HTMLDivElement | null }
|
|
123
|
+
const { rerender } = render(<Layout items={many(8)} rememberAs="one" boxRef={box} />)
|
|
124
|
+
scrollTo(box.current!, 200)
|
|
125
|
+
rerender(<Layout items={many(5)} rememberAs="two" boxRef={box} />)
|
|
126
|
+
expect(box.current!.scrollTop).toBe(1000)
|
|
127
|
+
rerender(<Layout items={many(8)} rememberAs="one" boxRef={box} />)
|
|
128
|
+
expect(box.current!.scrollTop).toBe(200)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('comes back to where it was left after another conversation that was still being read', () => {
|
|
132
|
+
const box = { current: null as HTMLDivElement | null }
|
|
133
|
+
const { rerender } = render(<Layout items={many(8)} rememberAs="before-a-read" boxRef={box} />)
|
|
134
|
+
scrollTo(box.current!, 200)
|
|
135
|
+
rerender(<Layout items={[]} loading rememberAs="being-read" boxRef={box} />)
|
|
136
|
+
// The placeholders are shorter: the browser pulls the offset in, and says so.
|
|
137
|
+
scrollTo(box.current!, 0)
|
|
138
|
+
rerender(<Layout items={many(8)} rememberAs="before-a-read" boxRef={box} />)
|
|
139
|
+
expect(box.current!.scrollTop).toBe(200)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('read again under the same name, lands where the reader left it, not where the placeholders pulled it', () => {
|
|
143
|
+
const box = { current: null as HTMLDivElement | null }
|
|
144
|
+
const { rerender } = render(<Layout items={many(8)} rememberAs="read-again" boxRef={box} />)
|
|
145
|
+
scrollTo(box.current!, 200)
|
|
146
|
+
rerender(<Layout items={[]} loading rememberAs="read-again" boxRef={box} />)
|
|
147
|
+
scrollTo(box.current!, 0)
|
|
148
|
+
rerender(<Layout items={many(8)} rememberAs="read-again" boxRef={box} />)
|
|
149
|
+
expect(box.current!.scrollTop).toBe(200)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('without a name, opens at the newest each time it is drawn', () => {
|
|
153
|
+
const box = { current: null as HTMLDivElement | null }
|
|
154
|
+
const { unmount } = render(<Layout items={many(8)} boxRef={box} />)
|
|
155
|
+
scrollTo(box.current!, 250)
|
|
156
|
+
unmount()
|
|
157
|
+
render(<Layout items={many(8)} boxRef={box} />)
|
|
158
|
+
expect(box.current!.scrollTop).toBe(1000)
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('goes down to the reader’s own comment as it is sent, scrolled up or not; a refusal leaves them where they are', () => {
|
|
162
|
+
let sends: { sending: () => void; refused: () => void } | null = null
|
|
163
|
+
function Box() {
|
|
164
|
+
sends = useContext(sendsInLayout)
|
|
165
|
+
return <p>The box</p>
|
|
166
|
+
}
|
|
167
|
+
const box = { current: null as HTMLDivElement | null }
|
|
168
|
+
const { rerender } = render(<Layout items={many(8)} box={<Box />} boxRef={box} />)
|
|
169
|
+
expect(sends).not.toBeNull()
|
|
170
|
+
scrollTo(box.current!, 300)
|
|
171
|
+
act(() => sends!.sending())
|
|
172
|
+
heights.scroll = 1200
|
|
173
|
+
rerender(<Layout items={many(9)} box={<Box />} boxRef={box} />)
|
|
174
|
+
expect(box.current!.scrollTop).toBe(1200)
|
|
175
|
+
// Scrolled up again; a send that was refused: where the reader is decides what follows next.
|
|
176
|
+
scrollTo(box.current!, 300)
|
|
177
|
+
act(() => sends!.sending())
|
|
178
|
+
act(() => sends!.refused())
|
|
179
|
+
heights.scroll = 1400
|
|
180
|
+
rerender(<Layout items={many(10)} box={<Box />} boxRef={box} />)
|
|
181
|
+
expect(box.current!.scrollTop).toBe(300)
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('one column keeps where the reader is: it opens at the top, and follows nothing', () => {
|
|
185
|
+
const box = { current: null as HTMLDivElement | null }
|
|
186
|
+
function Under({ n }: { n: number }) {
|
|
187
|
+
return <ConversationLayout threads="under" items={many(n)} bodyRef={box} />
|
|
188
|
+
}
|
|
189
|
+
const { rerender } = render(<Under n={8} />)
|
|
190
|
+
expect(box.current!.scrollTop).toBe(0)
|
|
191
|
+
heights.scroll = 1200
|
|
192
|
+
rerender(<Under n={9} />)
|
|
193
|
+
expect(box.current!.scrollTop).toBe(0)
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
describe('useLeftAt: when the reader left a conversation, for its "New" line', () => {
|
|
198
|
+
function LeftAt({ at, boxRef, items }: { at: string; boxRef: { current: HTMLDivElement | null }; items: ConversationItem[] }) {
|
|
199
|
+
const left = useLeftAt(at)
|
|
200
|
+
return (
|
|
201
|
+
<>
|
|
202
|
+
<output data-testid="left">{left === null ? 'none' : String(left)}</output>
|
|
203
|
+
<Layout items={items} rememberAs={at} boxRef={boxRef} />
|
|
204
|
+
</>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
beforeEach(() => {
|
|
209
|
+
vi.useFakeTimers({ toFake: ['Date'] })
|
|
210
|
+
vi.setSystemTime(1_800_000_000_000)
|
|
211
|
+
})
|
|
212
|
+
afterEach(() => vi.useRealTimers())
|
|
213
|
+
|
|
214
|
+
it('says when it was left away from the newest, taken once as it opens; none when it was left at the bottom or never opened', () => {
|
|
215
|
+
const box = { current: null as HTMLDivElement | null }
|
|
216
|
+
const first = render(<LeftAt at="read-up" items={many(8)} boxRef={box} />)
|
|
217
|
+
expect(screen.getByTestId('left').textContent).toBe('none')
|
|
218
|
+
scrollTo(box.current!, 200)
|
|
219
|
+
vi.setSystemTime(1_800_000_060_000)
|
|
220
|
+
first.unmount()
|
|
221
|
+
vi.setSystemTime(1_800_000_120_000)
|
|
222
|
+
const back = render(<LeftAt at="read-up" items={many(9)} boxRef={box} />)
|
|
223
|
+
expect(screen.getByTestId('left').textContent).toBe('1800000060000')
|
|
224
|
+
// Later scrolling moves the record, not the line.
|
|
225
|
+
scrollTo(box.current!, 1000)
|
|
226
|
+
back.rerender(<LeftAt at="read-up" items={many(9)} boxRef={box} />)
|
|
227
|
+
expect(screen.getByTestId('left').textContent).toBe('1800000060000')
|
|
228
|
+
back.unmount()
|
|
229
|
+
render(<LeftAt at="read-up" items={many(9)} boxRef={box} />)
|
|
230
|
+
expect(screen.getByTestId('left').textContent).toBe('none')
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
it('takes it again on the next visit when nothing was shown between, not the last visit’s', () => {
|
|
234
|
+
function Left({ at }: { at: string | null }) {
|
|
235
|
+
const left = useLeftAt(at)
|
|
236
|
+
return <output data-testid="left">{left === null ? 'none' : String(left)}</output>
|
|
237
|
+
}
|
|
238
|
+
places.set('between', { atBottom: false, offset: 10, leftAt: 111 })
|
|
239
|
+
const page = render(<Left at="between" />)
|
|
240
|
+
expect(screen.getByTestId('left').textContent).toBe('111')
|
|
241
|
+
page.rerender(<Left at={null} />)
|
|
242
|
+
expect(screen.getByTestId('left').textContent).toBe('none')
|
|
243
|
+
// Meanwhile the reader read it to the newest and left it there.
|
|
244
|
+
places.set('between', { atBottom: true, offset: 900, leftAt: 222 })
|
|
245
|
+
page.rerender(<Left at="between" />)
|
|
246
|
+
expect(screen.getByTestId('left').textContent).toBe('none')
|
|
247
|
+
})
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
const START = { id: 't1', author: ONE, time: '11:08 AM', words: 'The comment' }
|
|
251
|
+
function Replies({ n, start = START, boxRef }: { n: number; start?: typeof START; boxRef: { current: HTMLDivElement | null } }) {
|
|
252
|
+
return (
|
|
253
|
+
<Thread start={start} bodyRef={boxRef}>
|
|
254
|
+
{Array.from({ length: n }, (_, i) => (
|
|
255
|
+
<ReplyCard key={i} id={`r${i}`} author={ONE} time="11:30 AM">
|
|
256
|
+
{`Reply ${i}`}
|
|
257
|
+
</ReplyCard>
|
|
258
|
+
))}
|
|
259
|
+
{/* Not a reply: an app's own line among them (Peek's resolve history) takes it nowhere. */}
|
|
260
|
+
<p>A line of the app’s</p>
|
|
261
|
+
</Thread>
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
describe('Thread, beside: where it scrolls', () => {
|
|
266
|
+
it('opens at its newest reply', () => {
|
|
267
|
+
const box = { current: null as HTMLDivElement | null }
|
|
268
|
+
render(<Replies n={4} boxRef={box} />)
|
|
269
|
+
expect(box.current!.scrollTop).toBe(1000)
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
it('goes to each new reply, wherever the reader is in it', () => {
|
|
273
|
+
const box = { current: null as HTMLDivElement | null }
|
|
274
|
+
const { rerender } = render(<Replies n={4} boxRef={box} />)
|
|
275
|
+
scrollTo(box.current!, 100)
|
|
276
|
+
heights.scroll = 1200
|
|
277
|
+
rerender(<Replies n={5} boxRef={box} />)
|
|
278
|
+
expect(box.current!.scrollTop).toBe(1200)
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
it('stays where the reader is when nothing new is a reply', () => {
|
|
282
|
+
const box = { current: null as HTMLDivElement | null }
|
|
283
|
+
const { rerender } = render(<Replies n={4} boxRef={box} />)
|
|
284
|
+
scrollTo(box.current!, 100)
|
|
285
|
+
heights.scroll = 1200
|
|
286
|
+
rerender(<Replies n={4} boxRef={box} />)
|
|
287
|
+
expect(box.current!.scrollTop).toBe(100)
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
it('opens another thread at its newest reply, as many replies as it has', () => {
|
|
291
|
+
const box = { current: null as HTMLDivElement | null }
|
|
292
|
+
const { rerender } = render(<Replies n={4} boxRef={box} />)
|
|
293
|
+
scrollTo(box.current!, 100)
|
|
294
|
+
rerender(<Replies n={4} start={{ ...START, id: 't2' }} boxRef={box} />)
|
|
295
|
+
expect(box.current!.scrollTop).toBe(1000)
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
it('stays where the reader is when a reply is taken away (a delete)', () => {
|
|
299
|
+
const box = { current: null as HTMLDivElement | null }
|
|
300
|
+
const { rerender } = render(<Replies n={4} boxRef={box} />)
|
|
301
|
+
scrollTo(box.current!, 100)
|
|
302
|
+
heights.scroll = 800
|
|
303
|
+
rerender(<Replies n={3} boxRef={box} />)
|
|
304
|
+
expect(box.current!.scrollTop).toBe(100)
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
it('opens another thread at its newest reply with no start id too, as many replies as it has', () => {
|
|
308
|
+
const box = { current: null as HTMLDivElement | null }
|
|
309
|
+
// Each reply keyed by its own id, as an app's list is.
|
|
310
|
+
function Other({ who }: { who: string }) {
|
|
311
|
+
return (
|
|
312
|
+
<Thread bodyRef={box}>
|
|
313
|
+
{Array.from({ length: 4 }, (_, i) => (
|
|
314
|
+
<ReplyCard key={`${who}${i}`} id={`${who}${i}`} author={ONE} time="11:30 AM">
|
|
315
|
+
{`Reply ${i} of ${who}`}
|
|
316
|
+
</ReplyCard>
|
|
317
|
+
))}
|
|
318
|
+
</Thread>
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
const { rerender } = render(<Other who="a" />)
|
|
322
|
+
scrollTo(box.current!, 100)
|
|
323
|
+
rerender(<Other who="b" />)
|
|
324
|
+
expect(box.current!.scrollTop).toBe(1000)
|
|
325
|
+
})
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Holding still while cards, chips and pictures fill in (Peek's OPT-10): the box is watched for changes of size. jsdom
|
|
330
|
+
* has none, and no layout: here a stand-in watcher is told when something changed size, the box keeps its offset
|
|
331
|
+
* between 0 and its height less its view as a browser does, and each card says where its top is.
|
|
332
|
+
*/
|
|
333
|
+
describe('holding still while cards load', () => {
|
|
334
|
+
const watchers = new Set<() => void>()
|
|
335
|
+
class Watcher {
|
|
336
|
+
private readonly changed: () => void
|
|
337
|
+
constructor(changed: () => void) {
|
|
338
|
+
this.changed = changed
|
|
339
|
+
}
|
|
340
|
+
observe() {
|
|
341
|
+
watchers.add(this.changed)
|
|
342
|
+
}
|
|
343
|
+
disconnect() {
|
|
344
|
+
watchers.delete(this.changed)
|
|
345
|
+
}
|
|
346
|
+
unobserve() {}
|
|
347
|
+
}
|
|
348
|
+
/** Something in the box changed size: every watcher is told, as a browser tells them after layout. */
|
|
349
|
+
const resized = () => act(() => watchers.forEach((changed) => changed()))
|
|
350
|
+
const offsets = new WeakMap<Element, number>()
|
|
351
|
+
const tops = new WeakMap<Element, number>()
|
|
352
|
+
const hadWatcher = globalThis.ResizeObserver
|
|
353
|
+
beforeAll(() => {
|
|
354
|
+
globalThis.ResizeObserver = Watcher as unknown as typeof ResizeObserver
|
|
355
|
+
Object.defineProperty(HTMLElement.prototype, 'scrollTop', {
|
|
356
|
+
configurable: true,
|
|
357
|
+
get(this: HTMLElement) {
|
|
358
|
+
return offsets.get(this) ?? 0
|
|
359
|
+
},
|
|
360
|
+
set(this: HTMLElement, top: number) {
|
|
361
|
+
offsets.set(this, Math.max(0, Math.min(top, this.scrollHeight - this.clientHeight)))
|
|
362
|
+
},
|
|
363
|
+
})
|
|
364
|
+
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) {
|
|
365
|
+
return new DOMRect(0, tops.get(this) ?? 0, 300, 40)
|
|
366
|
+
})
|
|
367
|
+
})
|
|
368
|
+
afterAll(() => {
|
|
369
|
+
globalThis.ResizeObserver = hadWatcher
|
|
370
|
+
delete (HTMLElement.prototype as { scrollTop?: number }).scrollTop
|
|
371
|
+
vi.restoreAllMocks()
|
|
372
|
+
delete (document as { elementFromPoint?: unknown }).elementFromPoint
|
|
373
|
+
})
|
|
374
|
+
afterEach(() => watchers.clear())
|
|
375
|
+
|
|
376
|
+
it('two columns, at the newest: a picture filling in above keeps the newest comments in view', () => {
|
|
377
|
+
const box = { current: null as HTMLDivElement | null }
|
|
378
|
+
render(<Layout items={many(8)} boxRef={box} />)
|
|
379
|
+
expect(box.current!.scrollTop).toBe(600)
|
|
380
|
+
heights.scroll = 1300
|
|
381
|
+
resized()
|
|
382
|
+
expect(box.current!.scrollTop).toBe(900)
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
it('two columns, scrolled up to read: the comment at the top of the view stays at its height', () => {
|
|
386
|
+
const box = { current: null as HTMLDivElement | null }
|
|
387
|
+
render(<Layout items={many(8)} boxRef={box} />)
|
|
388
|
+
const card = document.querySelector('[data-conversation-item="c3"]')!.firstElementChild!
|
|
389
|
+
tops.set(card, 30)
|
|
390
|
+
document.elementFromPoint = () => card
|
|
391
|
+
scrollTo(box.current!, 200)
|
|
392
|
+
// A card above it grows by 50px: it is pushed down, and the view follows it.
|
|
393
|
+
tops.set(card, 80)
|
|
394
|
+
heights.scroll = 1050
|
|
395
|
+
resized()
|
|
396
|
+
expect(box.current!.scrollTop).toBe(250)
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
it('a thread at its newest reply stays there while a reply’s picture fills in, and a reader who scrolled up stays put', () => {
|
|
400
|
+
const box = { current: null as HTMLDivElement | null }
|
|
401
|
+
render(<Replies n={4} boxRef={box} />)
|
|
402
|
+
expect(box.current!.scrollTop).toBe(600)
|
|
403
|
+
heights.scroll = 1300
|
|
404
|
+
resized()
|
|
405
|
+
expect(box.current!.scrollTop).toBe(900)
|
|
406
|
+
scrollTo(box.current!, 100)
|
|
407
|
+
heights.scroll = 1500
|
|
408
|
+
resized()
|
|
409
|
+
expect(box.current!.scrollTop).toBe(100)
|
|
410
|
+
})
|
|
411
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
import { useState } from 'react'
|
|
2
|
+
import { useState, type ReactNode } from 'react'
|
|
3
3
|
import { ConversationCard, ReplyCard } from './ConversationCard'
|
|
4
4
|
import { ConversationLayout, type ConversationItem } from './ConversationLayout'
|
|
5
5
|
import { ONE, SHORT, SOME, THREE, TWO, WORDS, WriteBox, YOU, useReactions } from './conversation.examples'
|
|
@@ -8,6 +8,7 @@ import { Panel } from './Panel'
|
|
|
8
8
|
import { ReactionHorizon } from './ReactionHorizon'
|
|
9
9
|
import { QuotedLine } from './QuotedLine'
|
|
10
10
|
import { SkeletonBar } from './Skeleton'
|
|
11
|
+
import { useSeenOnScreen } from './seenOnScreen'
|
|
11
12
|
import { Thread } from './Thread'
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -107,6 +108,31 @@ export const TwoColumns: Story = {
|
|
|
107
108
|
},
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Two columns with the page's own panel: while no thread is open, the 384px column holds it (Peek's Overview); a
|
|
113
|
+
* thread opened takes its place, and closing it brings the panel back. Each thread is drawn only while it is open.
|
|
114
|
+
*/
|
|
115
|
+
export const TwoColumnsAside: Story = {
|
|
116
|
+
name: 'Two columns, with a panel',
|
|
117
|
+
render: function Render() {
|
|
118
|
+
const [open, setOpen] = useState<string | undefined>(undefined)
|
|
119
|
+
const items = useItems('beside', open, setOpen, false).map((item) => {
|
|
120
|
+
const thread = item.thread as ReactNode
|
|
121
|
+
return { ...item, thread: () => thread }
|
|
122
|
+
})
|
|
123
|
+
return (
|
|
124
|
+
<ConversationLayout
|
|
125
|
+
threads="beside"
|
|
126
|
+
items={items}
|
|
127
|
+
open={open}
|
|
128
|
+
onOpenChange={setOpen}
|
|
129
|
+
aside={<Page />}
|
|
130
|
+
box={<WriteBox label="Comment" />}
|
|
131
|
+
/>
|
|
132
|
+
)
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
|
|
110
136
|
/**
|
|
111
137
|
* Two columns, as Peek's file page and DMs: each day's comments under a line naming it, which stays at the top while
|
|
112
138
|
* its stretch scrolls; the reactions note under the comments. Few comments sit on the box, as a chat does.
|
|
@@ -129,6 +155,58 @@ export const TwoColumnsDays: Story = {
|
|
|
129
155
|
},
|
|
130
156
|
}
|
|
131
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Two columns, a long conversation: it opens at the newest comment; scrolled up, it stays where the reader is while
|
|
160
|
+
* comments arrive; at the bottom, it follows them. Write one: it goes down to it as it is drawn, scrolled up or not.
|
|
161
|
+
* Its place is remembered by `rememberAs`: open another story and come back, and it is where it was left.
|
|
162
|
+
*/
|
|
163
|
+
export const TwoColumnsLong: Story = {
|
|
164
|
+
name: 'Two columns, long',
|
|
165
|
+
render: function Render() {
|
|
166
|
+
const [said, setSaid] = useState<{ who: typeof ONE; words: string }[]>(() =>
|
|
167
|
+
Array.from({ length: 14 }, (_, i) => ({ who: [ONE, TWO, THREE][i % 3], words: i % 4 === 0 ? WORDS : `Comment ${i + 1} of a long conversation.` })),
|
|
168
|
+
)
|
|
169
|
+
const items: ConversationItem[] = said.map((c, i) => ({
|
|
170
|
+
id: `l${i}`,
|
|
171
|
+
day: i < 7 ? 'Monday' : 'Today',
|
|
172
|
+
card: (
|
|
173
|
+
<ConversationCard author={c.who} time={`${8 + (i % 7)}:${i % 2 ? '30' : '05'} AM`}>
|
|
174
|
+
{c.words}
|
|
175
|
+
</ConversationCard>
|
|
176
|
+
),
|
|
177
|
+
}))
|
|
178
|
+
return (
|
|
179
|
+
<ConversationLayout
|
|
180
|
+
threads="beside"
|
|
181
|
+
rememberAs="story-long"
|
|
182
|
+
items={items}
|
|
183
|
+
box={<WriteBox label="Comment" onSend={(words) => setSaid((now) => [...now, { who: YOU, words: words || 'Your comment.' }])} />}
|
|
184
|
+
/>
|
|
185
|
+
)
|
|
186
|
+
},
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Two columns, read by being seen: each comment new to the reader keeps its dot until it has been on screen a moment
|
|
191
|
+
* (`useSeenOnScreen`, handed to `seen`). Scroll, and the ones that show lose it after 1.5 seconds.
|
|
192
|
+
*/
|
|
193
|
+
export const TwoColumnsSeen: Story = {
|
|
194
|
+
name: 'Two columns, new until seen',
|
|
195
|
+
render: function Render() {
|
|
196
|
+
const seen = useSeenOnScreen('story')
|
|
197
|
+
const words = [WORDS, 'A second comment.', 'A third comment, further down.', 'A fourth comment.', 'A fifth comment.', 'A sixth comment.', 'The newest comment.']
|
|
198
|
+
const items: ConversationItem[] = words.map((said, i) => ({
|
|
199
|
+
id: `n${i}`,
|
|
200
|
+
card: (
|
|
201
|
+
<ConversationCard author={i % 2 ? TWO : ONE} time={`${9 + i}:00 AM`} isNew={i >= 3 && !seen.ids.has(`n${i}`)}>
|
|
202
|
+
{said}
|
|
203
|
+
</ConversationCard>
|
|
204
|
+
),
|
|
205
|
+
}))
|
|
206
|
+
return <ConversationLayout threads="beside" seen={seen} items={items} box={<WriteBox label="Comment" />} />
|
|
207
|
+
},
|
|
208
|
+
}
|
|
209
|
+
|
|
132
210
|
/** Two columns, an archived file: its card at the top however few the comments, the box's line saying why nothing can be written. */
|
|
133
211
|
export const TwoColumnsArchived: Story = {
|
|
134
212
|
name: 'Two columns, archived',
|
|
@@ -338,3 +338,82 @@ describe('ConversationLayout, two columns, what an app with its own list keeps (
|
|
|
338
338
|
expect(screen.queryByText('No comments yet.')).toBeNull()
|
|
339
339
|
})
|
|
340
340
|
})
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The right column holds what the page shows beside its comments when no thread is open (B1 of the audit of 2 November):
|
|
344
|
+
* Peek's Overview, which Peek drew in a 380px column of its own, with the thread put in it by hand. Now the layout's
|
|
345
|
+
* 384px column holds both.
|
|
346
|
+
*/
|
|
347
|
+
describe('ConversationLayout, two columns, the right column', () => {
|
|
348
|
+
const column = () => document.querySelector('.border-l') as HTMLElement | null
|
|
349
|
+
|
|
350
|
+
it('shows the app’s aside while no thread is open, and the thread in its place while one is', () => {
|
|
351
|
+
function Page() {
|
|
352
|
+
const [open, setOpen] = useState<string | undefined>()
|
|
353
|
+
return <ConversationLayout threads="beside" items={items('beside')} open={open} onOpenChange={setOpen} aside={<p>The overview</p>} />
|
|
354
|
+
}
|
|
355
|
+
render(<Page />)
|
|
356
|
+
expect(column()?.textContent).toBe('The overview')
|
|
357
|
+
expect(column()?.className).toContain('w-[384px]')
|
|
358
|
+
fireEvent.click(screen.getByText('With replies'))
|
|
359
|
+
expect(screen.queryByText('The overview')).toBeNull()
|
|
360
|
+
expect(column()?.textContent).toContain('A reply')
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
it('a thread the app draws only while it is open (a function) opens from its card, and is drawn only then', () => {
|
|
364
|
+
const drawn = vi.fn((words: string) => <Thread start={{ author: ONE, time: '11:08 AM', words }}><p>Replies to {words}</p></Thread>)
|
|
365
|
+
function Page() {
|
|
366
|
+
const [open, setOpen] = useState<string | undefined>()
|
|
367
|
+
const list: ConversationItem[] = ['First', 'Second'].map((words) => ({
|
|
368
|
+
id: words,
|
|
369
|
+
card: <ConversationCard author={ONE} time="11:08 AM">{words}</ConversationCard>,
|
|
370
|
+
thread: () => drawn(words),
|
|
371
|
+
}))
|
|
372
|
+
return <ConversationLayout threads="beside" items={list} open={open} onOpenChange={setOpen} />
|
|
373
|
+
}
|
|
374
|
+
render(<Page />)
|
|
375
|
+
expect(drawn).not.toHaveBeenCalled()
|
|
376
|
+
fireEvent.click(screen.getByText('Second'))
|
|
377
|
+
expect(screen.getByText('Replies to Second')).toBeTruthy()
|
|
378
|
+
expect(drawn.mock.calls.every(([words]) => words === 'Second')).toBe(true)
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
it('keeps the comments when what is in the column throws: the column says so in its place', () => {
|
|
382
|
+
const quiet = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
383
|
+
function Throws(): never {
|
|
384
|
+
throw new Error('an aside that throws')
|
|
385
|
+
}
|
|
386
|
+
render(<ConversationLayout threads="beside" items={items('beside')} aside={<Throws />} />)
|
|
387
|
+
expect(screen.getByText('With replies')).toBeTruthy()
|
|
388
|
+
expect(column()?.textContent).toContain('Something went wrong in the thread panel.')
|
|
389
|
+
quiet.mockRestore()
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
it('lets a thread that threw go: closing it draws the aside again, and another thread draws itself', () => {
|
|
393
|
+
const quiet = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
394
|
+
function Throws(): never {
|
|
395
|
+
throw new Error('a thread that throws')
|
|
396
|
+
}
|
|
397
|
+
const list: ConversationItem[] = [
|
|
398
|
+
{ id: 'c1', card: <ConversationCard author={ONE} time="11:08 AM">First</ConversationCard>, thread: <Throws /> },
|
|
399
|
+
{ id: 'c2', card: <ConversationCard author={ONE} time="11:08 AM">Second</ConversationCard>, thread: <p>Thread two</p> },
|
|
400
|
+
]
|
|
401
|
+
try {
|
|
402
|
+
const { rerender } = render(<ConversationLayout threads="beside" items={list} open="c1" aside={<p>The overview</p>} />)
|
|
403
|
+
expect(column()?.textContent).toContain('Something went wrong in the thread panel.')
|
|
404
|
+
rerender(<ConversationLayout threads="beside" items={list} aside={<p>The overview</p>} />)
|
|
405
|
+
expect(column()?.textContent).toBe('The overview')
|
|
406
|
+
rerender(<ConversationLayout threads="beside" items={list} open="c1" aside={<p>The overview</p>} />)
|
|
407
|
+
expect(column()?.textContent).toContain('Something went wrong in the thread panel.')
|
|
408
|
+
rerender(<ConversationLayout threads="beside" items={list} open="c2" aside={<p>The overview</p>} />)
|
|
409
|
+
expect(column()?.textContent).toBe('Thread two')
|
|
410
|
+
} finally {
|
|
411
|
+
quiet.mockRestore()
|
|
412
|
+
}
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
it('draws no column with no aside and no thread open', () => {
|
|
416
|
+
render(<ConversationLayout threads="beside" items={items('beside')} />)
|
|
417
|
+
expect(column()).toBeNull()
|
|
418
|
+
})
|
|
419
|
+
})
|