Skip to content

Commit 8b7cdb1

Browse files
committed
flex direction tests
1 parent 9a2dd48 commit 8b7cdb1

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

editor/src/components/inspector/flex-direction-control.spec.browser2.tsx

+59-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import {
33
expectSingleUndo2Saves,
44
hoverControlWithCheck,
55
selectComponentsForTest,
6+
setFeatureForBrowserTestsUseInDescribeBlockOnly,
67
} from '../../utils/utils.test-utils'
78
import { CanvasControlsContainerID } from '../canvas/controls/new-canvas-controls'
89
import { getSubduedPaddingControlTestID } from '../canvas/controls/select-mode/subdued-padding-control'
910
import { mouseClickAtPoint } from '../canvas/event-helpers.test-utils'
1011
import type { EditorRenderResult } from '../canvas/ui-jsx.test-utils'
11-
import { renderTestEditorWithCode } from '../canvas/ui-jsx.test-utils'
12+
import { renderTestEditorWithCode, renderTestEditorWithModel } from '../canvas/ui-jsx.test-utils'
1213
import type { FlexDirection } from './common/css-utils'
1314
import { FlexDirectionControlTestId, FlexDirectionToggleTestId } from './flex-direction-control'
15+
import { TailwindProject } from './sections/flex-section.test-utils'
1416

1517
describe('set flex direction', () => {
1618
it('set flex direction to row from not set', async () => {
@@ -111,6 +113,62 @@ describe('set flex direction', () => {
111113
expect(controls.length).toEqual(4)
112114
})
113115
})
116+
117+
describe('Tailwind', () => {
118+
setFeatureForBrowserTestsUseInDescribeBlockOnly('Tailwind', true)
119+
120+
it('set flex direction to column from not set', async () => {
121+
const editor = await renderTestEditorWithModel(
122+
TailwindProject('flex'),
123+
'await-first-dom-report',
124+
)
125+
await selectDiv(editor)
126+
await expectSingleUndo2Saves(editor, () => clickOn(editor, 'column'))
127+
const div = editor.renderedDOM.getByTestId('mydiv')
128+
expect(div.className).toEqual(
129+
'top-10 left-10 w-64 h-64 bg-slate-100 absolute flex flex-col', // flex-col is set by the control
130+
)
131+
})
132+
133+
it('set flex direction to row-reverse from not set', async () => {
134+
const editor = await renderTestEditorWithModel(
135+
TailwindProject('flex'),
136+
'await-first-dom-report',
137+
)
138+
await selectDiv(editor)
139+
await expectSingleUndo2Saves(editor, () => clickOn(editor, 'row-reverse'))
140+
const div = editor.renderedDOM.getByTestId('mydiv')
141+
expect(div.className).toEqual(
142+
'top-10 left-10 w-64 h-64 bg-slate-100 absolute flex flex-row-reverse', // flex-row-reverse is set by the control
143+
)
144+
})
145+
146+
it('set flex direction to column-reverse from not set', async () => {
147+
const editor = await renderTestEditorWithModel(
148+
TailwindProject('flex'),
149+
'await-first-dom-report',
150+
)
151+
await selectDiv(editor)
152+
await expectSingleUndo2Saves(editor, () => clickOn(editor, 'column-reverse'))
153+
const div = editor.renderedDOM.getByTestId('mydiv')
154+
expect(div.className).toEqual(
155+
'top-10 left-10 w-64 h-64 bg-slate-100 absolute flex flex-col-reverse', // flex-row-reverse is set by the control
156+
)
157+
})
158+
159+
it('set flex direction to row from column', async () => {
160+
const editor = await renderTestEditorWithModel(
161+
TailwindProject('flex flex-col'),
162+
'await-first-dom-report',
163+
)
164+
await selectDiv(editor)
165+
await expectSingleUndo2Saves(editor, () => clickOn(editor, 'row'))
166+
const div = editor.renderedDOM.getByTestId('mydiv')
167+
expect(div.className).toEqual(
168+
'top-10 left-10 w-64 h-64 bg-slate-100 absolute flex flex-row', // flex-row is set by the control
169+
)
170+
})
171+
})
114172
})
115173

116174
async function selectDiv(editor: EditorRenderResult): Promise<HTMLElement> {

0 commit comments

Comments
 (0)