From 9eed5ac4f3fa26b15c469cf6b6a0df15f6779f30 Mon Sep 17 00:00:00 2001 From: TheSisb Date: Fri, 26 Jan 2024 13:58:36 -0600 Subject: [PATCH 1/6] fix: jest memory leaking --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f7e25a5c20..1450ef8cb7 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "clean:full": "tsx ./tools/build/clean-repo.ts && yarn nx run-many --target=clean && rm -rf node_modules/ && yarn", "clean:core": "yarn workspace @twilio-paste/core clean", "pre-test": "tsx ./tools/build/pre-test.ts", - "test": "jest", - "test:coverage": "jest --coverage", + "test": "node --expose-gc --no-compilation-cache ./node_modules/.bin/jest --logHeapUsage", + "test:coverage": "node --expose-gc --no-compilation-cache ./node_modules/.bin/jest --logHeapUsage --coverage", "test:website": "yarn cypress run --record", "test:website-percy": "percy exec -- yarn cypress run --record", "test:website-gui": "WAIT_ON_TIMEOUT=600000 start-server-and-test 'yarn start:website' http://localhost:3000 'yarn cypress open'", From b159069e041f669b6b1c7b99d21a814b98260725 Mon Sep 17 00:00:00 2001 From: TheSisb Date: Fri, 26 Jan 2024 16:02:42 -0600 Subject: [PATCH 2/6] test: fix summary detail tests --- .../components/summary-detail/src/SummaryDetail.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/paste-core/components/summary-detail/src/SummaryDetail.tsx b/packages/paste-core/components/summary-detail/src/SummaryDetail.tsx index 215ecdb736..ff93f9dd4e 100644 --- a/packages/paste-core/components/summary-detail/src/SummaryDetail.tsx +++ b/packages/paste-core/components/summary-detail/src/SummaryDetail.tsx @@ -5,6 +5,7 @@ import { type DisclosurePrimitveStateReturn, useDisclosurePrimitiveState, } from "@twilio-paste/disclosure-primitive"; +import { useUID } from "@twilio-paste/uid-library"; import * as React from "react"; import { SummaryDetailContext } from "./SummaryDetailContext"; @@ -34,10 +35,11 @@ export interface SummaryDetailProps extends DisclosurePrimitiveInitialState { export const SummaryDetail = React.forwardRef( ({ children, element = "SUMMARY_DETAIL", state, ...props }, ref) => { + const headerId = useUID(); const stateForContext = state || useDisclosurePrimitiveState(props); return ( - + Date: Fri, 26 Jan 2024 16:10:10 -0600 Subject: [PATCH 3/6] test: simplify tests --- .../summary-detail/__tests__/index.spec.tsx | 41 +++++++------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/packages/paste-core/components/summary-detail/__tests__/index.spec.tsx b/packages/paste-core/components/summary-detail/__tests__/index.spec.tsx index 30b3cc7fb7..c39854fc48 100644 --- a/packages/paste-core/components/summary-detail/__tests__/index.spec.tsx +++ b/packages/paste-core/components/summary-detail/__tests__/index.spec.tsx @@ -1,7 +1,6 @@ import { render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { CustomizationProvider } from "@twilio-paste/customization"; -import { Theme } from "@twilio-paste/theme"; import * as React from "react"; import { @@ -18,17 +17,15 @@ const MockSummaryDetail: React.FC<{ visible?: SummaryDetailProps["visible"]; }> = ({ visible }) => { return ( - - - - - - Inbound Call - - - Agent: John Doe - - + + + + + Inbound Call + + + Agent: John Doe + ); }; @@ -72,7 +69,7 @@ const MockCustomElementSummaryDetail = (): JSX.Element => { const StateHookMock = (): JSX.Element => { const summaryDetail = useSummaryDetailState(); return ( - + <>