#708 apply strictier linting rules (#717)

* #708 apply strictier linting rules and fix simple eslint bugs

* #708 fix eslint errors relate to promise

* #708 fix eslint import/no-extraneous-dependencies

* #708 fix eslint errors of react-hook

* #708 enable eslint check for typescript

---------

Co-authored-by: lethemanh <lethemanh@lethemanhs-MacBook-Pro.local>
This commit is contained in:
lethemanh
2026-04-01 22:15:10 +07:00
committed by GitHub
parent 2bff6aae78
commit cadfa70e60
321 changed files with 27452 additions and 27600 deletions
+60 -62
View File
@@ -1,102 +1,100 @@
import CalendarLayout from "@/components/Calendar/CalendarLayout";
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import { renderWithProviders } from "../utils/Renderwithproviders";
import CalendarLayout from '@/components/Calendar/CalendarLayout'
import { act, fireEvent, screen, waitFor } from '@testing-library/react'
import { renderWithProviders } from '../utils/Renderwithproviders'
describe("Event Error Handling", () => {
describe('Event Error Handling', () => {
beforeEach(() => {
localStorage.clear();
jest.clearAllMocks();
});
localStorage.clear()
jest.clearAllMocks()
})
const today = new Date();
const start = new Date(today);
start.setHours(10, 0, 0, 0);
const end = new Date(today);
end.setHours(11, 0, 0, 0);
const today = new Date()
const start = new Date(today)
start.setHours(10, 0, 0, 0)
const end = new Date(today)
end.setHours(11, 0, 0, 0)
const erroredState = {
user: {
userData: {
sub: "test",
email: "test@test.com",
sid: "mockSid",
openpaasId: "user1",
sub: 'test',
email: 'test@test.com',
sid: 'mockSid',
openpaasId: 'user1'
},
tokens: { accessToken: "token" },
tokens: { accessToken: 'token' }
},
calendars: {
list: {
"user1/cal1": {
name: "Calendar personal",
id: "user1/cal1",
color: { light: "#FF0000", dark: "#000" },
owner: { emails: ["alice@example.com"] },
'user1/cal1': {
name: 'Calendar personal',
id: 'user1/cal1',
color: { light: '#FF0000', dark: '#000' },
owner: { emails: ['alice@example.com'] },
events: {
event1: {
id: "event1",
calId: "user1/cal1",
uid: "event1",
title: "Test Event",
id: 'event1',
calId: 'user1/cal1',
uid: 'event1',
title: 'Test Event',
start: start.toISOString(),
end: start.toISOString(),
partstat: "ACCEPTED",
partstat: 'ACCEPTED',
organizer: {
cn: "Alice",
cal_address: "alice@example.com",
cn: 'Alice',
cal_address: 'alice@example.com'
},
attendee: [
{
cn: "Alice",
partstat: "ACCEPTED",
rsvp: "TRUE",
role: "REQ-PARTICIPANT",
cutype: "INDIVIDUAL",
cal_address: "alice@example.com",
},
],
},
},
},
cn: 'Alice',
partstat: 'ACCEPTED',
rsvp: 'TRUE',
role: 'REQ-PARTICIPANT',
cutype: 'INDIVIDUAL',
cal_address: 'alice@example.com'
}
]
}
}
}
},
pending: false,
},
};
pending: false
}
}
it("BUGFIX: does not re-report errors after clearing error snackbar", async () => {
const consoleWarnSpy = jest.spyOn(console, "warn").mockImplementation();
it('BUGFIX: does not re-report errors after clearing error snackbar', async () => {
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation()
await act(async () =>
renderWithProviders(<CalendarLayout />, erroredState)
);
await act(async () => renderWithProviders(<CalendarLayout />, erroredState))
await waitFor(
() => {
expect(screen.getByText("Test Event"));
expect(screen.getByRole("alert")).toBeInTheDocument();
expect(screen.getByText('Test Event'))
expect(screen.getByRole('alert')).toBeInTheDocument()
},
{ timeout: 10000 }
);
const closeButton = screen.queryByRole("button", { name: "common.ok" });
)
const closeButton = screen.queryByRole('button', { name: 'common.ok' })
if (closeButton) {
const initialWarnCount = consoleWarnSpy.mock.calls.length;
const initialWarnCount = consoleWarnSpy.mock.calls.length
await act(async () => {
fireEvent.click(closeButton);
});
fireEvent.click(closeButton)
})
await waitFor(
() => {
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
expect(screen.queryByRole('alert')).not.toBeInTheDocument()
},
{ timeout: 5000 }
);
)
const afterCloseWarnCount = consoleWarnSpy.mock.calls.length;
const afterCloseWarnCount = consoleWarnSpy.mock.calls.length
expect(afterCloseWarnCount).toBe(initialWarnCount);
expect(afterCloseWarnCount).toBe(initialWarnCount)
}
consoleWarnSpy.mockRestore();
}, 15000);
});
consoleWarnSpy.mockRestore()
}, 15000)
})