From 373ab4329692820d6cb6760c88a21b0222708cc9 Mon Sep 17 00:00:00 2001 From: Ubeyt Demir Date: Tue, 28 Feb 2023 22:14:02 +0700 Subject: [PATCH] fix(sandpack-tests): introduce `hideTestsAndSupressLogs` prop (#775) Closes https://github.com/codesandbox/sandpack/issues/768 --- .../src/components/Tests/Header.tsx | 48 ++++++++++------- .../src/components/Tests/SandpackTests.tsx | 15 ++++++ sandpack-react/src/components/Tests/Specs.tsx | 54 +++++++++++-------- .../src/components/Tests/Tests.stories.tsx | 29 ++++++++++ .../src/contexts/sandpackContext.tsx | 1 - sandpack-react/src/types.ts | 2 - .../src/pages/advanced-usage/components.mdx | 32 ++++++++++- 7 files changed, 137 insertions(+), 44 deletions(-) diff --git a/sandpack-react/src/components/Tests/Header.tsx b/sandpack-react/src/components/Tests/Header.tsx index 1a93fea49..33d41c523 100644 --- a/sandpack-react/src/components/Tests/Header.tsx +++ b/sandpack-react/src/components/Tests/Header.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import { css } from "../../styles"; -import { roundedButtonClassName, buttonClassName } from "../../styles/shared"; +import { buttonClassName, roundedButtonClassName } from "../../styles/shared"; import { classNames } from "../../utils/classNames"; import { ConsoleIcon } from "../icons"; @@ -34,6 +34,9 @@ interface Props { watchMode: boolean; setWatchMode: () => void; showSuitesOnly: boolean; + showVerboseButton: boolean; + showWatchButton: boolean; + hideTestsAndSupressLogs: boolean; } const buttonsClassName = classNames( @@ -51,6 +54,9 @@ export const Header: React.FC = ({ watchMode, setWatchMode, showSuitesOnly, + showWatchButton, + showVerboseButton, + hideTestsAndSupressLogs, }) => { return (
@@ -87,24 +93,28 @@ export const Header: React.FC = ({ Suite only )} - - + {showVerboseButton && ( + + )} + {showWatchButton && ( + + )}
); diff --git a/sandpack-react/src/components/Tests/SandpackTests.tsx b/sandpack-react/src/components/Tests/SandpackTests.tsx index 51978b476..3812847d4 100644 --- a/sandpack-react/src/components/Tests/SandpackTests.tsx +++ b/sandpack-react/src/components/Tests/SandpackTests.tsx @@ -58,6 +58,14 @@ export const SandpackTests: React.FC< watchMode?: boolean; onComplete?: (specs: Record) => void; actionsChildren?: JSX.Element; + showVerboseButton?: boolean; + showWatchButton?: boolean; + /** + * Hide the tests and supress logs + * If `true` the tests will be hidden and the logs will be supressed. This is useful when you want to run tests in the background and don't want to show the tests to the user. + * @default false + */ + hideTestsAndSupressLogs?: boolean; } & React.HtmlHTMLAttributes > = ({ verbose = false, @@ -66,6 +74,9 @@ export const SandpackTests: React.FC< className, onComplete, actionsChildren, + showVerboseButton = true, + showWatchButton = true, + hideTestsAndSupressLogs = false, ...props }) => { const theme = useSandpackTheme(); @@ -379,6 +390,7 @@ export const SandpackTests: React.FC<