Skip to content
Draft
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
File renamed without changes.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.9.0
23.6.1
File renamed without changes.
12 changes: 7 additions & 5 deletions .storybook/main.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { StorybookConfig } from "@storybook/react-vite";
import path from "path";
import { type StorybookConfig } from "@storybook/react-vite";
import { mergeConfig } from "vite";

const config: StorybookConfig = {
Expand All @@ -17,9 +16,12 @@ const config: StorybookConfig = {
// See https://github.com/vitejs/vite/issues/8644#issuecomment-1159308803
logOverride: { "this-is-undefined-in-esm": "silent" },
},
// Add aliasing to resolve absolute paths for imports
resolve: { alias: { src: path.resolve(__dirname, "../src") } },
optimizeDeps: ["@emotion/react/jsx-dev-runtime"],
// If you see weird errors around `createElement is undefined`, it is likely because of
// React now wanting the `key` prop to always come first:
//
// - https://github.com/facebook/react/pull/25697/files?diff=unified&w=1
// - https://github.com/vitejs/vite/issues/6215
// - https://github.com/mui/material-ui/issues/39833
});
},

Expand Down
5 changes: 4 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { Config } from "@jest/types";
import { createDefaultEsmPreset } from "ts-jest";

const presetConfig = createDefaultEsmPreset({ isolatedModules: true });

