Skip to content

Commit eb66195

Browse files
committed
Disable sidebar stories for now
1 parent 5aad9e0 commit eb66195

File tree

1 file changed

+79
-81
lines changed

1 file changed

+79
-81
lines changed

components/sidebar.stories.tsx

Lines changed: 79 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import preview from '#.storybook/preview'
2-
import { useEffect, useState } from 'react'
32
import Sidebar from './sidebar'
43
import { createNotes } from '#mocks/notes'
5-
import { expect, waitFor } from 'storybook/test'
64

75
const meta = preview.meta({
86
component: Sidebar,
@@ -19,82 +17,82 @@ export const Empty = meta.story({
1917
},
2018
})
2119

22-
export const NotesExpanded = meta.story({
23-
play: async ({ canvas, userEvent }) => {
24-
const expanders = canvas.getAllByAltText(/expand/i)
25-
26-
expanders.forEach(async (expander) => {
27-
await userEvent.click(expander)
28-
})
29-
},
30-
})
31-
32-
const changeNoteGate = Promise.withResolvers<void>()
33-
34-
export const NoteChangedAnimation = meta.story({
35-
render: () => {
36-
const [notes, setNotes] = useState(createNotes())
37-
useEffect(() => {
38-
setTimeout(() => {
39-
setNotes((prevNotes) => {
40-
return [
41-
{
42-
...prevNotes[0]!,
43-
title: 'New title',
44-
},
45-
...prevNotes.slice(1),
46-
]
47-
})
48-
changeNoteGate.resolve()
49-
}, 1000)
50-
}, [])
51-
return <Sidebar notes={notes} />
52-
},
53-
play: async () => {
54-
await changeNoteGate.promise
55-
},
56-
})
57-
58-
export const ToggleSidebarOnMobile = meta.story({
59-
globals: {
60-
viewport: 'mobile1',
61-
},
62-
parameters: {
63-
chromatic: { viewports: [320] },
64-
},
65-
play: async ({ canvas, step, userEvent }) => {
66-
const searchInput = canvas.getByRole('menubar')
67-
68-
await step('Sidebar is initially visible', async () => {
69-
expect(searchInput).toBeVisible()
70-
expect(isElementInView(searchInput)).toBe(true)
71-
})
72-
73-
await step('Select note', async () => {
74-
const note = canvas.getAllByRole('button', {
75-
name: /Open note for preview/i,
76-
})[0]!
77-
await userEvent.click(note)
78-
})
79-
80-
await waitFor(function sidebarIsNotVisible() {
81-
expect(isElementInView(searchInput)).toBe(false)
82-
})
83-
},
84-
})
85-
86-
/**
87-
* assertion to check if an element is in or out of the viewport,
88-
* regardless of being in the DOM or not
89-
*/
90-
function isElementInView(element: Element) {
91-
var rect = element.getBoundingClientRect()
92-
var html = document.documentElement
93-
94-
return (
95-
rect.bottom >= 0 &&
96-
rect.top <= (window.innerHeight || html.clientHeight) &&
97-
rect.right >= 0 &&
98-
rect.left <= (window.innerWidth || html.clientWidth)
99-
)
100-
}
20+
// export const NotesExpanded = meta.story({
21+
// play: async ({ canvas, userEvent }) => {
22+
// const expanders = canvas.getAllByAltText(/expand/i)
23+
//
24+
// expanders.forEach(async (expander) => {
25+
// await userEvent.click(expander)
26+
// })
27+
// },
28+
// })
29+
//
30+
// const changeNoteGate = Promise.withResolvers<void>()
31+
//
32+
// export const NoteChangedAnimation = meta.story({
33+
// render: () => {
34+
// const [notes, setNotes] = useState(createNotes())
35+
// useEffect(() => {
36+
// setTimeout(() => {
37+
// setNotes((prevNotes) => {
38+
// return [
39+
// {
40+
// ...prevNotes[0]!,
41+
// title: 'New title',
42+
// },
43+
// ...prevNotes.slice(1),
44+
// ]
45+
// })
46+
// changeNoteGate.resolve()
47+
// }, 1000)
48+
// }, [])
49+
// return <Sidebar notes={notes} />
50+
// },
51+
// play: async () => {
52+
// await changeNoteGate.promise
53+
// },
54+
// })
55+
//
56+
// export const ToggleSidebarOnMobile = meta.story({
57+
// globals: {
58+
// viewport: 'mobile1',
59+
// },
60+
// parameters: {
61+
// chromatic: { viewports: [320] },
62+
// },
63+
// play: async ({ canvas, step, userEvent }) => {
64+
// const searchInput = canvas.getByRole('menubar')
65+
//
66+
// await step('Sidebar is initially visible', async () => {
67+
// expect(searchInput).toBeVisible()
68+
// expect(isElementInView(searchInput)).toBe(true)
69+
// })
70+
//
71+
// await step('Select note', async () => {
72+
// const note = canvas.getAllByRole('button', {
73+
// name: /Open note for preview/i,
74+
// })[0]!
75+
// await userEvent.click(note)
76+
// })
77+
//
78+
// await waitFor(function sidebarIsNotVisible() {
79+
// expect(isElementInView(searchInput)).toBe(false)
80+
// })
81+
// },
82+
// })
83+
//
84+
// /**
85+
// * assertion to check if an element is in or out of the viewport,
86+
// * regardless of being in the DOM or not
87+
// */
88+
// function isElementInView(element: Element) {
89+
// var rect = element.getBoundingClientRect()
90+
// var html = document.documentElement
91+
//
92+
// return (
93+
// rect.bottom >= 0 &&
94+
// rect.top <= (window.innerHeight || html.clientHeight) &&
95+
// rect.right >= 0 &&
96+
// rect.left <= (window.innerWidth || html.clientWidth)
97+
// )
98+
// }

0 commit comments

Comments
 (0)