Skip to content

Commit 88a6203

Browse files
committed
Fix wide/narrow screen size change, add unit test
1 parent b45ef73 commit 88a6203

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { render } from 'flexible-testing-library-react';
1+
import { act, render, role } from 'flexible-testing-library-react';
22

33
import { MoodRetro } from './MoodRetro';
44

55
const nop = () => undefined;
66

77
describe('MoodRetro', () => {
8-
it('renders without error', () => {
9-
render(
8+
it('can switch between wide and narrow view', () => {
9+
const { getAllBy } = render(
1010
<MoodRetro
1111
retroOptions={{}}
1212
retroItems={[]}
@@ -16,5 +16,26 @@ describe('MoodRetro', () => {
1616
dispatch={nop}
1717
/>,
1818
);
19+
20+
expect(
21+
getAllBy(role('textbox')).map((i) => i.getAttribute('placeholder')),
22+
).toEqual([
23+
'I\u2019m glad that\u2026',
24+
'I\u2019m wondering about\u2026',
25+
'It wasn\u2019t so great that\u2026',
26+
'Add an action item',
27+
]);
28+
29+
const originalWidth = window.innerWidth;
30+
window.innerWidth = 200;
31+
try {
32+
act(() => window.dispatchEvent(new UIEvent('resize')));
33+
34+
expect(
35+
getAllBy(role('textbox')).map((i) => i.getAttribute('placeholder')),
36+
).toEqual(['I\u2019m glad that\u2026']);
37+
} finally {
38+
window.innerWidth = originalWidth;
39+
}
1940
});
2041
});

frontend/src/components/retro-formats/mood/MoodRetro.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export const MoodRetro = ({
7474
!singleColumn || OPTIONS.enableMobileFacilitation.read(retroOptions);
7575

7676
const useAction = useActionFactory(dispatch);
77-
const useFacilitatorAction = canFacilitate ? useAction : () => undefined;
77+
const useFacilitatorAction = useActionFactory(
78+
canFacilitate ? dispatch : undefined,
79+
);
7880

7981
const handleAddItem = useAction(addRetroItem);
8082
const handleAddActionItem = useAction(addRetroActionItem);

0 commit comments

Comments
 (0)