Saleor 2078/create cypress test ids (#958)
* Add first id * Add more ids * Add more test ids * Fix typing * Remove unnecessary import * Update snapshots
This commit is contained in:
parent
b894487c63
commit
9a694071ce
11 changed files with 67 additions and 6 deletions
|
@ -20,6 +20,7 @@ import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
import { useStyles } from "../styles";
|
import { useStyles } from "../styles";
|
||||||
|
import { ExtendedFormHelperTextProps } from "./types";
|
||||||
|
|
||||||
export interface FormData {
|
export interface FormData {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -80,6 +81,11 @@ export const ChannelForm: React.FC<ChannelFormProps> = ({
|
||||||
helperText={getChannelsErrorMessage(formErrors?.slug, intl)}
|
helperText={getChannelsErrorMessage(formErrors?.slug, intl)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
fullWidth
|
fullWidth
|
||||||
|
FormHelperTextProps={
|
||||||
|
{
|
||||||
|
"data-testid": "slug-text-input-helper-text"
|
||||||
|
} as ExtendedFormHelperTextProps
|
||||||
|
}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
defaultMessage: "Slug",
|
defaultMessage: "Slug",
|
||||||
description: "channel slug"
|
description: "channel slug"
|
||||||
|
@ -124,8 +130,14 @@ export const ChannelForm: React.FC<ChannelFormProps> = ({
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{!!currencyCodes ? (
|
{!!currencyCodes ? (
|
||||||
<SingleAutocompleteSelectField
|
<SingleAutocompleteSelectField
|
||||||
|
data-test-id="channel-currency-select-input"
|
||||||
allowCustomValues
|
allowCustomValues
|
||||||
error={!!formErrors.currencyCode}
|
error={!!formErrors.currencyCode}
|
||||||
|
FormHelperTextProps={
|
||||||
|
{
|
||||||
|
"data-testid": "currency-text-input-helper-text"
|
||||||
|
} as ExtendedFormHelperTextProps
|
||||||
|
}
|
||||||
helperText={getChannelsErrorMessage(
|
helperText={getChannelsErrorMessage(
|
||||||
formErrors?.currencyCode,
|
formErrors?.currencyCode,
|
||||||
intl
|
intl
|
||||||
|
|
5
src/channels/components/ChannelForm/types.ts
Normal file
5
src/channels/components/ChannelForm/types.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import { FormHelperTextProps } from "@material-ui/core/FormHelperText";
|
||||||
|
|
||||||
|
export type ExtendedFormHelperTextProps = FormHelperTextProps & {
|
||||||
|
"data-testid": string;
|
||||||
|
};
|
|
@ -61,7 +61,11 @@ const AppHeader: React.FC<AppHeaderProps> = props => {
|
||||||
{anchor =>
|
{anchor =>
|
||||||
anchor ? (
|
anchor ? (
|
||||||
<Portal container={anchor.current}>
|
<Portal container={anchor.current}>
|
||||||
<div className={classes.root} onClick={onBack}>
|
<div
|
||||||
|
className={classes.root}
|
||||||
|
onClick={onBack}
|
||||||
|
data-test-id="app-header-back-button"
|
||||||
|
>
|
||||||
<ArrowBackIcon className={classes.backArrow} />
|
<ArrowBackIcon className={classes.backArrow} />
|
||||||
{children ? (
|
{children ? (
|
||||||
<Typography className={classes.title}>{children}</Typography>
|
<Typography className={classes.title}>{children}</Typography>
|
||||||
|
|
|
@ -38,6 +38,7 @@ const AppChannelSelect: React.FC<AppChannelSelectProps> = ({
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<SingleSelectField
|
<SingleSelectField
|
||||||
|
testId="app-channel-select"
|
||||||
choices={mapNodeToChoice(channels)}
|
choices={mapNodeToChoice(channels)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={selectedChannelId}
|
value={selectedChannelId}
|
||||||
|
|
|
@ -417,7 +417,11 @@ export const ChannelsAvailability: React.FC<ChannelsAvailabilityProps> = props =
|
||||||
userPermissions={user?.userPermissions || []}
|
userPermissions={user?.userPermissions || []}
|
||||||
requiredPermissions={[PermissionEnum.MANAGE_CHANNELS]}
|
requiredPermissions={[PermissionEnum.MANAGE_CHANNELS]}
|
||||||
>
|
>
|
||||||
<Button color="primary" onClick={openModal}>
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onClick={openModal}
|
||||||
|
data-test-id="channels-availiability-manage-button"
|
||||||
|
>
|
||||||
{intl.formatMessage({
|
{intl.formatMessage({
|
||||||
defaultMessage: "Manage",
|
defaultMessage: "Manage",
|
||||||
description: "section header button"
|
description: "section header button"
|
||||||
|
|
|
@ -77,7 +77,10 @@ export const ChannelsAvailabilityContent: React.FC<ChannelsAvailabilityContentPr
|
||||||
<Typography className={classes.contentTitle}>
|
<Typography className={classes.contentTitle}>
|
||||||
<FormattedMessage defaultMessage="Channels A to Z" />
|
<FormattedMessage defaultMessage="Channels A to Z" />
|
||||||
</Typography>
|
</Typography>
|
||||||
<div className={classes.scrollArea}>
|
<div
|
||||||
|
className={classes.scrollArea}
|
||||||
|
data-test-id="manage-products-channels-availiability-list"
|
||||||
|
>
|
||||||
{filteredChannels?.length ? (
|
{filteredChannels?.length ? (
|
||||||
filteredChannels.map(option => (
|
filteredChannels.map(option => (
|
||||||
<div key={option.id} className={classes.option}>
|
<div key={option.id} className={classes.option}>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { InputProps } from "@material-ui/core/Input";
|
import { InputProps } from "@material-ui/core/Input";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import TextField from "@material-ui/core/TextField";
|
import TextField from "@material-ui/core/TextField";
|
||||||
|
import { ExtendedFormHelperTextProps } from "@saleor/channels/components/ChannelForm/types";
|
||||||
import { FetchMoreProps } from "@saleor/types";
|
import { FetchMoreProps } from "@saleor/types";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import Downshift, { ControllerStateAndHelpers } from "downshift";
|
import Downshift, { ControllerStateAndHelpers } from "downshift";
|
||||||
|
@ -42,6 +43,7 @@ export interface SingleAutocompleteSelectFieldProps
|
||||||
InputProps?: InputProps;
|
InputProps?: InputProps;
|
||||||
fetchChoices?: (value: string) => void;
|
fetchChoices?: (value: string) => void;
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
|
FormHelperTextProps?: ExtendedFormHelperTextProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DebounceAutocomplete: React.ComponentType<DebounceProps<
|
const DebounceAutocomplete: React.ComponentType<DebounceProps<
|
||||||
|
@ -69,6 +71,7 @@ const SingleAutocompleteSelectFieldComponent: React.FC<SingleAutocompleteSelectF
|
||||||
fetchChoices,
|
fetchChoices,
|
||||||
onChange,
|
onChange,
|
||||||
onFetchMore,
|
onFetchMore,
|
||||||
|
FormHelperTextProps,
|
||||||
...rest
|
...rest
|
||||||
} = props;
|
} = props;
|
||||||
const classes = useStyles(props);
|
const classes = useStyles(props);
|
||||||
|
@ -178,6 +181,7 @@ const SingleAutocompleteSelectFieldComponent: React.FC<SingleAutocompleteSelectF
|
||||||
error={error}
|
error={error}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
helperText={helperText}
|
helperText={helperText}
|
||||||
|
FormHelperTextProps={FormHelperTextProps}
|
||||||
label={label}
|
label={label}
|
||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -35,6 +35,7 @@ export interface Choice {
|
||||||
|
|
||||||
export type Choices = Choice[];
|
export type Choices = Choice[];
|
||||||
interface SingleSelectFieldProps {
|
interface SingleSelectFieldProps {
|
||||||
|
testId?: string;
|
||||||
choices: Choices;
|
choices: Choices;
|
||||||
className?: string;
|
className?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
@ -62,7 +63,8 @@ export const SingleSelectField: React.FC<SingleSelectFieldProps> = props => {
|
||||||
hint,
|
hint,
|
||||||
selectProps,
|
selectProps,
|
||||||
placeholder,
|
placeholder,
|
||||||
InputProps
|
InputProps,
|
||||||
|
testId
|
||||||
} = props;
|
} = props;
|
||||||
const classes = useStyles(props);
|
const classes = useStyles(props);
|
||||||
|
|
||||||
|
@ -84,6 +86,7 @@ export const SingleSelectField: React.FC<SingleSelectFieldProps> = props => {
|
||||||
{label}
|
{label}
|
||||||
</InputLabel>
|
</InputLabel>
|
||||||
<Select
|
<Select
|
||||||
|
data-test-id={testId}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
renderValue={choiceValue =>
|
renderValue={choiceValue =>
|
||||||
|
|
|
@ -44,7 +44,12 @@ const OrderDraftDetails: React.FC<OrderDraftDetailsProps> = ({
|
||||||
toolbar={
|
toolbar={
|
||||||
!disabled &&
|
!disabled &&
|
||||||
order?.channel?.isActive && (
|
order?.channel?.isActive && (
|
||||||
<Button color="primary" variant="text" onClick={onOrderLineAdd}>
|
<Button
|
||||||
|
color="primary"
|
||||||
|
variant="text"
|
||||||
|
onClick={onOrderLineAdd}
|
||||||
|
data-test-id="add-products-button"
|
||||||
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Add products"
|
defaultMessage="Add products"
|
||||||
description="button"
|
description="button"
|
||||||
|
|
|
@ -72,7 +72,12 @@ const OrderListPage: React.FC<OrderListPageProps> = ({
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Button color="primary" variant="contained" onClick={onAdd}>
|
<Button
|
||||||
|
color="primary"
|
||||||
|
variant="contained"
|
||||||
|
onClick={onAdd}
|
||||||
|
data-test-id="create-order-button"
|
||||||
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Create order"
|
defaultMessage="Create order"
|
||||||
description="button"
|
description="button"
|
||||||
|
|
|
@ -2688,6 +2688,7 @@ exports[`Storyshots Generics / ChannelsAvailability default 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="channels-availiability-manage-button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -2773,6 +2774,7 @@ exports[`Storyshots Generics / ChannelsAvailability with onChange 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="channels-availiability-manage-button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -46366,6 +46368,7 @@ exports[`Storyshots Views / Channels / Channel details default 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="SingleAutocompleteSelectField-container-id"
|
class="SingleAutocompleteSelectField-container-id"
|
||||||
|
data-test-id="channel-currency-select-input"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||||
|
@ -46627,6 +46630,7 @@ exports[`Storyshots Views / Channels / Channel details disabled 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="SingleAutocompleteSelectField-container-id"
|
class="SingleAutocompleteSelectField-container-id"
|
||||||
|
data-test-id="channel-currency-select-input"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||||
|
@ -46887,6 +46891,7 @@ exports[`Storyshots Views / Channels / Channel details loading 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="SingleAutocompleteSelectField-container-id"
|
class="SingleAutocompleteSelectField-container-id"
|
||||||
|
data-test-id="channel-currency-select-input"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||||
|
@ -47146,6 +47151,7 @@ exports[`Storyshots Views / Channels / Channel details with data 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="SingleAutocompleteSelectField-container-id"
|
class="SingleAutocompleteSelectField-container-id"
|
||||||
|
data-test-id="channel-currency-select-input"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||||
|
@ -47372,6 +47378,7 @@ exports[`Storyshots Views / Channels / Channel details with errors 1`] = `
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
class="MuiFormHelperText-root-id MuiFormHelperText-contained-id MuiFormHelperText-error-id"
|
class="MuiFormHelperText-root-id MuiFormHelperText-contained-id MuiFormHelperText-error-id"
|
||||||
|
data-testid="slug-text-input-helper-text"
|
||||||
>
|
>
|
||||||
Slug must be unique
|
Slug must be unique
|
||||||
</p>
|
</p>
|
||||||
|
@ -47410,6 +47417,7 @@ exports[`Storyshots Views / Channels / Channel details with errors 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="SingleAutocompleteSelectField-container-id"
|
class="SingleAutocompleteSelectField-container-id"
|
||||||
|
data-test-id="channel-currency-select-input"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||||
|
@ -48149,6 +48157,7 @@ exports[`Storyshots Views / Channels / Channel form with errors 1`] = `
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
class="MuiFormHelperText-root-id MuiFormHelperText-contained-id MuiFormHelperText-error-id MuiFormHelperText-filled-id"
|
class="MuiFormHelperText-root-id MuiFormHelperText-contained-id MuiFormHelperText-error-id MuiFormHelperText-filled-id"
|
||||||
|
data-testid="slug-text-input-helper-text"
|
||||||
>
|
>
|
||||||
Slug must be unique
|
Slug must be unique
|
||||||
</p>
|
</p>
|
||||||
|
@ -125137,6 +125146,7 @@ exports[`Storyshots Views / Orders / Order draft default 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="add-products-button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -126212,6 +126222,7 @@ exports[`Storyshots Views / Orders / Order draft no user permissions 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="add-products-button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -126855,6 +126866,7 @@ exports[`Storyshots Views / Orders / Order draft without lines 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="add-products-button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -127191,6 +127203,7 @@ exports[`Storyshots Views / Orders / Order list default 1`] = `
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||||
|
data-test-id="create-order-button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -128539,6 +128552,7 @@ exports[`Storyshots Views / Orders / Order list loading 1`] = `
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||||
|
data-test-id="create-order-button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -128997,6 +129011,7 @@ exports[`Storyshots Views / Orders / Order list when no data 1`] = `
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||||
|
data-test-id="create-order-button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue