mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
chore: update workflow
This commit is contained in:
parent
f30c3cb2b0
commit
616448541c
8 changed files with 24 additions and 495 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "obsidian-task-progress-bar",
|
||||
"name": "Task Genius",
|
||||
"version": "9.0.0-beta.1",
|
||||
"version": "9.0.0-beta.2",
|
||||
"minAppVersion": "0.15.2",
|
||||
"description": "Comprehensive task management that includes progress bars, task status cycling, and advanced task tracking features.",
|
||||
"author": "Boninall",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "task-genius",
|
||||
"version": "9.0.0-beta.1",
|
||||
"version": "9.0.0-beta.2",
|
||||
"description": "Comprehensive task management plugin for Obsidian with progress bars, task status cycling, and advanced task tracking features.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ describe("Badge Debug Helper", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: `- [ ] ${badgeEvent.summary}`,
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -155,6 +156,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: false,
|
||||
originalMarkdown: "- [ ] Full Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -212,6 +214,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -271,6 +274,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -297,6 +301,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 2",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -378,6 +383,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: false,
|
||||
originalMarkdown: "- [ ] Event from Calendar 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -404,6 +410,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: false,
|
||||
originalMarkdown: "- [ ] Event from Calendar 2",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -461,6 +468,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: false,
|
||||
originalMarkdown: "- [ ] Full Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -506,6 +514,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -563,6 +572,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -589,6 +599,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: false,
|
||||
originalMarkdown: "- [ ] Full Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -651,6 +662,7 @@ describe("Calendar Badge Rendering Logic", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ describe("Calendar View Badge Integration", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -216,6 +217,7 @@ describe("Calendar View Badge Integration", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: false,
|
||||
originalMarkdown: "- [ ] Full Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -308,6 +310,7 @@ describe("Calendar View Badge Integration", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -334,6 +337,7 @@ describe("Calendar View Badge Integration", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: false,
|
||||
originalMarkdown: "- [ ] Full Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -418,6 +422,7 @@ describe("Calendar View Badge Integration", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -444,6 +449,7 @@ describe("Calendar View Badge Integration", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 2",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
@ -565,6 +571,7 @@ describe("Calendar View Badge Integration", () => {
|
|||
line: 0,
|
||||
completed: false,
|
||||
status: " ",
|
||||
badge: true,
|
||||
originalMarkdown: "- [ ] Badge Event 1",
|
||||
metadata: {
|
||||
tags: [],
|
||||
|
|
|
|||
|
|
@ -1,236 +0,0 @@
|
|||
import { App, moment } from "obsidian";
|
||||
import { MonthView } from "../month-view";
|
||||
import { CalendarEvent } from "../../index";
|
||||
import TaskProgressBarPlugin from "../../../../index";
|
||||
import "../../../../__mocks__/dom-helpers";
|
||||
|
||||
// Mock dependencies
|
||||
jest.mock("obsidian", () => ({
|
||||
App: jest.fn(),
|
||||
Component: class MockComponent {
|
||||
addChild = jest.fn();
|
||||
registerDomEvent = jest.fn();
|
||||
onunload = jest.fn();
|
||||
},
|
||||
moment: require("moment"),
|
||||
debounce: (fn: Function) => fn,
|
||||
}));
|
||||
|
||||
jest.mock("../../../../index", () => ({
|
||||
default: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock("../../rendering/event-renderer", () => ({
|
||||
renderCalendarEvent: jest.fn(() => ({
|
||||
eventEl: document.createElement("div"),
|
||||
component: { onunload: jest.fn() },
|
||||
})),
|
||||
}));
|
||||
|
||||
jest.mock("../../../../common/setting-definition", () => ({
|
||||
getViewSettingOrDefault: jest.fn(),
|
||||
CalendarSpecificConfig: {},
|
||||
}));
|
||||
|
||||
jest.mock("sortablejs", () => ({
|
||||
default: {
|
||||
create: jest.fn(() => ({
|
||||
destroy: jest.fn(),
|
||||
})),
|
||||
},
|
||||
}));
|
||||
|
||||
describe("MonthView Weekend Hiding", () => {
|
||||
let mockApp: App;
|
||||
let mockPlugin: TaskProgressBarPlugin;
|
||||
let containerEl: HTMLElement;
|
||||
let monthView: MonthView;
|
||||
|
||||
beforeEach(() => {
|
||||
// Setup DOM environment
|
||||
document.body.innerHTML = "";
|
||||
containerEl = document.createElement("div");
|
||||
document.body.appendChild(containerEl);
|
||||
|
||||
// Mock app and plugin
|
||||
mockApp = {} as App;
|
||||
mockPlugin = {
|
||||
settings: {
|
||||
viewConfiguration: [
|
||||
{
|
||||
id: "calendar",
|
||||
specificConfig: {
|
||||
firstDayOfWeek: 1, // Monday
|
||||
hideWeekends: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
} as any;
|
||||
|
||||
// Create test events
|
||||
const testEvents: CalendarEvent[] = [
|
||||
{
|
||||
id: "test-1",
|
||||
title: "Test Event 1",
|
||||
start: moment("2024-01-15").toDate(), // Monday
|
||||
metadata: {
|
||||
dueDate: moment("2024-01-15").valueOf(),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "test-2",
|
||||
title: "Test Event 2",
|
||||
start: moment("2024-01-20").toDate(), // Saturday (weekend)
|
||||
metadata: {
|
||||
dueDate: moment("2024-01-20").valueOf(),
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// Create MonthView instance
|
||||
monthView = new MonthView(
|
||||
mockApp,
|
||||
mockPlugin,
|
||||
containerEl,
|
||||
"calendar",
|
||||
moment("2024-01-15"), // January 2024
|
||||
testEvents,
|
||||
{
|
||||
onDayClick: jest.fn(),
|
||||
onEventClick: jest.fn(),
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
monthView.onunload();
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
test("should render only 5 weekday headers when hideWeekends is true", () => {
|
||||
// Render the month view
|
||||
monthView.render();
|
||||
|
||||
// Check weekday headers
|
||||
const weekdayHeaders = containerEl.querySelectorAll(".calendar-weekday");
|
||||
expect(weekdayHeaders.length).toBe(5);
|
||||
|
||||
// Verify the headers are work days only (Mon-Fri)
|
||||
const headerTexts = Array.from(weekdayHeaders).map(
|
||||
(el) => el.textContent
|
||||
);
|
||||
expect(headerTexts).not.toContain("Sat");
|
||||
expect(headerTexts).not.toContain("Sun");
|
||||
expect(headerTexts).toContain("Mon");
|
||||
expect(headerTexts).toContain("Tue");
|
||||
expect(headerTexts).toContain("Wed");
|
||||
expect(headerTexts).toContain("Thu");
|
||||
expect(headerTexts).toContain("Fri");
|
||||
});
|
||||
|
||||
test("should have hide-weekends CSS class when hideWeekends is true", () => {
|
||||
monthView.render();
|
||||
|
||||
expect(containerEl.classList.contains("hide-weekends")).toBe(true);
|
||||
});
|
||||
|
||||
test("should not create day cells for weekend dates", () => {
|
||||
monthView.render();
|
||||
|
||||
// Get all day cells
|
||||
const dayCells = containerEl.querySelectorAll(".calendar-day-cell");
|
||||
|
||||
// Check that no weekend dates are created
|
||||
Array.from(dayCells).forEach((cell) => {
|
||||
const dateStr = cell.getAttribute("data-date");
|
||||
if (dateStr) {
|
||||
const date = moment(dateStr);
|
||||
const dayOfWeek = date.day();
|
||||
// Should not be Saturday (6) or Sunday (0)
|
||||
expect(dayOfWeek).not.toBe(0);
|
||||
expect(dayOfWeek).not.toBe(6);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("should render only work days in a typical week", () => {
|
||||
monthView.render();
|
||||
|
||||
// Get all day cells for a specific week
|
||||
const dayCells = containerEl.querySelectorAll(".calendar-day-cell");
|
||||
const datesInView = Array.from(dayCells).map((cell) =>
|
||||
cell.getAttribute("data-date")
|
||||
);
|
||||
|
||||
// Find a complete work week (e.g., Jan 15-19, 2024 is Mon-Fri)
|
||||
const workWeekDates = [
|
||||
"2024-01-15", // Monday
|
||||
"2024-01-16", // Tuesday
|
||||
"2024-01-17", // Wednesday
|
||||
"2024-01-18", // Thursday
|
||||
"2024-01-19", // Friday
|
||||
];
|
||||
|
||||
// All work days should be present
|
||||
workWeekDates.forEach((date) => {
|
||||
expect(datesInView).toContain(date);
|
||||
});
|
||||
|
||||
// Weekend days should not be present
|
||||
const weekendDates = [
|
||||
"2024-01-13", // Saturday
|
||||
"2024-01-14", // Sunday
|
||||
"2024-01-20", // Saturday
|
||||
"2024-01-21", // Sunday
|
||||
];
|
||||
|
||||
weekendDates.forEach((date) => {
|
||||
expect(datesInView).not.toContain(date);
|
||||
});
|
||||
});
|
||||
|
||||
test("should have correct grid layout with 5 columns when weekends hidden", () => {
|
||||
monthView.render();
|
||||
|
||||
// Check that the container has the hide-weekends class
|
||||
expect(containerEl.classList.contains("hide-weekends")).toBe(true);
|
||||
|
||||
// The CSS should set grid-template-columns to repeat(5, 1fr)
|
||||
// We can't directly test CSS, but we can verify the class is applied
|
||||
const monthGrid = containerEl.querySelector(".calendar-month-grid");
|
||||
expect(monthGrid).toBeTruthy();
|
||||
|
||||
const weekdayHeader = containerEl.querySelector(
|
||||
".calendar-weekday-header"
|
||||
);
|
||||
expect(weekdayHeader).toBeTruthy();
|
||||
});
|
||||
|
||||
test("should render 7 days when hideWeekends is false", () => {
|
||||
// Update plugin settings to show weekends
|
||||
mockPlugin.settings.viewConfiguration[0].specificConfig.hideWeekends = false;
|
||||
|
||||
// Create new instance with weekends enabled
|
||||
const monthViewWithWeekends = new MonthView(
|
||||
mockApp,
|
||||
mockPlugin,
|
||||
containerEl,
|
||||
"calendar",
|
||||
moment("2024-01-15"),
|
||||
[],
|
||||
{}
|
||||
);
|
||||
|
||||
monthViewWithWeekends.render();
|
||||
|
||||
// Should have 7 weekday headers
|
||||
const weekdayHeaders = containerEl.querySelectorAll(".calendar-weekday");
|
||||
expect(weekdayHeaders.length).toBe(7);
|
||||
|
||||
// Should not have hide-weekends class
|
||||
expect(containerEl.classList.contains("hide-weekends")).toBe(false);
|
||||
|
||||
monthViewWithWeekends.onunload();
|
||||
});
|
||||
});
|
||||
|
|
@ -1,256 +0,0 @@
|
|||
import { App, moment } from "obsidian";
|
||||
import { YearView } from "../year-view";
|
||||
import { CalendarEvent } from "../../index";
|
||||
import TaskProgressBarPlugin from "../../../../index";
|
||||
import "../../../../__mocks__/dom-helpers";
|
||||
|
||||
// Mock dependencies
|
||||
jest.mock("obsidian", () => ({
|
||||
App: jest.fn(),
|
||||
Component: class MockComponent {
|
||||
addChild = jest.fn();
|
||||
registerDomEvent = jest.fn();
|
||||
onunload = jest.fn();
|
||||
},
|
||||
moment: require("moment"),
|
||||
debounce: (fn: Function) => fn,
|
||||
}));
|
||||
|
||||
jest.mock("../../../../index", () => ({
|
||||
default: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock("../../../../common/setting-definition", () => ({
|
||||
getViewSettingOrDefault: jest.fn(() => ({
|
||||
specificConfig: {
|
||||
firstDayOfWeek: 1, // Monday
|
||||
hideWeekends: true,
|
||||
},
|
||||
})),
|
||||
CalendarSpecificConfig: {},
|
||||
}));
|
||||
|
||||
describe("YearView Weekend Hiding", () => {
|
||||
let mockApp: App;
|
||||
let mockPlugin: TaskProgressBarPlugin;
|
||||
let containerEl: HTMLElement;
|
||||
let yearView: YearView;
|
||||
|
||||
beforeEach(() => {
|
||||
// Setup DOM environment
|
||||
document.body.innerHTML = "";
|
||||
containerEl = document.createElement("div");
|
||||
document.body.appendChild(containerEl);
|
||||
|
||||
// Mock app and plugin
|
||||
mockApp = {} as App;
|
||||
mockPlugin = {
|
||||
settings: {
|
||||
viewConfiguration: [
|
||||
{
|
||||
id: "calendar",
|
||||
specificConfig: {
|
||||
firstDayOfWeek: 1, // Monday
|
||||
hideWeekends: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
} as any;
|
||||
|
||||
// Create test events
|
||||
const testEvents: CalendarEvent[] = [
|
||||
{
|
||||
id: "test-1",
|
||||
title: "Test Event 1",
|
||||
start: moment("2024-01-15").toDate(), // Monday
|
||||
metadata: {
|
||||
dueDate: moment("2024-01-15").valueOf(),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "test-2",
|
||||
title: "Test Event 2",
|
||||
start: moment("2024-06-15").toDate(), // Saturday (weekend)
|
||||
metadata: {
|
||||
dueDate: moment("2024-06-15").valueOf(),
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// Create YearView instance
|
||||
yearView = new YearView(
|
||||
mockApp,
|
||||
mockPlugin,
|
||||
containerEl,
|
||||
moment("2024-01-01"), // Year 2024
|
||||
testEvents,
|
||||
{
|
||||
onDayClick: jest.fn(),
|
||||
onMonthClick: jest.fn(),
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
yearView.onunload();
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
test("should render only 5 weekday headers in mini-months when hideWeekends is true", () => {
|
||||
// Render the year view
|
||||
yearView.render();
|
||||
|
||||
// Check mini-month weekday headers
|
||||
const miniWeekdayHeaders = containerEl.querySelectorAll(".mini-weekday");
|
||||
|
||||
// Each mini-month should have 5 weekday headers (one for each month)
|
||||
// Since we have 12 months, we should have 12 * 5 = 60 mini-weekday headers
|
||||
expect(miniWeekdayHeaders.length).toBe(60);
|
||||
|
||||
// Verify no weekend day names are present
|
||||
const headerTexts = Array.from(miniWeekdayHeaders).map(
|
||||
(el) => el.textContent
|
||||
);
|
||||
|
||||
// Should not contain Saturday or Sunday abbreviations
|
||||
expect(headerTexts.filter(text => text === "Sa" || text === "Su")).toHaveLength(0);
|
||||
|
||||
// Should contain work day abbreviations
|
||||
expect(headerTexts.filter(text => text === "Mo")).toHaveLength(12); // 12 months
|
||||
expect(headerTexts.filter(text => text === "Tu")).toHaveLength(12);
|
||||
expect(headerTexts.filter(text => text === "We")).toHaveLength(12);
|
||||
expect(headerTexts.filter(text => text === "Th")).toHaveLength(12);
|
||||
expect(headerTexts.filter(text => text === "Fr")).toHaveLength(12);
|
||||
});
|
||||
|
||||
test("should have hide-weekends CSS class when hideWeekends is true", () => {
|
||||
yearView.render();
|
||||
|
||||
expect(containerEl.classList.contains("hide-weekends")).toBe(true);
|
||||
});
|
||||
|
||||
test("should not create day cells for weekend dates in mini-months", () => {
|
||||
yearView.render();
|
||||
|
||||
// Get all mini-day cells from all mini-months
|
||||
const miniDayCells = containerEl.querySelectorAll(".mini-day-cell");
|
||||
|
||||
// Check that no weekend dates are created
|
||||
Array.from(miniDayCells).forEach((cell) => {
|
||||
const dateStr = cell.getAttribute("data-date");
|
||||
if (dateStr) {
|
||||
const date = moment(dateStr);
|
||||
const dayOfWeek = date.day();
|
||||
// Should not be Saturday (6) or Sunday (0)
|
||||
expect(dayOfWeek).not.toBe(0);
|
||||
expect(dayOfWeek).not.toBe(6);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("should render 12 mini-months", () => {
|
||||
yearView.render();
|
||||
|
||||
// Should have 12 mini-month containers
|
||||
const miniMonths = containerEl.querySelectorAll(".calendar-mini-month");
|
||||
expect(miniMonths.length).toBe(12);
|
||||
|
||||
// Each should have a header with month name
|
||||
const monthHeaders = containerEl.querySelectorAll(".mini-month-header");
|
||||
expect(monthHeaders.length).toBe(12);
|
||||
|
||||
// Verify month names are present
|
||||
const monthNames = Array.from(monthHeaders).map(
|
||||
(el) => el.textContent
|
||||
);
|
||||
expect(monthNames).toContain("January");
|
||||
expect(monthNames).toContain("December");
|
||||
});
|
||||
|
||||
test("should render only work days in January 2024 mini-month", () => {
|
||||
yearView.render();
|
||||
|
||||
// Get the first mini-month (January)
|
||||
const miniMonths = containerEl.querySelectorAll(".calendar-mini-month");
|
||||
const januaryMonth = miniMonths[0];
|
||||
|
||||
// Get day cells from January mini-month
|
||||
const januaryDayCells = januaryMonth.querySelectorAll(".mini-day-cell");
|
||||
const datesInJanuary = Array.from(januaryDayCells).map((cell) =>
|
||||
cell.getAttribute("data-date")
|
||||
);
|
||||
|
||||
// Check that work days are present and weekend days are not
|
||||
// January 1, 2024 is a Monday
|
||||
const workDays = [
|
||||
"2024-01-01", // Monday
|
||||
"2024-01-02", // Tuesday
|
||||
"2024-01-03", // Wednesday
|
||||
"2024-01-04", // Thursday
|
||||
"2024-01-05", // Friday
|
||||
];
|
||||
|
||||
const weekendDays = [
|
||||
"2024-01-06", // Saturday
|
||||
"2024-01-07", // Sunday
|
||||
];
|
||||
|
||||
// Work days should be present
|
||||
workDays.forEach((date) => {
|
||||
expect(datesInJanuary).toContain(date);
|
||||
});
|
||||
|
||||
// Weekend days should not be present
|
||||
weekendDays.forEach((date) => {
|
||||
expect(datesInJanuary).not.toContain(date);
|
||||
});
|
||||
});
|
||||
|
||||
test("should have correct grid layout with 5 columns for mini-months when weekends hidden", () => {
|
||||
yearView.render();
|
||||
|
||||
// Check that the container has the hide-weekends class
|
||||
expect(containerEl.classList.contains("hide-weekends")).toBe(true);
|
||||
|
||||
// All mini-month grids should be present
|
||||
const miniMonthGrids = containerEl.querySelectorAll(".mini-month-grid");
|
||||
expect(miniMonthGrids.length).toBe(12);
|
||||
|
||||
// Each mini-month should have weekday headers
|
||||
const miniWeekdayHeaders = containerEl.querySelectorAll(".mini-weekday-header");
|
||||
expect(miniWeekdayHeaders.length).toBe(12);
|
||||
});
|
||||
|
||||
test("should render 7 days when hideWeekends is false", () => {
|
||||
// Mock getViewSettingOrDefault to return hideWeekends: false
|
||||
const { getViewSettingOrDefault } = require("../../../../common/setting-definition");
|
||||
getViewSettingOrDefault.mockReturnValue({
|
||||
specificConfig: {
|
||||
firstDayOfWeek: 1,
|
||||
hideWeekends: false,
|
||||
},
|
||||
});
|
||||
|
||||
// Create new instance with weekends enabled
|
||||
const yearViewWithWeekends = new YearView(
|
||||
mockApp,
|
||||
mockPlugin,
|
||||
containerEl,
|
||||
moment("2024-01-01"),
|
||||
[],
|
||||
{}
|
||||
);
|
||||
|
||||
yearViewWithWeekends.render();
|
||||
|
||||
// Should have 7 * 12 = 84 weekday headers (7 per month, 12 months)
|
||||
const miniWeekdayHeaders = containerEl.querySelectorAll(".mini-weekday");
|
||||
expect(miniWeekdayHeaders.length).toBe(84);
|
||||
|
||||
// Should not have hide-weekends class
|
||||
expect(containerEl.classList.contains("hide-weekends")).toBe(false);
|
||||
|
||||
yearViewWithWeekends.onunload();
|
||||
});
|
||||
});
|
||||
|
|
@ -68,5 +68,6 @@
|
|||
"8.9.0": "0.15.2",
|
||||
"8.10.0": "0.15.2",
|
||||
"8.10.1": "0.15.2",
|
||||
"9.0.0-beta.1": "0.15.2"
|
||||
"9.0.0-beta.1": "0.15.2",
|
||||
"9.0.0-beta.2": "0.15.2"
|
||||
}
|
||||
Loading…
Reference in a new issue