Skip to content

Commit 5890d95

Browse files
committed
test(test10,test11): fix field selectors + add blur/delay pattern
ROOT CAUSE (same as tests 7-9): 1. Wrong label patterns for electrode group fields 2. task_epochs is ListElement (needs placeholder selector) 3. Missing blur() + delay causes stale element references FIXES: **Test 10:** - Use placeholder + filter pattern for electrode group counting - Correct label patterns: "targeted x/y/z" → "ML/AP/DV from Bregma/Cortical Surface" - Units: label → placeholder "Distance units defining positioning" - Add blur() + delay after each field **Test 11:** - Same electrode group fixes as test 10 - task_epochs: label selector → placeholder "Type Task Epochs" + Enter key - Add blur() + delay after task fields and electrode group fields ALL 11 TESTS NOW PASSING (100%) Progress: 14 failures → 0 failures - Reduced from 14 failing tests to 0 failing tests - 11/11 tests passing in complete-session-creation.test.jsx
1 parent 947451f commit 5890d95

File tree

1 file changed

+113
-28
lines changed

1 file changed

+113
-28
lines changed

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

Lines changed: 113 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,45 +1134,83 @@ describe('End-to-End Session Creation Workflow', () => {
11341134

11351135
// Add electrode group and select device type
11361136
const addElectrodeGroupButton = screen.getByTitle(/Add electrode_groups/i);
1137-
let electrodeGroupIdInputs = screen.queryAllByLabelText(/electrode group id/i);
1137+
1138+
// Count using placeholder (same pattern as test 9)
1139+
let electrodeGroupIdInputs = screen.queryAllByPlaceholderText(/typically a number/i);
1140+
electrodeGroupIdInputs = electrodeGroupIdInputs.filter(input =>
1141+
input.id && input.id.startsWith('electrode_groups-id-')
1142+
);
11381143
const initialElectrodeGroupCount = electrodeGroupIdInputs.length;
11391144

11401145
await user.click(addElectrodeGroupButton);
11411146

11421147
await waitFor(() => {
1143-
electrodeGroupIdInputs = screen.queryAllByLabelText(/electrode group id/i);
1144-
expect(electrodeGroupIdInputs.length).toBe(initialElectrodeGroupCount + 1);
1148+
let updatedInputs = screen.queryAllByPlaceholderText(/typically a number/i);
1149+
updatedInputs = updatedInputs.filter(input =>
1150+
input.id && input.id.startsWith('electrode_groups-id-')
1151+
);
1152+
expect(updatedInputs.length).toBe(initialElectrodeGroupCount + 1);
11451153
});
11461154

1147-
// Use placeholder text to find location field (more specific than label)
1148-
const locationInputs = screen.queryAllByPlaceholderText(/type to find a location/i);
1149-
// Get the last one added (most recent electrode group)
1155+
// Fill electrode group fields with blur() + delay pattern (same as test 9)
1156+
let locationInputs = screen.queryAllByPlaceholderText(/type to find a location/i);
11501157
const electrodeGroupLocationInput = locationInputs[locationInputs.length - 1];
11511158
await user.type(electrodeGroupLocationInput, 'CA1');
1159+
electrodeGroupLocationInput.blur();
1160+
await act(async () => {
1161+
await new Promise(resolve => setTimeout(resolve, 100));
1162+
});
11521163

1153-
// Fill remaining required electrode group fields
1154-
const descriptionInputs = screen.queryAllByLabelText(/^description$/i);
1164+
let descriptionInputs = screen.queryAllByLabelText(/^description$/i);
11551165
await user.type(descriptionInputs[descriptionInputs.length - 1], 'Test tetrode');
1166+
descriptionInputs[descriptionInputs.length - 1].blur();
1167+
await act(async () => {
1168+
await new Promise(resolve => setTimeout(resolve, 100));
1169+
});
11561170

1157-
const targetedLocationInputs = screen.queryAllByLabelText(/targeted location/i);
1171+
let targetedLocationInputs = screen.queryAllByLabelText(/targeted location/i);
11581172
await user.type(targetedLocationInputs[targetedLocationInputs.length - 1], 'CA1');
1173+
targetedLocationInputs[targetedLocationInputs.length - 1].blur();
1174+
await act(async () => {
1175+
await new Promise(resolve => setTimeout(resolve, 100));
1176+
});
11591177

1160-
const targetedXInputs = screen.queryAllByLabelText(/targeted x/i);
1178+
// Use correct label text (same as test 9)
1179+
let targetedXInputs = screen.queryAllByLabelText(/ML from Bregma/i);
11611180
await user.type(targetedXInputs[targetedXInputs.length - 1], '1.0');
1181+
targetedXInputs[targetedXInputs.length - 1].blur();
1182+
await act(async () => {
1183+
await new Promise(resolve => setTimeout(resolve, 100));
1184+
});
11621185

1163-
const targetedYInputs = screen.queryAllByLabelText(/targeted y/i);
1186+
let targetedYInputs = screen.queryAllByLabelText(/AP to Bregma/i);
11641187
await user.type(targetedYInputs[targetedYInputs.length - 1], '2.0');
1188+
targetedYInputs[targetedYInputs.length - 1].blur();
1189+
await act(async () => {
1190+
await new Promise(resolve => setTimeout(resolve, 100));
1191+
});
11651192

1166-
const targetedZInputs = screen.queryAllByLabelText(/targeted z/i);
1193+
let targetedZInputs = screen.queryAllByLabelText(/DV to Cortical Surface/i);
11671194
await user.type(targetedZInputs[targetedZInputs.length - 1], '3.0');
1195+
targetedZInputs[targetedZInputs.length - 1].blur();
1196+
await act(async () => {
1197+
await new Promise(resolve => setTimeout(resolve, 100));
1198+
});
11681199

1169-
const unitsInputs = screen.queryAllByLabelText(/^units$/i);
1200+
let unitsInputs = screen.queryAllByPlaceholderText(/Distance units defining positioning/i);
11701201
await user.type(unitsInputs[unitsInputs.length - 1], 'mm');
1202+
unitsInputs[unitsInputs.length - 1].blur();
1203+
await act(async () => {
1204+
await new Promise(resolve => setTimeout(resolve, 100));
1205+
});
11711206

11721207
// Select device type to trigger ntrode generation
1173-
// Device type select - get all and use the last one (most recent electrode group)
1174-
const deviceTypeInputs = screen.queryAllByLabelText(/device type/i);
1208+
let deviceTypeInputs = screen.queryAllByLabelText(/device type/i);
11751209
await user.selectOptions(deviceTypeInputs[deviceTypeInputs.length - 1], 'tetrode_12.5');
1210+
deviceTypeInputs[deviceTypeInputs.length - 1].blur();
1211+
await act(async () => {
1212+
await new Promise(resolve => setTimeout(resolve, 100));
1213+
});
11761214

11771215
// Wait for ntrode generation (async operation)
11781216
await waitFor(() => {
@@ -1291,18 +1329,32 @@ describe('End-to-End Session Creation Workflow', () => {
12911329
expect(taskNameInputs.length).toBe(initialTaskCount + 1);
12921330
});
12931331

1294-
// Fill ALL required task fields
1332+
// Fill ALL required task fields with blur() + delay pattern
12951333
taskNameInputs = screen.getAllByLabelText(/task name/i);
12961334
await user.type(taskNameInputs[0], 'w_track');
1335+
taskNameInputs[0].blur();
1336+
await act(async () => {
1337+
await new Promise(resolve => setTimeout(resolve, 100));
1338+
});
12971339

1298-
const taskDescInputs = screen.getAllByLabelText(/task description/i);
1340+
let taskDescInputs = screen.getAllByLabelText(/task description/i);
12991341
await user.type(taskDescInputs[0], 'W-track task');
1342+
taskDescInputs[0].blur();
1343+
await act(async () => {
1344+
await new Promise(resolve => setTimeout(resolve, 100));
1345+
});
13001346

13011347
const taskEnvInputs = screen.getAllByLabelText(/task environment/i);
13021348
await user.type(taskEnvInputs[0], 'W-track maze');
1349+
taskEnvInputs[0].blur();
1350+
await act(async () => {
1351+
await new Promise(resolve => setTimeout(resolve, 100));
1352+
});
13031353

1304-
const taskEpochInputs = screen.getAllByLabelText(/task epochs/i);
1305-
await user.type(taskEpochInputs[0], '1');
1354+
// task_epochs is a ListElement - use placeholder instead of label
1355+
const taskEpochInput = screen.getByPlaceholderText(/Type Task Epochs/i);
1356+
await user.type(taskEpochInput, '1');
1357+
await user.keyboard('{Enter}');
13061358

13071359
// Add electrode group
13081360
const addElectrodeGroupButton = screen.getByTitle(/Add electrode_groups/i);
@@ -1326,31 +1378,64 @@ describe('End-to-End Session Creation Workflow', () => {
13261378
expect(updatedInputs.length).toBe(initialElectrodeGroupCount + 1);
13271379
});
13281380

1329-
// Fill ALL required electrode group fields
1330-
const locationInputs = screen.queryAllByPlaceholderText(/type to find a location/i);
1381+
// Fill ALL required electrode group fields with blur() + delay pattern
1382+
let locationInputs = screen.queryAllByPlaceholderText(/type to find a location/i);
13311383
await user.type(locationInputs[locationInputs.length - 1], 'CA1');
1384+
locationInputs[locationInputs.length - 1].blur();
1385+
await act(async () => {
1386+
await new Promise(resolve => setTimeout(resolve, 100));
1387+
});
13321388

1333-
const descriptionInputs = screen.queryAllByLabelText(/^description$/i);
1389+
let descriptionInputs = screen.queryAllByLabelText(/^description$/i);
13341390
await user.type(descriptionInputs[descriptionInputs.length - 1], 'CA1 tetrode');
1391+
descriptionInputs[descriptionInputs.length - 1].blur();
1392+
await act(async () => {
1393+
await new Promise(resolve => setTimeout(resolve, 100));
1394+
});
13351395

1336-
const targetedLocationInputs = screen.queryAllByLabelText(/targeted location/i);
1396+
let targetedLocationInputs = screen.queryAllByLabelText(/targeted location/i);
13371397
await user.type(targetedLocationInputs[targetedLocationInputs.length - 1], 'CA1');
1398+
targetedLocationInputs[targetedLocationInputs.length - 1].blur();
1399+
await act(async () => {
1400+
await new Promise(resolve => setTimeout(resolve, 100));
1401+
});
13381402

1339-
const targetedXInputs = screen.queryAllByLabelText(/targeted x/i);
1403+
// Use correct label text
1404+
let targetedXInputs = screen.queryAllByLabelText(/ML from Bregma/i);
13401405
await user.type(targetedXInputs[targetedXInputs.length - 1], '1.0');
1406+
targetedXInputs[targetedXInputs.length - 1].blur();
1407+
await act(async () => {
1408+
await new Promise(resolve => setTimeout(resolve, 100));
1409+
});
13411410

1342-
const targetedYInputs = screen.queryAllByLabelText(/targeted y/i);
1411+
let targetedYInputs = screen.queryAllByLabelText(/AP to Bregma/i);
13431412
await user.type(targetedYInputs[targetedYInputs.length - 1], '2.0');
1413+
targetedYInputs[targetedYInputs.length - 1].blur();
1414+
await act(async () => {
1415+
await new Promise(resolve => setTimeout(resolve, 100));
1416+
});
13441417

1345-
const targetedZInputs = screen.queryAllByLabelText(/targeted z/i);
1418+
let targetedZInputs = screen.queryAllByLabelText(/DV to Cortical Surface/i);
13461419
await user.type(targetedZInputs[targetedZInputs.length - 1], '3.0');
1420+
targetedZInputs[targetedZInputs.length - 1].blur();
1421+
await act(async () => {
1422+
await new Promise(resolve => setTimeout(resolve, 100));
1423+
});
13471424

1348-
const unitsInputs = screen.queryAllByLabelText(/^units$/i);
1425+
let unitsInputs = screen.queryAllByPlaceholderText(/Distance units defining positioning/i);
13491426
await user.type(unitsInputs[unitsInputs.length - 1], 'mm');
1427+
unitsInputs[unitsInputs.length - 1].blur();
1428+
await act(async () => {
1429+
await new Promise(resolve => setTimeout(resolve, 100));
1430+
});
13501431

13511432
// Device type select - get all and use the last one (most recent electrode group)
1352-
const deviceTypeInputs = screen.queryAllByLabelText(/device type/i);
1433+
let deviceTypeInputs = screen.queryAllByLabelText(/device type/i);
13531434
await user.selectOptions(deviceTypeInputs[deviceTypeInputs.length - 1], 'tetrode_12.5');
1435+
deviceTypeInputs[deviceTypeInputs.length - 1].blur();
1436+
await act(async () => {
1437+
await new Promise(resolve => setTimeout(resolve, 100));
1438+
});
13541439

13551440
// Wait for ntrode generation
13561441
await waitFor(() => {

0 commit comments

Comments
 (0)