Add additional lint rules

This commit is contained in:
Aerilyn Weber 2026-05-19 16:15:15 +09:00
parent 02d782c3da
commit 420b18eb78
67 changed files with 3686 additions and 1415 deletions

View file

@ -14,9 +14,20 @@ describe('ShoppingListsPage', () => {
vi.clearAllMocks();
vi.mocked(useApiModule.useApi).mockReturnValue({
householdId: 'hh1',
householdIds: ['hh1'],
isLoading: false,
user: null,
token: '123',
isAuthenticated: true,
profile: {
_id: 'user1',
keycloakId: 'user1',
displayName: 'Test User',
email: 'test@example.com',
householdIds: ['hh1'],
defaultHouseholdId: 'hh1',
createdAt: '2026-05-10T00:00:00.000Z',
updatedAt: '2026-05-10T00:00:00.000Z',
},
refreshProfile: vi.fn(),
});
vi.mocked(ShoppingListsService.getShoppingLists).mockResolvedValue([
{ id: 'list2', name: 'Completed Costco', status: 'completed', items: [], totalEstimatedCost: 50, createdAt: '2026-05-09' } as any,
@ -68,9 +79,7 @@ describe('ShoppingListsPage', () => {
it('opens generate from meal plan modal', async () => {
vi.mocked(MealPlansService.listMealPlans).mockResolvedValue({
data: [{ _id: 'mp1', status: 'active', weekStartDate: '2026-05-10', days: [] } as any],
total: 1,
page: 1,
limit: 10,
pagination: { cursor: null, hasMore: false }
});
vi.mocked(ShoppingListsService.generateFromMealPlan).mockResolvedValue({
id: 'list3', name: 'Generated', status: 'active', items: [], createdAt: '2026-05-11'
@ -104,7 +113,7 @@ describe('ShoppingListsPage', () => {
it('can cancel/close creation and gap scanning modals', async () => {
vi.mocked(MealPlansService.listMealPlans).mockResolvedValue({
data: [],
total: 0, page: 1, limit: 10
pagination: { cursor: null, hasMore: false }
});
const { container } = render(<ShoppingListsPage />);
@ -165,7 +174,7 @@ describe('ShoppingListsPage', () => {
it('handles generate from meal plan failure', async () => {
vi.mocked(MealPlansService.listMealPlans).mockResolvedValue({
data: [{ _id: 'mp1', status: 'active', weekStartDate: '2026-05-10', days: [] } as any],
total: 1, page: 1, limit: 10
pagination: { cursor: null, hasMore: false }
});
vi.mocked(ShoppingListsService.generateFromMealPlan).mockRejectedValue(new Error('Gen failed'));
const alertSpy = vi.spyOn(window, 'alert').mockImplementation(() => {});
@ -314,7 +323,7 @@ describe('ShoppingListsPage', () => {
it('handles gap scanner generation failure with generic error fallback', async () => {
vi.mocked(MealPlansService.listMealPlans).mockResolvedValue({
data: [{ _id: 'mp1', status: 'active', weekStartDate: '2026-05-10', days: [] } as any],
total: 1, page: 1, limit: 10
pagination: { cursor: null, hasMore: false }
});
vi.mocked(ShoppingListsService.generateFromMealPlan).mockRejectedValue({});
const alertSpy = vi.spyOn(window, 'alert').mockImplementation(() => {});

View file

@ -130,7 +130,7 @@ describe('Icon', () => {
});
it('renders null for invalid icon name', () => {
const { container } = render(<Icon name="nonexistent" as any />);
const { container } = render(<Icon name={"nonexistent" as any} />);
const svg = container.querySelector('svg');
expect(svg).toBeInTheDocument();
expect(svg?.childNodes.length).toBe(0);

View file

@ -80,7 +80,7 @@ describe('shopping-lists service', () => {
const urlInsecure = ShoppingListsService.getShoppingListSyncSocketUrl('hh1', 'list1');
expect(urlInsecure).toBe('ws://localhost:3001/households/hh1/shopping-lists/list1/sync');
apiClient.baseUrl = 'https://api.meshitrack.com';
(apiClient as any).baseUrl = 'https://api.meshitrack.com';
const urlSecure = ShoppingListsService.getShoppingListSyncSocketUrl('hh1', 'list1');
expect(urlSecure).toBe('wss://api.meshitrack.com/households/hh1/shopping-lists/list1/sync');