Skip to content

Commit 0bfe0d6

Browse files
jaaydenhParkreiner
andauthored
feat: add tests for dynamic parameters (#18679)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for a new testing attribute to the multi-select combobox component, improving testability. * Expanded mock data for dynamic parameters, covering a wider range of input types and validation scenarios. * **Bug Fixes** * Improved loader and error handling on the experimental workspace creation page to better display WebSocket errors. * **Tests** * Introduced comprehensive tests for the experimental workspace creation page, including dynamic parameter updates, error handling, and form submission scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Michael Smith <throwawayclover@gmail.com>
1 parent b8c9192 commit 0bfe0d6

File tree

6 files changed

+803
-12
lines changed

6 files changed

+803
-12
lines changed

site/src/components/Combobox/Combobox.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface ComboboxProps {
3434
onInputChange?: (value: string) => void;
3535
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
3636
onSelect: (value: string) => void;
37+
id?: string;
3738
}
3839

3940
type ComboboxOption = {
@@ -53,6 +54,7 @@ export const Combobox: FC<ComboboxProps> = ({
5354
onInputChange,
5455
onKeyDown,
5556
onSelect,
57+
id,
5658
}) => {
5759
const [managedOpen, setManagedOpen] = useState(false);
5860
const [managedInputValue, setManagedInputValue] = useState("");
@@ -78,6 +80,7 @@ export const Combobox: FC<ComboboxProps> = ({
7880
<Popover open={isOpen} onOpenChange={handleOpenChange}>
7981
<PopoverTrigger asChild>
8082
<Button
83+
id={id}
8184
variant="outline"
8285
aria-expanded={isOpen}
8386
className="w-full justify-between group"

site/src/components/MultiSelectCombobox/MultiSelectCombobox.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ interface MultiSelectComboboxProps {
104104
>;
105105
/** hide or show the button that clears all the selected options. */
106106
hideClearAllButton?: boolean;
107+
/** Test ID for testing purposes */
108+
"data-testid"?: string;
107109
}
108110

109111
interface MultiSelectComboboxRef {
@@ -205,6 +207,7 @@ export const MultiSelectCombobox = forwardRef<
205207
commandProps,
206208
inputProps,
207209
hideClearAllButton = false,
210+
"data-testid": dataTestId,
208211
}: MultiSelectComboboxProps,
209212
ref,
210213
) => {
@@ -454,6 +457,7 @@ export const MultiSelectCombobox = forwardRef<
454457
<Command
455458
ref={dropdownRef}
456459
{...commandProps}
460+
data-testid={dataTestId}
457461
onKeyDown={(e) => {
458462
handleKeyDown(e);
459463
commandProps?.onKeyDown?.(e);

site/src/modules/workspaces/DynamicParameter/DynamicParameter.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
453453
case "dropdown": {
454454
return (
455455
<Combobox
456+
id={id}
456457
value={value ?? ""}
457458
onSelect={(value) => onChange(value)}
458459
options={parameter.options.map((option) => ({
@@ -497,7 +498,10 @@ const ParameterField: FC<ParameterFieldProps> = ({
497498

498499
return (
499500
<MultiSelectCombobox
500-
inputProps={{ id }}
501+
inputProps={{
502+
id: id,
503+
}}
504+
data-testid={`multiselect-${parameter.name}`}
501505
options={options}
502506
defaultOptions={selectedOptions}
503507
onChange={(newValues) => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy