Skip to content

Commit ba88454

Browse files
committed
test(test8): fix SelectInputPairElement interaction + use valid values
ROOT CAUSE: 1. SelectInputPairElement combines select dropdown + number input 2. Final value is concatenation: `${selectValue}${inputValue}` 3. Test tried to type "Poke event" into number input (invalid) 4. Stale element references after selectOptions() causes clear() to fail FIXES: 1. **Use valid SelectInputPairElement pattern**: Select "Dout" from dropdown, type "2" into number input → produces "Dout2" 2. **Add blur() + delay after selectOptions()**: Prevents stale element when querying number input after select changes 3. **Fix test expectations**: Changed from impossible "Poke event" to valid "Dout2" that matches component behavior COMPONENT BEHAVIOR: SelectInputPairElement (behavioral_events-description): - Dropdown options: Din, Dout, Accel, Gyro, Mag (from behavioralEventsDescription()) - Input type: number (can only accept digits) - onBlur concatenates: selectRef.current.value + inputRef.current.value - Example: select="Dout" + input="2" → "Dout2" Test 8 now passes: 8/11 tests passing (73%)
1 parent 2edde66 commit ba88454

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

src/__tests__/integration/complete-session-creation.test.jsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -933,39 +933,41 @@ describe('End-to-End Session Creation Workflow', () => {
933933
// Add behavioral events
934934
const addBehavioralEventButton = screen.getByTitle(/Add behavioral_events/i);
935935

936-
// DEBUG: Check what happens when we click Add
937-
console.log(`DEBUG test8: BEFORE click - checking for "Add behavioral_events" button`);
938-
console.log(`DEBUG test8: Button found: ${addBehavioralEventButton ? 'YES' : 'NO'}`);
939-
940-
// Check initial behavioral events count using a different selector
941-
// behavioral_events has SelectInputPairElement with name="description"
936+
// Count behavioral events using "Item #" text
942937
let behavioralEventItems = screen.queryAllByText(/Item #/i);
943-
console.log(`DEBUG test8: Initial "Item #" count: ${behavioralEventItems.length}`);
944-
945938
const initialEventCount = behavioralEventItems.length;
946939

947940
await user.click(addBehavioralEventButton);
948941

949-
console.log(`DEBUG test8: Clicked Add button, waiting for item to appear...`);
950-
951942
await waitFor(() => {
952943
behavioralEventItems = screen.queryAllByText(/Item #/i);
953-
console.log(`DEBUG test8: After click, "Item #" count: ${behavioralEventItems.length}`);
954944
expect(behavioralEventItems.length).toBe(initialEventCount + 1);
955945
});
956946

957947
// Fill behavioral event fields
958-
// behavioral_events-description is a SelectInputPairElement with unique placeholder
959-
const eventDescInput = screen.getByPlaceholderText(/DIO info/i);
960-
await user.type(eventDescInput, 'Poke event');
948+
// behavioral_events-description is a SelectInputPairElement: select dropdown + number input
949+
// Component concatenates select value + input value (e.g., "Din" + "1" = "Din1")
950+
951+
// Select from dropdown (Din, Dout, Accel, Gyro, Mag)
952+
const eventDescSelect = document.getElementById('behavioral_events-description-0-list');
953+
await user.selectOptions(eventDescSelect, 'Dout');
954+
eventDescSelect.blur();
955+
await act(async () => {
956+
await new Promise(resolve => setTimeout(resolve, 100));
957+
});
958+
959+
// Fill the number input part - query fresh after React re-render
960+
let eventDescInput = screen.getByPlaceholderText(/DIO info/i);
961+
await user.clear(eventDescInput);
962+
await user.type(eventDescInput, '2');
961963
eventDescInput.blur();
962964
await act(async () => {
963965
await new Promise(resolve => setTimeout(resolve, 100));
964966
});
965967

966-
// behavioral_events-name is a DataListElement with unique placeholder
968+
// behavioral_events-name is a DataListElement - query fresh
967969
const eventNameInput = screen.getByPlaceholderText(/E\.g\. light1/i);
968-
await user.type(eventNameInput, 'Din1');
970+
await user.type(eventNameInput, 'poke_sensor');
969971

970972
// Export using React fiber approach
971973
await triggerExport();
@@ -981,8 +983,9 @@ describe('End-to-End Session Creation Workflow', () => {
981983
// Verify behavioral events structure
982984
expect(exportedData.behavioral_events).toBeDefined();
983985
expect(exportedData.behavioral_events).toHaveLength(1);
984-
expect(exportedData.behavioral_events[0].description).toBe('Poke event');
985-
expect(exportedData.behavioral_events[0].name).toBe('Din1');
986+
// Description is concatenation of select ("Dout") + input ("2") = "Dout2"
987+
expect(exportedData.behavioral_events[0].description).toBe('Dout2');
988+
expect(exportedData.behavioral_events[0].name).toBe('poke_sensor');
986989
});
987990

988991
/**

0 commit comments

Comments
 (0)