0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-08 17:53:55 +08:00
discourse/plugins/discourse-calendar/test/javascripts/helpers/get-event-by-text.js
Jarek Radosz 81ec46fe6a
DEV: Fixup the calendar test helper (#39487)
This was causing flakiness (depending on test order it could still have
the other element, which made it pass)

Added more assertions to have more info in case it fails again.
2026-04-23 12:48:14 +02:00

17 lines
365 B
JavaScript
Vendored

export default function getEventByText(text) {
const events = [
...document.querySelectorAll(".fc-daygrid-event-harness"),
].filter(
(event) =>
event.querySelector(".fc-event-title")?.textContent.trim() === text
);
switch (events.length) {
case 0:
return;
case 1:
return events[0];
default:
return events;
}
}