Esri / calcite-design-system

A monorepo containing the packages for Esri's Calcite Design System
https://developers.arcgis.com/calcite-design-system/
Other
290 stars 75 forks source link

dropdown: Unstable test with the assertSelectedItems function #5716

Closed driskull closed 6 months ago

driskull commented 2 years ago

Test type

Unstable test

Which Component(s)

dropdown

Unstable Tests

The assertSelectedItems function needs to await 100ms currently to make sure the correct event is being tested.

The test should be updated to wait for the event necessary before proceeding with the function to test the event.

Test error, if applicable

FAIL src/components/dropdown/dropdown.e2e.ts (73.859 s) ● calcite-dropdown › renders no selected item when group is in none selection mode (and removes any selected state set in dom on load)

expect(received).toBe(expected) // Object.is equality

Expected: "item-2"
Received: "item-1"

  83 |         return (window as SelectionEventTestWindow).eventDetail.item.id;
  84 |       });
> 85 |       expect(selectedItemId).toBe(mostRecentId);
     |                              ^
  86 |     }
  87 |     expect(selectedItemIds).toHaveLength(expectedItemIds.length);
  88 |

  at assertSelectedItems (src/components/dropdown/dropdown.e2e.ts:85:30)
      at runMicrotasks (<anonymous>)
  at Object.<anonymous> (src/components/dropdown/dropdown.e2e.ts:373:5)

PR skipped, if applicable

https://github.com/Esri/calcite-components/pull/5715

Additional Info

Refactor test to remove the 100ms timeout and get the test stable.

jcfranco commented 6 months ago

Fixed via https://github.com/Esri/calcite-design-system/pull/9243.