Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function createTestStore(tracks: ReturnType<typeof createMockTrack>[]) {
setCurrentSection: noop,
addSection: noop,
renameSection: noop,
duplicateSection: noop,
removeSection: noop,
setTrackVolume: noop,
setTrackPan: noop,
Expand All @@ -32,6 +33,8 @@ function createTestStore(tracks: ReturnType<typeof createMockTrack>[]) {
updateNote: noop,
setClipNotes: noop,
createClip: noop,
duplicateClip: noop,
removeClip: noop,
setClipLength: noop,
addNewTrack: noop,
removeTrack: noop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import type { PlaygroundState } from '../../types';

interface PlaygroundCardProps {
playground: PlaygroundState;
index: number;
onPress?: (id: string) => void;
onMenuPress?: (id: string) => void;
}

const PlaygroundCard = memo(function PlaygroundCard({
playground,
index,
onPress,
onMenuPress,
}: PlaygroundCardProps) {
Expand Down Expand Up @@ -75,6 +77,7 @@ const PlaygroundCard = memo(function PlaygroundCard({
hitSlop={12}
accessibilityRole="button"
accessibilityLabel="More options"
testID={`playgroundMenuButton_${index}`}
>
<Icon icon={Icons.more} size={20} color={colors.mcWhite3} />
</Pressable>
Expand Down Expand Up @@ -173,10 +176,11 @@ export const PlaygroundsDashboard = memo(function PlaygroundsDashboard({
{ paddingHorizontal: padding },
]}
>
{playgrounds.map((p) => (
{playgrounds.map((p, index) => (
<PlaygroundCard
key={p.id}
playground={p}
index={index}
onPress={onSelect}
onMenuPress={onMenuPress}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ describe('PlaygroundsDashboard behavior', () => {
expect(onSelect).toHaveBeenCalled();
});

it('calls onMenuPress from a stable indexed menu trigger', () => {
const onMenuPress = jest.fn();
const playgrounds = createMockPlaygroundsList(2);
const { getByTestId } = renderWithTheme(
<PlaygroundsDashboard
playgrounds={playgrounds}
onMenuPress={onMenuPress}
/>
);

fireEvent.press(getByTestId('playgroundMenuButton_1'));

expect(onMenuPress).toHaveBeenCalledWith(playgrounds[1]!.id);
});

it('calls onCreate when tapping + New', () => {
const onCreate = jest.fn();
const playgrounds = createMockPlaygroundsList(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ exports[`PlaygroundsDashboard snapshots matches snapshot refresh with playground
"padding": 12,
}
}
testID="playgroundMenuButton_0"
>
<View>
<View
Expand Down Expand Up @@ -790,6 +791,7 @@ exports[`PlaygroundsDashboard snapshots matches snapshot refresh with playground
"padding": 12,
}
}
testID="playgroundMenuButton_1"
>
<View>
<View
Expand Down Expand Up @@ -1136,6 +1138,7 @@ exports[`PlaygroundsDashboard snapshots matches snapshot with playgrounds 1`] =
"padding": 12,
}
}
testID="playgroundMenuButton_0"
>
<View>
<View
Expand Down Expand Up @@ -1344,6 +1347,7 @@ exports[`PlaygroundsDashboard snapshots matches snapshot with playgrounds 1`] =
"padding": 12,
}
}
testID="playgroundMenuButton_1"
>
<View>
<View
Expand Down Expand Up @@ -1552,6 +1556,7 @@ exports[`PlaygroundsDashboard snapshots matches snapshot with playgrounds 1`] =
"padding": 12,
}
}
testID="playgroundMenuButton_2"
>
<View>
<View
Expand Down
Loading
Loading