From 30bd13c7bc7a222d2e3075ee629f430fe4021e2f Mon Sep 17 00:00:00 2001 From: Julius van Dis Date: Wed, 8 Jan 2025 20:30:56 +0100 Subject: [PATCH] typecheck testfiles and storybook files as well --- .storybook/{preview.ts => preview.tsx} | 0 .../{ExpensesCard.spec.js => ExpensesCard.spec.tsx} | 9 +++++---- src/main/react/components/holiday-card/HolidayCard.tsx | 8 ++++---- src/main/react/theme/theme-light.ts | 1 + .../components/contracts/ContractsEnding.stories.tsx | 10 ++++------ .../components/holiday-card/HolidayCard.stories.tsx | 2 +- .../upcoming-events-card/FlockEventList.stories.tsx | 6 ++++++ tsconfig.json | 6 +----- 8 files changed, 22 insertions(+), 20 deletions(-) rename .storybook/{preview.ts => preview.tsx} (100%) rename src/main/react/components/expenses-card/{ExpensesCard.spec.js => ExpensesCard.spec.tsx} (90%) diff --git a/.storybook/preview.ts b/.storybook/preview.tsx similarity index 100% rename from .storybook/preview.ts rename to .storybook/preview.tsx diff --git a/src/main/react/components/expenses-card/ExpensesCard.spec.js b/src/main/react/components/expenses-card/ExpensesCard.spec.tsx similarity index 90% rename from src/main/react/components/expenses-card/ExpensesCard.spec.js rename to src/main/react/components/expenses-card/ExpensesCard.spec.tsx index cb4ed18b..7d579284 100644 --- a/src/main/react/components/expenses-card/ExpensesCard.spec.js +++ b/src/main/react/components/expenses-card/ExpensesCard.spec.tsx @@ -1,13 +1,14 @@ import React from "react"; import { render, screen, cleanup } from "@testing-library/react"; import "@testing-library/jest-dom"; -import { ExpensesCard } from "./ExpensesCard.tsx"; +import { ExpensesCard } from "./ExpensesCard"; import { createTestCostExpense, createTestTravelExpense, } from "../../utils/tests/test-models"; import dayjs from "dayjs"; import { Status } from "../../models/Status"; +import { CostExpense, TravelExpense } from "../../models/Expense"; describe("ExpensesCard", () => { const testExpense001 = createTestCostExpense("item-01", dayjs()); @@ -36,7 +37,7 @@ describe("ExpensesCard", () => { Status.REJECTED ); - const expenses = [ + const expenses: (CostExpense | TravelExpense)[] = [ testExpense001, testExpense002, testExpense003, @@ -50,7 +51,7 @@ describe("ExpensesCard", () => { }); describe("without expenses", () => { - let expenseCardElement; + let expenseCardElement: HTMLElement | null; beforeEach(() => { render(); expenseCardElement = screen.queryByTestId("expenses-card"); @@ -69,7 +70,7 @@ describe("ExpensesCard", () => { }); describe("with expenses", () => { - let expenseCardElement; + let expenseCardElement: HTMLElement | null; beforeEach(() => { render(); expenseCardElement = screen.queryByTestId("expenses-card"); diff --git a/src/main/react/components/holiday-card/HolidayCard.tsx b/src/main/react/components/holiday-card/HolidayCard.tsx index 7243e3a4..a0f0e9e3 100644 --- a/src/main/react/components/holiday-card/HolidayCard.tsx +++ b/src/main/react/components/holiday-card/HolidayCard.tsx @@ -1,4 +1,4 @@ -import { Card, CardContent, CardHeader } from "@material-ui/core"; +import { Card, CardContent, CardHeader, Typography } from "@material-ui/core"; import React, { useEffect, useState } from "react"; import { PersonHolidayDetails } from "../../clients/AggregationClient"; import { hoursFormatter } from "../../utils/Hours"; @@ -14,7 +14,7 @@ const useStyles = makeStyles(() => ({ display: "flex", flexDirection: "row", justifyContent: "center", - alignItems: "baseline", + alignItems: "center", "@container (max-width: 500px)": { flexDirection: "column", alignItems: "center", @@ -74,13 +74,13 @@ export function HolidayCard({ item }: HolidayCardProps) {
- You have + You have
{hoursFormatter.format(available)}
- hours left + hours left
diff --git a/src/main/react/theme/theme-light.ts b/src/main/react/theme/theme-light.ts index 60c45a1f..1cf617ab 100644 --- a/src/main/react/theme/theme-light.ts +++ b/src/main/react/theme/theme-light.ts @@ -41,6 +41,7 @@ export const themeLight = createTheme({ export const highLightClass = makeStyles((theme) => ({ highlight: { position: "relative", + fontFamily: theme.typography.fontFamily, "&::before": { content: '""', backgroundColor: theme.palette.primary.main, diff --git a/src/storybook/components/contracts/ContractsEnding.stories.tsx b/src/storybook/components/contracts/ContractsEnding.stories.tsx index b91417f6..ab9edf99 100644 --- a/src/storybook/components/contracts/ContractsEnding.stories.tsx +++ b/src/storybook/components/contracts/ContractsEnding.stories.tsx @@ -27,12 +27,11 @@ const meta: Meta = { shirtSize: "M", user: "4dbc2ac4-fc48-4511-a189-bf0d79f7e898", fullName: "Bert Muppets", + receiveEmail: false, + googleDriveId: "", }, from: dayjs("2022-10-16"), to: dayjs("2023-11-24"), - hourlyRate: 80.0, - hoursPerWeek: 40, - billable: true, type: "EXTERNAL", }, ], @@ -69,12 +68,11 @@ export const within6weeks: Story = { shirtSize: "M", user: "4dbc2ac4-fc48-4511-a189-bf0d79f7e898", fullName: "Bert Muppets", + receiveEmail: false, + googleDriveId: "", }, from: dayjs("2022-10-16"), to: dayjs("2023-11-24"), - hourlyRate: 80.0, - hoursPerWeek: 40, - billable: true, type: "EXTERNAL", }, ], diff --git a/src/storybook/components/holiday-card/HolidayCard.stories.tsx b/src/storybook/components/holiday-card/HolidayCard.stories.tsx index 68f92340..79e3412e 100644 --- a/src/storybook/components/holiday-card/HolidayCard.stories.tsx +++ b/src/storybook/components/holiday-card/HolidayCard.stories.tsx @@ -25,6 +25,6 @@ export const withDefaultHours: Story = {}; export const noData: Story = { args: { - item: {}, + item: undefined, }, }; diff --git a/src/storybook/components/upcoming-events-card/FlockEventList.stories.tsx b/src/storybook/components/upcoming-events-card/FlockEventList.stories.tsx index 7dcec323..b3bb6a8e 100644 --- a/src/storybook/components/upcoming-events-card/FlockEventList.stories.tsx +++ b/src/storybook/components/upcoming-events-card/FlockEventList.stories.tsx @@ -1,6 +1,7 @@ import { Meta, StoryObj } from "@storybook/react"; import { EventList } from "../../../main/react/components/upcoming-events/EventList"; import dayjs from "dayjs"; +import { EventType } from "../../../main/react/clients/EventClient"; const meta: Meta = { component: EventList, @@ -20,6 +21,7 @@ export const withData: Story = { { description: "Super nice event that takes place!", id: 2712, + type: EventType.GENERAL_EVENT, code: "event-code", from: dayjs(), to: dayjs().add(1, "day"), @@ -31,6 +33,7 @@ export const withData: Story = { { description: "Smashing Conference - Freiburg", id: 2712, + type: EventType.GENERAL_EVENT, code: "event-code", from: dayjs(), to: dayjs().add(4, "day"), @@ -42,6 +45,7 @@ export const withData: Story = { { description: "FLock Hack Day - Flock HQ.", id: 2712, + type: EventType.GENERAL_EVENT, code: "event-code", from: dayjs(), to: dayjs(), @@ -53,6 +57,7 @@ export const withData: Story = { { description: "FLock Hack Day - Flock HQ.", id: 2712, + type: EventType.GENERAL_EVENT, code: "event-code", from: dayjs(), to: dayjs(), @@ -64,6 +69,7 @@ export const withData: Story = { { description: "Random event- Flock HQ.", id: 2712, + type: EventType.GENERAL_EVENT, code: "event-code", from: dayjs(), to: dayjs(), diff --git a/tsconfig.json b/tsconfig.json index cf65a582..7e83e64a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,9 +17,5 @@ "jsx": "react", "noImplicitAny": false }, - "exclude": [ - "node_modules", - "**/*.stories.tsx", - "**/*.spec.ts" - ] + "exclude": ["node_modules"] }