Skip to content

Commit

Permalink
fix: massively renamed TestSelector types to be easily understood
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGhadyani-Okta committed Aug 27, 2024
1 parent 4f10bd4 commit b5b4289
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 116 deletions.
12 changes: 6 additions & 6 deletions packages/odyssey-react-mui/src/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
useInputValues,
getControlState,
} from "./inputUtils";
import { FeatureTestSelector } from "./test-selectors";
import { TestSelector } from "./test-selectors";

// This is required to get around a react-types issue for "AutoSizer is not a valid JSX element."
// @see https://github.com/bvaughn/react-virtualized/issues/1739#issuecomment-1291444246
Expand All @@ -59,11 +59,11 @@ export const AutocompleteTestSelectors = {
hint: "description",
label: "label",
},
feature: {
children: {
list: {
feature: {
children: {
listItem: {
selector: {
elementSelector: {
method: "ByRole",
options: {
label: "name",
Expand All @@ -75,14 +75,14 @@ export const AutocompleteTestSelectors = {
isControlledElement: true,
},
},
selector: {
elementSelector: {
method: "ByRole",
options: {
label: "name",
},
role: "combobox",
},
} as const satisfies FeatureTestSelector;
} as const satisfies TestSelector;

export type AutocompleteProps<
OptionType,
Expand Down
10 changes: 5 additions & 5 deletions packages/odyssey-react-mui/src/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
DesignTokens,
useOdysseyDesignTokens,
} from "./OdysseyDesignTokensContext";
import { type FeatureTestSelector } from "./test-selectors";
import { type TestSelector } from "./test-selectors";
import { Paragraph } from "./Typography";
import { useUniqueId } from "./useUniqueId";

Expand All @@ -29,9 +29,9 @@ export const CalloutTestSelectors = {
text: "description",
title: "label",
},
feature: {
children: {
link: {
selector: {
elementSelector: {
method: "ByRole",
options: {
linkText: "name",
Expand All @@ -40,14 +40,14 @@ export const CalloutTestSelectors = {
},
},
},
selector: {
elementSelector: {
method: "ByRole",
options: {
title: "name",
},
role: ["alert", "status"],
},
} as const satisfies FeatureTestSelector;
} as const satisfies TestSelector;

export const calloutRoleValues = ["status", "alert"] as const;
export const calloutSeverityValues = [
Expand Down
12 changes: 6 additions & 6 deletions packages/odyssey-react-mui/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ import {
useOdysseyDesignTokens,
DesignTokens,
} from "./OdysseyDesignTokensContext";
import { FeatureTestSelector } from "./test-selectors";
import { TestSelector } from "./test-selectors";

export const SelectTestSelectors = {
accessibleText: {
errorMessage: "errorMessage",
hint: "description",
label: "label",
},
feature: {
children: {
list: {
feature: {
children: {
listItem: {
selector: {
elementSelector: {
method: "ByRole",
options: {
label: "name",
Expand All @@ -76,14 +76,14 @@ export const SelectTestSelectors = {
isControlledElement: true,
},
},
selector: {
elementSelector: {
method: "ByRole",
options: {
label: "name",
},
role: "combobox",
},
} as const satisfies FeatureTestSelector;
} as const satisfies TestSelector;

export type SelectOption = {
text: string;
Expand Down
10 changes: 5 additions & 5 deletions packages/odyssey-react-mui/src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import { Badge, BadgeProps } from "./Badge";
import { Box } from "./Box";
import { HtmlProps } from "./HtmlProps";
import { useOdysseyDesignTokens } from "./OdysseyDesignTokensContext";
import { type FeatureTestSelector } from "./test-selectors";
import { type TestSelector } from "./test-selectors";

export const TabsTestSelectors = {
feature: {
children: {
tabItem: {
selector: {
elementSelector: {
method: "ByRole",
options: {
label: "name",
Expand All @@ -44,14 +44,14 @@ export const TabsTestSelectors = {
},
},
},
selector: {
elementSelector: {
method: "ByRole",
options: {
label: "name",
},
role: "tablist",
},
} as const satisfies FeatureTestSelector;
} as const satisfies TestSelector;

export type TabItemProps = {
/**
Expand Down
10 changes: 5 additions & 5 deletions packages/odyssey-react-mui/src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ import {
import { Field } from "./Field";
import { HtmlProps } from "./HtmlProps";
import { FocusHandle, useInputValues, getControlState } from "./inputUtils";
import { type FeatureTestSelector } from "./test-selectors";
import { type TestSelector } from "./test-selectors";

export const TextFieldTestSelectors = {
accessibleText: {
errorMessage: "errorMessage",
hint: "description",
label: "label",
},
feature: {
children: {
link: {
selector: {
elementSelector: {
method: "ByRole",
options: {
label: "name",
Expand All @@ -49,14 +49,14 @@ export const TextFieldTestSelectors = {
},
},
},
selector: {
elementSelector: {
method: "ByRole",
options: {
label: "name",
},
role: "textbox",
},
} as const satisfies FeatureTestSelector;
} as const satisfies TestSelector;

export const textFieldTypeValues = [
"email",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import {
computeAccessibleDescription,
} from "dom-accessibility-api";

import { type AccessibleLabelSelectorType } from "./featureTestSelector";
import { type AccessibleTextSelectorValue } from "./testSelector";
import { getComputedAccessibleErrorMessageText } from "./getComputedAccessibleErrorMessageText";

export const accessibleTextSelector = {
description: computeAccessibleDescription,
errorMessage: getComputedAccessibleErrorMessageText,
label: computeAccessibleName,
} as const satisfies Record<
AccessibleLabelSelectorType,
AccessibleTextSelectorValue,
(element: HTMLElement) => string
>;

Expand All @@ -32,5 +32,5 @@ export const getComputedAccessibleText = ({
type,
}: {
element: HTMLElement;
type: AccessibleLabelSelectorType;
type: AccessibleTextSelectorValue;
}) => accessibleTextSelector[type](element);
2 changes: 1 addition & 1 deletion packages/odyssey-react-mui/src/test-selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
* See the License for the specific language governing permissions and limitations under the License.
*/

export * from "./featureTestSelector";
export * from "./queryOdysseySelector";
export * from "./querySelector";
export * from "./testSelector";
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { querySelector } from "./querySelector";
import { type FeatureTestSelector } from "./featureTestSelector";
import { type TestSelector } from "./testSelector";
import { AutocompleteTestSelectors } from "../Autocomplete";
import { CalloutTestSelectors } from "../Callout";
import { SelectTestSelectors } from "../Select";
Expand All @@ -24,7 +24,7 @@ export const odysseyTestSelector = {
Select: SelectTestSelectors,
Tabs: TabsTestSelectors,
TextField: TextFieldTestSelectors,
} as const satisfies Record<string, FeatureTestSelector>;
} as const satisfies Record<string, TestSelector>;

export const queryOdysseySelector = <
ComponentName extends keyof typeof odysseyTestSelector,
Expand Down
Loading

0 comments on commit b5b4289

Please sign in to comment.