const config: Config.InitialOptions = {
preset: "ts-jest",
...presetConfig,
testEnvironment: "jsdom",
moduleNameMapper: {
"^src(.*)": "<rootDir>/src$1",
Expand Down
43 changes: 30 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "@homebound/beam",
"version": "2.378.1",
"type": "module",
"author": "Homebound",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/homebound-team/beam"
Expand All @@ -14,23 +13,39 @@
"!dist/**/*.{stories,test}.*",
"!dist/setupTests.*"
],
"exports": {
".": {
"import": "dist/index.js",
"typings": "dist/index.d.ts",
"style": "dist/index.css"
},
"./rtl": {
"import": "dist/utils/rtl.js",
"typings": "dist/utils/rtl.d.ts"
},
"./sb": {
"import": "dist/utils/sb.js",
"typings": "dist/utils/sb.d.ts"
}
},
"engines": {
"node": "~20.9.0"
},
"scripts": {
"start": "yarn storybook",
"build": "yarn copy && tspc",
"build": "yarn tsup-node src/index.ts src/utils/rtl.tsx src/utils/sb.tsx --format esm --dts --clean --sourcemap",
"build:truss": "truss",
"build-storybook": "NODE_OPTIONS=--openssl-legacy-provider storybook build",
"test": "jest --maxWorkers 4",
"test:watch": "jest --watch",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --maxWorkers 4",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
"lint": "eslint --ext js,ts,tsx src",
"lint:fix": "eslint --ext js,ts,tsx --fix src",
"storybook": "NODE_OPTIONS=--openssl-legacy-provider storybook dev -p 9000",
"chromatic": "chromatic --project-token=074248da7284 --exit-once-uploaded --only-changed",
"copy": "npx copyfiles -u 1 \"./src/**/*.css\" \"./dist/\"",
"copy-to-internal-frontend": "cp -r dist/* ~/homebound/internal-frontend/node_modules/@homebound/beam/dist/",
"format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,md,mdx}\""
"format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,md,mdx}\"",
"type-check": "yarn tsc"
},
"dependencies": {
"@homebound/form-state": "^2.25.2",
Expand All @@ -53,7 +68,7 @@
"react-virtuoso": "^4.2.2",
"tributejs": "^5.1.3",
"trix": "^1.3.1",
"use-debounce": "^7.0.1",
"use-debounce": "^10.0.4",
"use-query-params": "^1.2.2"
},
"peerDependencies": {
Expand All @@ -73,9 +88,10 @@
"devDependencies": {
"@emotion/react": "^11.10.6",
"@homebound/eslint-config": "^1.10.2",
"@homebound/fast-css-prop": "^1.137.4",
"@homebound/rtl-react-router-utils": "1.2.0",
"@homebound/rtl-utils": "^2.66.2",
"@homebound/truss": "^1.136.0",
"@homebound/truss": "^1.137.4",
"@homebound/tsconfig": "^1.1.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
Expand All @@ -98,7 +114,6 @@
"@types/react-beautiful-dnd": "^13.1.3",
"@types/react-dom": "^18.3.1",
"@types/react-router-dom": "^5.3.3",
"@vitejs/plugin-react": "^4.3.2",
"array-move": "^4.0.0",
"chromatic": "^11.12.6",
"conventional-changelog-conventionalcommits": "^5.0.0",
Expand All @@ -120,16 +135,18 @@
"storybook": "^8.5.1",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"ts-patch": "^3.2.1",
"tsup": "^8.3.6",
"typescript": "5.5.4",
"typescript-transform-paths": "^3.5.1",
"vite": "^5.4.9",
"vite-tsconfig-paths": "^5.0.1",
"vite": "^6.0.11",
"vite-tsconfig-paths": "^5.1.4",
"watch": "^1.0.2"
},
"resolutions": {
"@types/react": "18.0.28",
"react-router": "5.3.4"
},
"imports": {
"src/*": "./src/*"
},
"packageManager": "yarn@3.6.3"
}
1 change: 1 addition & 0 deletions src/components/Accordion.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { click, render } from "src/utils/rtl";
import { Accordion } from "./Accordion";

Expand Down
1 change: 1 addition & 0 deletions src/components/AutoSaveIndicator.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import React from "react";
import { noop } from "src/utils";
import { render } from "src/utils/rtl";
Expand Down
3 changes: 2 additions & 1 deletion src/components/AutoSaveStatus/useAutoSaveStatus.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { jest } from "@jest/globals";
import { act, renderHook } from "@testing-library/react";
import { AutoSaveStatus, AutoSaveStatusProvider } from "./AutoSaveStatusProvider";
import { useAutoSaveStatus } from "./useAutoSaveStatus";

describe(useAutoSaveStatus, () => {
describe("useAutoSaveStatus", () => {
/** The internal setTimeout running after tests is spamming the console, so cancel them all here */
afterEach(() => {
jest.clearAllTimers();
Expand Down
1 change: 1 addition & 0 deletions src/components/Avatar/AvatarButton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { AvatarButton } from "src/components/Avatar/AvatarButton";
import { click, render } from "src/utils/rtl";

Expand Down
1 change: 1 addition & 0 deletions src/components/Banner.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { Banner } from "src";
import { click, render } from "src/utils/rtl";

Expand Down
1 change: 1 addition & 0 deletions src/components/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { Button } from "src/components/Button";
import { noop } from "src/utils";
import { click, render, wait } from "src/utils/rtl";
Expand Down
1 change: 1 addition & 0 deletions src/components/ButtonDatePicker.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { ButtonDatePicker } from "src/components/ButtonDatePicker";
import { jan1, jan2 } from "src/forms/formStateDomain";
import { click, render } from "src/utils/rtl";
Expand Down
1 change: 1 addition & 0 deletions src/components/ButtonGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { ButtonGroup, ButtonGroupButton } from "src/components/ButtonGroup";
import { click, render } from "src/utils/rtl";
import { Css } from "..";
Expand Down
12 changes: 2 additions & 10 deletions src/components/Filters/Filters.test.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { wait } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { fireEvent } from "@testing-library/react";
import { useState } from "react";
import { booleanFilter, FilterDefs, Filters, multiFilter, singleFilter } from "src/components/Filters";
import { ProjectFilter, Stage } from "src/components/Filters/testDomain";
import { HasIdAndName } from "src/types";
import { click, render } from "src/utils/rtl";
import { zeroTo } from "src/utils/sb";
import { useDebounce } from "use-debounce";
import { MultiFilterProps } from "./MultiFilter";

jest.mock("use-debounce", () => {
const debounceMock = jest.fn((value, delay) => [value]); // Define the mock inline
return {
useDebounce: debounceMock,
};
});

describe("Filters", () => {
it("can match GQL types of enum arrays", () => {
// Given a filter with an enum[]
Expand Down Expand Up @@ -61,7 +54,6 @@ describe("Filters", () => {

it("calls onSearch with the debounced value", async () => {
const onSearchMock = jest.fn();
const debounceMock = jest.mocked(useDebounce);
// Given a stateful component that has initial values set
const r = await render(<TestFilterSearch onSearch={onSearchMock} />);

Expand All @@ -74,7 +66,7 @@ describe("Filters", () => {
// Then the only remaining option is one and the onSearch/debounce function was called with the correct value and delay
expect(r.queryAllByRole("option")).toHaveLength(1);
expect(onSearchMock).toHaveBeenCalledWith("1");
expect(debounceMock).toHaveBeenCalledWith("1", 300);
// expect(debounceMock).toHaveBeenCalledWith("1", 300);
});
});

Expand Down
1 change: 1 addition & 0 deletions src/components/IconButton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { IconButton } from "src/components/IconButton";
import { noop } from "src/utils";
import { click, render, withRouter } from "src/utils/rtl";
Expand Down
1 change: 1 addition & 0 deletions src/components/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { fireEvent } from "@testing-library/react";
import { useEffect } from "react";
import { ModalBody, ModalFooter, ModalProps, useModal } from "src/components/Modal";
Expand Down
1 change: 1 addition & 0 deletions src/components/Modal/useModal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { act } from "@testing-library/react";
import { useEffect } from "react";
import { BeamContextState, useBeamContext } from "src/components/BeamContext";
Expand Down
1 change: 1 addition & 0 deletions src/components/Pagination.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { noop } from "src/utils";
import { click, getOptions, render } from "src/utils/rtl";
import { PageSettings, Pagination, toLimitAndOffset } from "./Pagination";
Expand Down
1 change: 1 addition & 0 deletions src/components/Snackbar/SnackbarNotice.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { SnackbarNotice } from "src/components/Snackbar/SnackbarNotice";
import { noop } from "src/utils";
import { click, render } from "src/utils/rtl";
Expand Down
1 change: 1 addition & 0 deletions src/components/Stepper.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { Step, Stepper } from "src/components/Stepper";
import { click, render } from "src/utils/rtl";
import { zeroTo } from "src/utils/sb";
Expand Down
2 changes: 1 addition & 1 deletion src/components/SuperDrawer/SuperDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export function SuperDrawer(): ReactPortal | null {
<Global styles={{ body: Css.oh.$ }} />
{/* Overlay */}
<motion.div
{...testId}
// Key is required for framer-motion animations
key="superDrawer"
{...testId}
// TODO: Should this color be part of the Palette?
// z-index of 3 is used to give flexibility for future overlapping content
// Not using `inset` due to Safari 14.0.x not supporting this CSS property.
Expand Down
1 change: 1 addition & 0 deletions src/components/SuperDrawer/useSuperDrawer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { act, renderHook } from "@testing-library/react";
import { ReactElement, useEffect } from "react";
import { SuperDrawerHeader } from "src/components/SuperDrawer/components/SuperDrawerHeader";
Expand Down
1 change: 1 addition & 0 deletions src/components/Table/GridTable.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { act } from "@testing-library/react";
import { MutableRefObject, useContext, useMemo, useState } from "react";
import { GridDataRow } from "src/components/Table/components/Row";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from "@jest/globals";
import { MutableRefObject } from "react";
import { EditColumnsButton } from "src/components/Table/components/EditColumnsButton";
import { GridTable } from "src/components/Table/GridTable";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundCheckboxField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { click, render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { BoundCheckboxField } from "src/forms";
import { AuthorInput } from "src/forms/formStateDomain";
import { blur, focus } from "src/utils/rtl";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundCheckboxGroupField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { BoundCheckboxGroupField } from "src/forms";
import { AuthorInput } from "src/forms/formStateDomain";
import { CheckboxGroupItemOption } from "src/inputs";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundChipSelectField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { jest } from "@jest/globals";
import { fireEvent } from "@testing-library/react";
import { BoundChipSelectField } from "src";
import { AuthorInput } from "src/forms/formStateDomain";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundDateField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createObjectState, ObjectConfig, ObjectState } from "@homebound/form-state";
import { jest } from "@jest/globals";
import { act, fireEvent } from "@testing-library/react";
import { BoundDateField } from "src/forms/BoundDateField";
import { AuthorInput, jan1, jan2 } from "src/forms/formStateDomain";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundDateRangeField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState } from "@homebound/form-state";
import { render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { fireEvent } from "@testing-library/react";
import { BoundDateRangeField } from "src/forms/BoundDateRangeField";
import { AuthorInput, jan1, jan19, jan2 } from "src/forms/formStateDomain";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundIconCardField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { jest } from "@jest/globals";
import { click, render } from "src/utils/rtl";
import { BoundIconCardField } from "./BoundIconCardField";
import { AuthorInput } from "./formStateDomain";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundIconCardGroupField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { jest } from "@jest/globals";
import { IconCardGroupItemOption } from "src/inputs/IconCardGroup";
import { click, render } from "src/utils/rtl";
import { BoundIconCardGroupField } from "./BoundIconCardGroupField";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundMultiLineSelectField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { AuthorInput } from "src/forms/formStateDomain";
import { click } from "src/utils/rtl";
import { BoundMultiLineSelectField } from "./BoundMultiLineSelectField";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundMultiSelectField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { BoundMultiSelectField } from "src/forms/BoundMultiSelectField";
import { AuthorInput } from "src/forms/formStateDomain";
import { blur, click, focus } from "src/utils/rtl";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundNumberField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { act, fireEvent } from "@testing-library/react";
import { Observer } from "mobx-react";
import { BoundNumberField } from "src/forms/BoundNumberField";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundRadioGroupField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { BoundRadioGroupField } from "src/forms/BoundRadioGroupField";
import { AuthorInput } from "src/forms/formStateDomain";
import { blur, click, focus } from "src/utils/rtl";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundSelectAndTextField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createObjectState, ObjectConfig, required, useFormState } from "@homebound/form-state";
import { jest } from "@jest/globals";
import { fireEvent } from "@testing-library/react";
import { Observer } from "mobx-react";
import { BoundSelectAndTextField } from "src";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundSelectField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { click, render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { BoundSelectField } from "src/forms/BoundSelectField";
import { AuthorHeight, AuthorInput } from "src/forms/formStateDomain";
import { noop } from "src/utils";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundSwitchField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { click, render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { BoundSwitchField } from "src/forms";
import { AuthorInput } from "src/forms/formStateDomain";

Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundTextAreaField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { fireEvent } from "@testing-library/react";
import { BoundTextAreaField } from "src/forms/BoundTextAreaField";
import { AuthorInput } from "src/forms/formStateDomain";
Expand Down
1 change: 1 addition & 0 deletions src/forms/BoundTextField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createObjectState, ObjectConfig, ObjectState, required } from "@homebound/form-state";
import { render } from "@homebound/rtl-utils";
import { jest } from "@jest/globals";
import { fireEvent } from "@testing-library/react";
import { BoundTextField } from "src/forms/BoundTextField";
import { AuthorInput } from "src/forms/formStateDomain";
Expand Down
Loading