Files
duty-teller/webapp/js/dayDetail.test.js
Nikolay Tatarinov 8a80af32d8
All checks were successful
CI / lint-and-test (push) Successful in 25s
Docker Build and Release / build-and-push (push) Successful in 56s
Docker Build and Release / release (push) Successful in 9s
feat: enhance group duty pin command functionality
- Updated the `pin_duty_cmd` to handle cases where no message ID is found by sending a new duty message, pinning it, saving the pin, and scheduling the next update.
- Improved error handling for message sending and pinning operations, providing appropriate replies based on success or failure.
- Enhanced unit tests to cover the new behavior, ensuring proper functionality and error handling in various scenarios.
2026-02-25 14:43:19 +03:00

42 lines
1.4 KiB
JavaScript

/**
* Unit tests for buildDayDetailContent.
* Verifies dutyList is sorted by start_at before display.
*/
import { describe, it, expect, beforeAll } from "vitest";
import { buildDayDetailContent } from "./dayDetail.js";
describe("buildDayDetailContent", () => {
beforeAll(() => {
document.body.innerHTML =
'<div id="calendar"></div><div id="monthTitle"></div>' +
'<div id="dutyList"></div><div id="loading"></div><div id="error"></div>' +
'<div id="accessDenied"></div><div class="header"></div><div class="weekdays"></div>' +
'<button id="prevMonth"></button><button id="nextMonth"></button>';
});
it("sorts duty list by start_at when input order is wrong", () => {
const dateKey = "2025-02-25";
const duties = [
{
event_type: "duty",
full_name: "Петров",
start_at: "2025-02-25T14:00:00",
end_at: "2025-02-25T18:00:00",
},
{
event_type: "duty",
full_name: "Иванов",
start_at: "2025-02-25T09:00:00",
end_at: "2025-02-25T14:00:00",
},
];
const html = buildDayDetailContent(dateKey, duties, []);
expect(html).toContain("Иванов");
expect(html).toContain("Петров");
const ivanovPos = html.indexOf("Иванов");
const petrovPos = html.indexOf("Петров");
expect(ivanovPos).toBeLessThan(petrovPos);
});
});