Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions apps/autodial/functions/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"google",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
Expand All @@ -20,19 +19,18 @@ module.exports = {
ignorePatterns: [
"/lib/**/*", // Ignore built files.
],
plugins: [
"@typescript-eslint",
"import",
],
plugins: ["@typescript-eslint", "import"],
rules: {
"quotes": ["error", "double"],
quotes: ["error", "double"],
"import/no-unresolved": 0,
"require-jsdoc": 0,
},
overrides: [{
files: "**/*.spec.+(ts|tsx)",
rules: {
"@typescript-eslint/no-explicit-any": "off",
overrides: [
{
files: "**/*.spec.+(ts|tsx)",
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
},
}],
],
};
3 changes: 3 additions & 0 deletions apps/autodial/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"displayName": "functions",
"preset": "ts-jest",
"testEnvironment": "node",
"testEnvironmentOptions": {
"url": "http://localhost/"
},
"resetMocks": true,
"roots": [
"<rootDir>"
Expand Down
17 changes: 7 additions & 10 deletions apps/autodial/functions/src/test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {expect} from "@jest/globals";
import Matchers = jest.Matchers;
import {
fillroadall,
Expand All @@ -7,9 +6,10 @@ import {
fuzzyEquals,
Datapoint,
Goal,
GoalVerbose, DenseSegment,
GoalVerbose,
DenseSegment,
} from "../../../src/lib";
import {setLogger} from "react-query";
import { setLogger } from "react-query";

interface MyMatchers<R> extends Matchers<R> {
toFuzzyEqual(expected: number): R;
Expand All @@ -20,14 +20,12 @@ expect.extend({
const pass = fuzzyEquals(expected, received);
if (pass) {
return {
message: () =>
`expected ${received} not to fuzzy equal ${expected}`,
message: () => `expected ${received} not to fuzzy equal ${expected}`,
pass: true,
};
} else {
return {
message: () =>
`expected ${received} to fuzzy equal ${expected}`,
message: () => `expected ${received} to fuzzy equal ${expected}`,
pass: false,
};
}
Expand All @@ -37,8 +35,7 @@ expect.extend({
export const e = expect as never as <T>(actual: T) => MyMatchers<T>;

type DatapointInput = Omit<Datapoint, "timestamp"> & { timestamp?: number };
export type GoalInput = Partial<Goal>
& { datapoints?: DatapointInput[] }
export type GoalInput = Partial<Goal> & { datapoints?: DatapointInput[] };

function getRate(g: GoalInput, mathishard: DenseSegment | undefined): number {
if (g.rate !== undefined) {
Expand Down Expand Up @@ -82,7 +79,7 @@ export function makeGoal(g: GoalInput = {}): GoalVerbose {
}

export async function withMutedReactQueryLogger<T>(
func: () => Promise<T>
func: () => Promise<T>
): Promise<T> {
const noop = () => {
// do nothing
Expand Down
14 changes: 10 additions & 4 deletions apps/autodial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@mui/lab": "^5.0.0-alpha.63",
"@mui/material": "^5.2.7",
"@netlify/functions": "^0.7.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/node": "^12.0.0",
Expand Down Expand Up @@ -45,7 +45,10 @@
{
"displayName": "web",
"preset": "ts-jest",
"testEnvironment": "node",
"testEnvironment": "jest-environment-jsdom",
"testEnvironmentOptions": {
"url": "http://localhost/"
},
"resetMocks": true,
"moduleNameMapper": {
"\\.(css|jpg|jpeg|png|gif|eot|otf|webp|svg)$": "<rootDir>/src/__mocks__/fileMock.ts"
Expand Down Expand Up @@ -78,8 +81,10 @@
]
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/jest": "^29.5.2",
"@types/lodash": "^4.14.195",
"@types/node-fetch": "^2.5.10",
"@types/testing-library__jest-dom": "^5.14.5",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"eslint": "^7.29.0",
Expand All @@ -88,9 +93,10 @@
"eslint-plugin-import": "^2.23.4",
"firebase-functions-test": "^0.3.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"netlify-cli": "^10.6.0",
"prettier": "2.7.1",
"ts-jest": "^26.5.5",
"ts-jest": "^29.1.0",
"typescript": "^4.3.4"
}
}
22 changes: 9 additions & 13 deletions apps/autodial/src/App.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment jsdom
*/

import React from "react";
import { waitFor, screen } from "@testing-library/react";
import App from "./App";
Expand Down Expand Up @@ -223,23 +219,23 @@ describe("Home page", () => {
});

it("displays min value", async () => {
setNow(2009, 3, 1);

loadGoals([{ slug: "the_slug", rate: 3, fineprint: "#autodialMin=1.5" }]);

const { getByText } = await r(<App />);
r(<App />);

await waitFor(() => {
expect(getByText("1.5/d")).toBeInTheDocument();
});
expect(await screen.findByText("1.5/d")).toBeInTheDocument();
});

it("displays positive value", async () => {
loadGoals([{ slug: "the_slug", rate: 3, fineprint: "#autodialMax=1" }]);
setNow(2009, 3, 1);

const { getByText } = await r(<App />);
loadGoals([{ slug: "the_slug", rate: 3, fineprint: "#autodialMax=5" }]);

await waitFor(() => {
expect(getByText("1/d")).toBeInTheDocument();
});
r(<App />);

expect(await screen.findByText("5/d")).toBeInTheDocument();
});

it("removes login button when data loads successfully", async () => {
Expand Down
1 change: 1 addition & 0 deletions apps/autodial/src/component/molecule/goalRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default function GoalRow({ goal, username }: Props): JSX.Element {
setPendingRate(newRate === null ? false : newRate);
setArpn(arpn);
} catch (e: unknown) {
console.error(e);
if (e instanceof Error) {
setError(e.message);
} else {
Expand Down
1 change: 0 additions & 1 deletion apps/autodial/src/lib/dial.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { dial } from "./dial";
import { describe, it } from "@jest/globals";
import { e, makeGoal } from "../../functions/src/test/helpers";
import { parseDate } from "./time";
import { setNow } from "./test/helpers";
Expand Down
11 changes: 2 additions & 9 deletions apps/autodial/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -21,8 +17,5 @@
"jsx": "react-jsx",
"baseUrl": "."
},
"include": [
"src",
"jest.config.js",
],
"include": ["src", "jest.config.js", "./src/setupTests.ts"]
}
47 changes: 24 additions & 23 deletions apps/focusqueue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,41 @@
"preview": "vite preview",
"test": "vitest",
"lint": "eslint .",
"unused": "depcheck"
"unused": "depcheck",
"checkTs": "tsc --noEmit"
},
"dependencies": {
"@bradgarropy/use-countdown": "^1.5.2",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/lab": "5.0.0-alpha.120",
"@mui/material": "^5.11.10",
"@tanstack/react-query": "^4.24.10",
"axios": "^1.3.4",
"firebase": "^9.17.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/lab": "5.0.0-alpha.134",
"@mui/material": "^5.13.5",
"@tanstack/react-query": "^4.29.12",
"axios": "^1.4.0",
"firebase": "^9.22.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.8.1"
"react-router-dom": "^6.12.1"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/testing-library__jest-dom": "^5.14.5",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"@vitejs/plugin-react-swc": "^3.2.0",
"@types/react": "^18.2.11",
"@types/react-dom": "^18.2.5",
"@types/testing-library__jest-dom": "^5.14.6",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"@vitejs/plugin-react-swc": "^3.3.2",
"depcheck": "^1.4.3",
"eslint": "^8.34.0",
"eslint": "^8.42.0",
"eslint-plugin-react": "^7.32.2",
"jsdom": "^21.1.0",
"prettier": "^2.8.4",
"tslib": "^2.5.0",
"typescript": "^4.9.5",
"vite": "^4.1.4",
"vite-aliases": "^0.10.0",
"vitest": "^0.28.5"
"jsdom": "^22.1.0",
"prettier": "^2.8.8",
"tslib": "^2.5.3",
"typescript": "^5.1.3",
"vite": "^4.3.9",
"vite-aliases": "^0.11.2",
"vitest": "^0.32.0"
}
}
2 changes: 1 addition & 1 deletion apps/focusqueue/src/App.flow.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import App from "./App";
import userEvent from "@testing-library/user-event";
import { useAuthenticatedUser } from "@services/firebase/auth";
import { useAuthenticatedUser } from "~services/firebase/auth";
import React from "react";

// TODO: Consider making this Flow.spec since describe has Flow
Expand Down
2 changes: 1 addition & 1 deletion apps/focusqueue/src/App.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
loginWithGoogle,
logout,
useAuthenticatedUser,
} from "@services/firebase/auth";
} from "~services/firebase/auth";
import React from "react";

vi.mock("./lib/speak");
Expand Down
6 changes: 3 additions & 3 deletions apps/focusqueue/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import CssBaseline from "@mui/material/CssBaseline";
import Container from "@mui/material/Container";
import Flow from "@components/Flow";
import AuthControls from "@components/AuthControls";
import Flow from "~components/Flow";
import AuthControls from "~components/AuthControls";
import { Action, initialState, reducer, State } from "./App.reducer";
import React, { createContext, Dispatch, useReducer } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import Typography from "@mui/material/Typography";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import Settings from "@components/Settings";
import Settings from "~components/Settings";

const queryClient = new QueryClient();

Expand Down
2 changes: 1 addition & 1 deletion apps/focusqueue/src/components/AuthControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
useAuthenticatedUser,
logout,
loginWithGithub,
} from "@services/firebase/auth";
} from "~services/firebase/auth";
import Stack from "@mui/material/Stack";
import Dialog from "@mui/material/Dialog";
import { DialogContent } from "@mui/material";
Expand Down
2 changes: 1 addition & 1 deletion apps/focusqueue/src/components/Countdown.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect, vi } from "vitest";
import { render, screen, act, waitFor } from "@testing-library/react";
import Countdown from "./Countdown";
import userEvent from "@testing-library/user-event";
import speak from "@lib/speak";
import speak from "~lib/speak";
import React from "react";
import { __advance, __complete, __reset } from "@bradgarropy/use-countdown";

Expand Down
4 changes: 2 additions & 2 deletions apps/focusqueue/src/components/Countdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Button from "@mui/material/Button";
import useCountdown from "@bradgarropy/use-countdown";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import speak from "@lib/speak";
import convertStringToNumericSeconds from "@lib/convertStringToNumericSeconds";
import speak from "~lib/speak";
import convertStringToNumericSeconds from "~lib/convertStringToNumericSeconds";
import React from "react";

export default function Countdown({
Expand Down
8 changes: 4 additions & 4 deletions apps/focusqueue/src/components/Dump.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render, screen, waitFor } from "@testing-library/react";
import { describe, it, expect, beforeEach, vi } from "vitest";
import Dump from "./Dump";
import { State } from "@/App.reducer";
import { State } from "~/App.reducer";
import userEvent from "@testing-library/user-event";
import { authenticate, getBoards } from "@services/trello";
import { updateMe } from "@services/firebase/firestore";
import { useMe } from "@services/firebase/firestore";
import { authenticate, getBoards } from "~services/trello";
import { updateMe } from "~services/firebase/firestore";
import { useMe } from "~services/firebase/firestore";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import React from "react";

Expand Down
4 changes: 2 additions & 2 deletions apps/focusqueue/src/components/Dump.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import TextField from "@mui/material/TextField";
import Button from "@mui/material/Button";
import { useEffect } from "react";
import { addTask, updateMe, useMe } from "@services/firebase/firestore";
import { State, Action } from "@/App.reducer";
import { addTask, updateMe, useMe } from "~services/firebase/firestore";
import { State, Action } from "~/App.reducer";
import TrelloDialog from "./TrelloDialog";
import { Stack } from "@mui/material";
import React from "react";
Expand Down
10 changes: 5 additions & 5 deletions apps/focusqueue/src/components/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import Typography from "@mui/material/Typography";
import Stack from "@mui/material/Stack";
import Dump from "./Dump";
import { useContext } from "react";
import { AppContext } from "@/App";
import withAuth from "@lib/withAuth";
import { createDatapoint } from "@services/beeminder";
import { useMe } from "@services/firebase/firestore";
import convertStringToNumericSeconds from "@lib/convertStringToNumericSeconds";
import { AppContext } from "~/App";
import withAuth from "~lib/withAuth";
import { createDatapoint } from "~services/beeminder";
import { useMe } from "~services/firebase/firestore";
import convertStringToNumericSeconds from "~lib/convertStringToNumericSeconds";
import React from "react";

function Flow() {
Expand Down
Loading