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.
This commit is contained in:
41
webapp/js/dayDetail.test.js
Normal file
41
webapp/js/dayDetail.test.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user