From 1488e8ace22674281d31e640989c81187fb1fbb4 Mon Sep 17 00:00:00 2001
From: jmainguytalend <102585684+jmainguytalend@users.noreply.github.com>
Date: Wed, 27 Mar 2024 16:19:27 +0100
Subject: [PATCH] chore(): status comp - add date-test attr (#5244)
---
.changeset/two-dolls-obey.md | 5 +++++
.../Status/Primitive/StatusPrimitive.test.tsx | 18 ++++++++++++++++++
.../Status/Primitive/StatusPrimitive.tsx | 11 +++++++----
.../Status/variations/StatusCanceled.tsx | 1 +
.../Status/variations/StatusFailed.tsx | 1 +
.../Status/variations/StatusInProgress.tsx | 1 +
.../Status/variations/StatusSuccessful.tsx | 1 +
.../Status/variations/StatusWarning.tsx | 1 +
.../src/stories/feedback/Status.stories.tsx | 4 ++--
9 files changed, 37 insertions(+), 6 deletions(-)
create mode 100644 .changeset/two-dolls-obey.md
create mode 100644 packages/design-system/src/components/Status/Primitive/StatusPrimitive.test.tsx
diff --git a/.changeset/two-dolls-obey.md b/.changeset/two-dolls-obey.md
new file mode 100644
index 00000000000..2c42c6cafef
--- /dev/null
+++ b/.changeset/two-dolls-obey.md
@@ -0,0 +1,5 @@
+---
+"@talend/design-system": patch
+---
+
+Status : add data-test\* attributes
diff --git a/packages/design-system/src/components/Status/Primitive/StatusPrimitive.test.tsx b/packages/design-system/src/components/Status/Primitive/StatusPrimitive.test.tsx
new file mode 100644
index 00000000000..2e673b76f70
--- /dev/null
+++ b/packages/design-system/src/components/Status/Primitive/StatusPrimitive.test.tsx
@@ -0,0 +1,18 @@
+/* eslint-disable import/no-extraneous-dependencies */
+import { describe, expect, it } from '@jest/globals';
+import { render, screen } from '@testing-library/react';
+
+import Status from './StatusPrimitive';
+
+describe('Status', () => {
+ it('Should render', async () => {
+ render(
+
+ This is my status
+ ,
+ );
+
+ expect(screen.getByTestId('my-status-component')).toBeInTheDocument();
+ expect(screen.getByText('This is my status')).toBeInTheDocument();
+ });
+});
diff --git a/packages/design-system/src/components/Status/Primitive/StatusPrimitive.tsx b/packages/design-system/src/components/Status/Primitive/StatusPrimitive.tsx
index 60f06c0d18b..7c88b393c3b 100644
--- a/packages/design-system/src/components/Status/Primitive/StatusPrimitive.tsx
+++ b/packages/design-system/src/components/Status/Primitive/StatusPrimitive.tsx
@@ -1,16 +1,19 @@
import { forwardRef } from 'react';
import type { Ref } from 'react';
+
import classnames from 'classnames';
+
// eslint-disable-next-line @talend/import-depth
import { IconNameWithSize } from '@talend/icons/dist/typeUtils';
-import { Tooltip, TooltipChildrenFnProps, TooltipChildrenFnRef } from '../../Tooltip';
-import { Loading } from '../../Loading';
+import { mergeRefs } from '../../../mergeRef';
+import { DataAttributes } from '../../../types';
import { SizedIcon } from '../../Icon';
+import { Loading } from '../../Loading';
import { StackHorizontal } from '../../Stack';
+import { Tooltip, TooltipChildrenFnProps, TooltipChildrenFnRef } from '../../Tooltip';
import styles from './Status.module.scss';
-import { mergeRefs } from '../../../mergeRef';
export const variants = {
successful: 'successful',
@@ -26,7 +29,7 @@ export type StatusProps = {
hideText?: boolean;
children?: string;
variant: keyof typeof variants;
-};
+} & DataAttributes;
const Status = forwardRef(
(
diff --git a/packages/design-system/src/components/Status/variations/StatusCanceled.tsx b/packages/design-system/src/components/Status/variations/StatusCanceled.tsx
index de61541a378..c2986800d9c 100644
--- a/packages/design-system/src/components/Status/variations/StatusCanceled.tsx
+++ b/packages/design-system/src/components/Status/variations/StatusCanceled.tsx
@@ -1,6 +1,7 @@
import { forwardRef } from 'react';
import type { Ref } from 'react';
import { useTranslation } from 'react-i18next';
+
import StatusPrimitive, { StatusProps } from '../Primitive/StatusPrimitive';
export type StatusCanceledProps = Omit;
diff --git a/packages/design-system/src/components/Status/variations/StatusFailed.tsx b/packages/design-system/src/components/Status/variations/StatusFailed.tsx
index 2406fb4ab5d..64c85ea92c4 100644
--- a/packages/design-system/src/components/Status/variations/StatusFailed.tsx
+++ b/packages/design-system/src/components/Status/variations/StatusFailed.tsx
@@ -1,6 +1,7 @@
import { forwardRef } from 'react';
import type { Ref } from 'react';
import { useTranslation } from 'react-i18next';
+
import StatusPrimitive, { StatusProps } from '../Primitive/StatusPrimitive';
export type StatusFailedProps = Omit;
diff --git a/packages/design-system/src/components/Status/variations/StatusInProgress.tsx b/packages/design-system/src/components/Status/variations/StatusInProgress.tsx
index b356347c075..973d1626302 100644
--- a/packages/design-system/src/components/Status/variations/StatusInProgress.tsx
+++ b/packages/design-system/src/components/Status/variations/StatusInProgress.tsx
@@ -1,6 +1,7 @@
import { forwardRef } from 'react';
import type { Ref } from 'react';
import { useTranslation } from 'react-i18next';
+
import StatusPrimitive, { StatusProps } from '../Primitive/StatusPrimitive';
export type StatusInProgressProps = Omit;
diff --git a/packages/design-system/src/components/Status/variations/StatusSuccessful.tsx b/packages/design-system/src/components/Status/variations/StatusSuccessful.tsx
index 8a69814d92f..791f15704de 100644
--- a/packages/design-system/src/components/Status/variations/StatusSuccessful.tsx
+++ b/packages/design-system/src/components/Status/variations/StatusSuccessful.tsx
@@ -1,6 +1,7 @@
import { forwardRef } from 'react';
import type { Ref } from 'react';
import { useTranslation } from 'react-i18next';
+
import StatusPrimitive, { StatusProps } from '../Primitive/StatusPrimitive';
export type StatusSuccessfulProps = Omit;
diff --git a/packages/design-system/src/components/Status/variations/StatusWarning.tsx b/packages/design-system/src/components/Status/variations/StatusWarning.tsx
index bc77dc64cee..4c03c2ad7f5 100644
--- a/packages/design-system/src/components/Status/variations/StatusWarning.tsx
+++ b/packages/design-system/src/components/Status/variations/StatusWarning.tsx
@@ -1,6 +1,7 @@
import { forwardRef } from 'react';
import type { Ref } from 'react';
import { useTranslation } from 'react-i18next';
+
import StatusPrimitive, { StatusProps } from '../Primitive/StatusPrimitive';
export type StatusWarningProps = Omit;
diff --git a/packages/design-system/src/stories/feedback/Status.stories.tsx b/packages/design-system/src/stories/feedback/Status.stories.tsx
index 13edcfc0fdd..795016dde2b 100644
--- a/packages/design-system/src/stories/feedback/Status.stories.tsx
+++ b/packages/design-system/src/stories/feedback/Status.stories.tsx
@@ -1,10 +1,10 @@
import {
- StatusFailed,
+ Status,
StatusCanceled,
+ StatusFailed,
StatusInProgress,
StatusSuccessful,
StatusWarning,
- Status,
} from '../../';
import { variants } from '../../components/Status/Primitive/StatusPrimitive';