diff --git a/packages/components/accordion/src/accordion.ts b/packages/components/accordion/src/accordion.ts index 7ef6ac2f..bf71a2b1 100644 --- a/packages/components/accordion/src/accordion.ts +++ b/packages/components/accordion/src/accordion.ts @@ -7,46 +7,31 @@ export const accordionProps = buildProps({ type: String, required: true, }, - buttonDataTest: { - type: String, - required: false, - default: undefined, - }, title: { type: String, required: false, default: undefined, }, - titleDataTest: { - type: String, - required: false, - default: undefined, - }, subTitle: { type: String, required: false, default: undefined, }, - subTitleDataTest: { - type: String, - required: false, - default: undefined, - }, icon: { type: String, required: false, default: undefined, }, - iconDataTest: { - type: String, - required: false, - default: undefined, - }, disabled: { type: Boolean, required: false, default: false, }, + dataTest: { + type: String, + required: false, + default: undefined, + }, } as const) export const accordionEmits = ['click'] diff --git a/packages/components/accordion/src/accordion.vue b/packages/components/accordion/src/accordion.vue index 6657a4ad..e3d1bdf4 100644 --- a/packages/components/accordion/src/accordion.vue +++ b/packages/components/accordion/src/accordion.vue @@ -11,7 +11,7 @@ :aria-controls="id" class="puik-accordion__header" :disabled="disabled" - :data-test="buttonDataTest" + :data-test="`button-${dataTest}`" @click="onClick" >
{{ title }}
{{ subTitle }}
diff --git a/packages/components/accordion/stories/accordion.stories.ts b/packages/components/accordion/stories/accordion.stories.ts index 8d2a0d96..d9160e08 100644 --- a/packages/components/accordion/stories/accordion.stories.ts +++ b/packages/components/accordion/stories/accordion.stories.ts @@ -15,26 +15,14 @@ export default { control: 'text', description: 'Title displayed in the header', }, - titleDataTest: { - control: 'text', - description: 'Set the data-test attribute for the title', - }, subTitle: { control: 'text', description: 'Sub title displayed in the header', }, - subTitleDataTest: { - control: 'text', - description: 'Set the data-test attribute for the sub title', - }, icon: { control: 'text', description: 'Icon used in the header', }, - iconDataTest: { - control: 'text', - description: 'Set the data-test attribute for the icon', - }, disabled: { control: 'boolean', description: 'Set accordion disabled', @@ -48,6 +36,11 @@ export default { control: 'none', description: 'Accordion content', }, + dataTest: { + control: 'text', + description: + 'Set the data-test attribute for the accordion `button-${dataTest}` `title-${dataTest}` `icon-${dataTest}` `subTitle-${dataTest}`', + }, }, } as Meta @@ -78,9 +71,6 @@ export const Default = { subTitle: 'Accordion subtitle', icon: 'home', disabled: false, - titleDataTest: '', - subTitleDataTest: '', - iconDataTest: '', }, parameters: { diff --git a/packages/components/alert/src/alert.ts b/packages/components/alert/src/alert.ts index d81c172e..2ebcab79 100644 --- a/packages/components/alert/src/alert.ts +++ b/packages/components/alert/src/alert.ts @@ -19,21 +19,11 @@ export const alertProps = buildProps({ required: false, default: undefined, }, - titleDataTest: { - type: String, - required: false, - default: undefined, - }, description: { type: String, required: false, default: undefined, }, - descriptionDataTest: { - type: String, - required: false, - default: undefined, - }, variant: { type: String as PropType, default: 'success', @@ -47,16 +37,16 @@ export const alertProps = buildProps({ required: false, default: undefined, }, - buttonDataTest: { - type: String, - required: false, - default: undefined, - }, ariaLive: { type: String as PropType<'polite' | 'assertive'>, required: false, default: 'polite', }, + alertDataTest: { + type: String, + required: false, + default: undefined, + }, } as const) export type AlertProps = ExtractPropTypes diff --git a/packages/components/alert/src/alert.vue b/packages/components/alert/src/alert.vue index 5e842072..bd9bb409 100644 --- a/packages/components/alert/src/alert.vue +++ b/packages/components/alert/src/alert.vue @@ -10,13 +10,17 @@
-

+

{{ title }}

{{ description }}
@@ -25,7 +29,7 @@ v-if="buttonLabel" :variant="variant" class="puik-alert__button" - :button-data-test="buttonDataTest" + :button-data-test="`button-${alertDataTest}`" @click="click" > {{ buttonLabel }} diff --git a/packages/components/alert/stories/alert.stories.ts b/packages/components/alert/stories/alert.stories.ts index d0e349e7..a8be4a9e 100644 --- a/packages/components/alert/stories/alert.stories.ts +++ b/packages/components/alert/stories/alert.stories.ts @@ -44,14 +44,10 @@ export default { control: 'none', description: 'Set the alert description', }, - titleDataTest: { - description: 'Set the data-test attribute for the title', - }, - descriptionDataTest: { - description: 'Set the data-test attribute for the description', - }, - buttonDataTest: { - description: 'Set the data-test attribute for the button', + alertDataTest: { + control: 'text', + description: + 'Set the data-test attribute for the alert components `title-${alertDataTest}` `description-${alertDataTest}` `button-${alertDataTest}`', }, }, args: { @@ -60,9 +56,6 @@ export default { variant: 'success', disableBorders: false, buttonLabel: 'Button', - titleDataTest: '', - descriptionDataTest: '', - buttonDataTest: '', }, } as Meta diff --git a/packages/components/badge/src/badge.ts b/packages/components/badge/src/badge.ts index 26d6e333..bc2790e2 100644 --- a/packages/components/badge/src/badge.ts +++ b/packages/components/badge/src/badge.ts @@ -17,7 +17,7 @@ export const badgeProps = buildProps({ type: String as PropType, default: 'neutral', }, - badgeDataTest: { + dataTest: { type: String, required: false, default: undefined, diff --git a/packages/components/badge/src/badge.vue b/packages/components/badge/src/badge.vue index 888fde3f..692c7269 100644 --- a/packages/components/badge/src/badge.vue +++ b/packages/components/badge/src/badge.vue @@ -2,7 +2,7 @@
diff --git a/packages/components/badge/stories/badge.stories.ts b/packages/components/badge/stories/badge.stories.ts index b9c06ad5..e77a28e4 100644 --- a/packages/components/badge/stories/badge.stories.ts +++ b/packages/components/badge/stories/badge.stories.ts @@ -25,7 +25,7 @@ export default { }, }, }, - badgeDataTest: { + dataTest: { control: 'text', description: 'Set the data-test attribute on the badge', }, @@ -33,7 +33,6 @@ export default { args: { default: 'Status', variant: 'neutral', - badgeDataTest: '', }, } as Meta diff --git a/packages/components/button/src/button.ts b/packages/components/button/src/button.ts index 9c8a2fdf..a6885676 100644 --- a/packages/components/button/src/button.ts +++ b/packages/components/button/src/button.ts @@ -48,21 +48,11 @@ export const buttonProps = buildProps({ required: false, default: '', }, - leftIconDataTest: { - type: String, - required: false, - default: undefined, - }, rightIcon: { type: String, required: false, default: '', }, - rightIconDataTest: { - type: String, - required: false, - default: undefined, - }, to: { type: [Object, String] as PropType, required: false, @@ -78,7 +68,7 @@ export const buttonProps = buildProps({ required: false, default: undefined, }, - buttonDataTest: { + dataTest: { type: String, required: false, default: undefined, diff --git a/packages/components/button/src/button.vue b/packages/components/button/src/button.vue index 828b9afc..745abac1 100644 --- a/packages/components/button/src/button.vue +++ b/packages/components/button/src/button.vue @@ -10,7 +10,7 @@ { 'puik-button--fluid': fluid }, ]" :disabled="disabled" - :data-test="buttonDataTest" + :data-test="`button-${dataTest}`" @click="setSelected" > diff --git a/packages/components/button/stories/button.stories.ts b/packages/components/button/stories/button.stories.ts index 401d5efe..33217b57 100644 --- a/packages/components/button/stories/button.stories.ts +++ b/packages/components/button/stories/button.stories.ts @@ -71,17 +71,10 @@ export default { control: 'text', description: 'Set a link for the button (changes button to "a" html tag)', }, - buttonDataTest: { + dataTest: { control: 'text', - description: 'Set a data-test attribute to the button', - }, - leftIconDataTest: { - control: 'text', - description: 'Set a data-test attribute to the left icon', - }, - rightIconDataTest: { - control: 'text', - description: 'Set a data-test attribute to the right icon', + description: + 'Set a data-test attribute to the button `button-${dataTest}` `left-icon-${dataTest}` `right-icon-${dataTest}`', }, }, args: { @@ -94,9 +87,6 @@ export default { to: undefined, href: undefined, default: 'Add to cart', - buttonDataTest: '', - leftIconDataTest: '', - rightIconDataTest: '', }, } as Meta diff --git a/packages/components/checkbox/src/checkbox.ts b/packages/components/checkbox/src/checkbox.ts index e63526ca..b47f0491 100644 --- a/packages/components/checkbox/src/checkbox.ts +++ b/packages/components/checkbox/src/checkbox.ts @@ -12,11 +12,6 @@ export const checkboxProps = buildProps({ required: false, default: undefined, }, - labelDataTest: { - type: String, - required: false, - default: undefined, - }, disabled: { type: Boolean, required: false, @@ -27,7 +22,7 @@ export const checkboxProps = buildProps({ required: false, default: false, }, - inputDataTest: { + dataTest: { type: String, required: false, default: undefined, diff --git a/packages/components/checkbox/src/checkbox.vue b/packages/components/checkbox/src/checkbox.vue index e91fd61a..e641dd6c 100644 --- a/packages/components/checkbox/src/checkbox.vue +++ b/packages/components/checkbox/src/checkbox.vue @@ -8,13 +8,13 @@ type="checkbox" :indeterminate="indeterminate" :disabled="disabled" - :data-test="inputDataTest" + :data-test="`input-${dataTest}`" /> diff --git a/packages/components/checkbox/stories/checkbox.stories.ts b/packages/components/checkbox/stories/checkbox.stories.ts index 636a2f7d..877b20ee 100644 --- a/packages/components/checkbox/stories/checkbox.stories.ts +++ b/packages/components/checkbox/stories/checkbox.stories.ts @@ -33,11 +33,9 @@ export default { }, }, }, - inputDataTest: { - description: 'Set the input data-test attribute', - }, - labelDataTest: { - description: 'Set the label data-test attribute', + dataTest: { + description: + 'Set the data-test attribute for the label and the input `label-${dataTest}` `input-${dataTest}`}`', }, }, args: { @@ -46,8 +44,6 @@ export default { indeterminate: false, disabled: false, modelValue: false, - inputDataTest: '', - labelDataTest: '', }, } as Meta diff --git a/packages/components/input/src/input.ts b/packages/components/input/src/input.ts index 812a81b7..a921ae82 100644 --- a/packages/components/input/src/input.ts +++ b/packages/components/input/src/input.ts @@ -90,12 +90,7 @@ export const inputProps = buildProps({ required: false, default: false, }, - inputDataTest: { - type: String, - required: false, - default: undefined, - }, - errorTextDataTest: { + dataTest: { type: String, required: false, default: undefined, diff --git a/packages/components/input/src/input.vue b/packages/components/input/src/input.vue index bbb031ce..d5b709e0 100644 --- a/packages/components/input/src/input.vue +++ b/packages/components/input/src/input.vue @@ -17,7 +17,7 @@ :min="type === 'number' ? min : undefined" :max="type === 'number' ? max : undefined" :step="type === 'number' ? step : undefined" - :data-test="inputDataTest" + :data-test="`input-${dataTest}`" @focus="handleFocus" @blur="handleBlur" /> @@ -52,7 +52,7 @@ > {{ error }} diff --git a/packages/components/input/stories/input.stories.ts b/packages/components/input/stories/input.stories.ts index 6e7bad25..95ee4e43 100644 --- a/packages/components/input/stories/input.stories.ts +++ b/packages/components/input/stories/input.stories.ts @@ -93,11 +93,9 @@ export default { control: 'none', description: 'Append an icon or text to the input', }, - inputDataTest: { - description: 'Set the data-test attribute on the input element', - }, - errorTextDataTest: { - description: 'Set the data-test attribute on the error slot', + dataTest: { + description: + 'Set the data-test attribute on the input and error text elements `input-${inputDataTest}` `error-${inputDataTest}`', }, }, } as Meta @@ -130,8 +128,6 @@ export const Default = { min: undefined, max: undefined, disabled: false, - inputDataTest: '', - errorTextDataTest: '', }, parameters: { diff --git a/packages/components/menu/src/menu-item-title.ts b/packages/components/menu/src/menu-item-title.ts index e64742ce..139d95d4 100644 --- a/packages/components/menu/src/menu-item-title.ts +++ b/packages/components/menu/src/menu-item-title.ts @@ -3,7 +3,7 @@ import type { ExtractPropTypes } from 'vue' import type MenuItemTitle from './menu-item-title.vue' export const menuItemTitleProps = buildProps({ - titleDataTest: { + dataTest: { type: String, required: false, default: undefined, diff --git a/packages/components/menu/src/menu-item-title.vue b/packages/components/menu/src/menu-item-title.vue index dcd7a9f4..695ac726 100644 --- a/packages/components/menu/src/menu-item-title.vue +++ b/packages/components/menu/src/menu-item-title.vue @@ -1,5 +1,5 @@ diff --git a/packages/components/menu/stories/menu-item-title.stories.ts b/packages/components/menu/stories/menu-item-title.stories.ts index de39c6f8..c519c2f6 100644 --- a/packages/components/menu/stories/menu-item-title.stories.ts +++ b/packages/components/menu/stories/menu-item-title.stories.ts @@ -9,8 +9,8 @@ export default { control: 'text', description: 'Default slot to set title text', }, - titleDataTest: { - description: 'Set the data-test attribute for title', + dataTest: { + description: 'Set the data-test attribute for title `title-${dataTest}`', control: 'text', }, }, diff --git a/packages/components/modal/src/modal.ts b/packages/components/modal/src/modal.ts index b81a1689..d17b5a0c 100644 --- a/packages/components/modal/src/modal.ts +++ b/packages/components/modal/src/modal.ts @@ -30,21 +30,11 @@ export const modalProps = buildProps({ required: false, default: undefined, }, - titleDataTest: { - type: String, - required: false, - default: undefined, - }, mainButtonText: { type: String, required: false, default: undefined, }, - mainButtonDataTest: { - type: String, - required: false, - default: undefined, - }, isMainButtonDisabled: { type: Boolean, required: false, @@ -55,21 +45,11 @@ export const modalProps = buildProps({ required: false, default: undefined, }, - secondButtonDataTest: { - type: String, - required: false, - default: undefined, - }, sideButtonText: { type: String, required: false, default: undefined, }, - sideButtonDataTest: { - type: String, - required: false, - default: undefined, - }, variant: { type: String as PropType, required: false, @@ -90,7 +70,7 @@ export const modalProps = buildProps({ required: false, default: undefined, }, - closeButtonDataTest: { + dataTest: { type: String, required: false, default: undefined, diff --git a/packages/components/modal/src/modal.vue b/packages/components/modal/src/modal.vue index dac3363e..e18f0860 100644 --- a/packages/components/modal/src/modal.vue +++ b/packages/components/modal/src/modal.vue @@ -22,7 +22,11 @@ :is-disabled="!showTitleTooltip" class="puik-modal__dialogPanelContainer__dialogPanel__header__title" > -

+

{{ title }}

@@ -33,7 +37,7 @@ :aria-label="t('puik.modal.closeButtonLabel')" class="puik-modal__dialogPanelContainer__dialogPanel__header__close-button" variant="text" - :data-test="closeButtonDataTest" + :data-test="`closeButton-${dataTest}`" @click="sendCloseModalEvent()" > @@ -50,7 +54,7 @@ v-if="secondButtonText" class="puik-modal__dialogPanelContainer__dialogPanel__footer__button--second" :variant="secondButtonVariant" - :data-test="secondButtonDataTest" + :data-test="`secondButton-${dataTest}`" @click="$emit('button-second')" > {{ secondButtonText }} @@ -60,7 +64,7 @@ class="puik-modal__dialogPanelContainer__dialogPanel__footer__button--main" :variant="mainButtonVariant" :disabled="isMainButtonDisabled" - :data-test="mainButtonDataTest" + :data-test="`mainButton-${dataTest}`" @click="$emit('button-main')" > {{ mainButtonText }} @@ -72,7 +76,7 @@ v-if="PuikModalVariant.DIALOG === variant && sideButtonText" class="puik-modal__dialogPanelContainer__dialogPanel__footer__button--side" variant="text" - :data-test="sideButtonDataTest" + :data-test="`sideButton-${dataTest}`" @click="$emit('button-side')" > {{ sideButtonText }} diff --git a/packages/components/modal/stories/modal.stories.ts b/packages/components/modal/stories/modal.stories.ts index 2644ff49..93912477 100644 --- a/packages/components/modal/stories/modal.stories.ts +++ b/packages/components/modal/stories/modal.stories.ts @@ -67,10 +67,6 @@ export default { }, }, }, - titleDataTest: { - description: 'Set the data-test attribute of the title', - control: 'text', - }, mainButtonText: { description: 'Set the text of the main button', control: 'text', @@ -83,10 +79,6 @@ export default { }, }, }, - mainButtonDataTest: { - description: 'Set the data-test attribute of the main button', - control: 'text', - }, secondButtonText: { description: 'Set the text of the secondary button', control: 'text', @@ -99,10 +91,6 @@ export default { }, }, }, - secondButtonDataTest: { - description: 'Set the data-test attribute of the secondary button', - control: 'text', - }, sideButtonText: { description: 'Set the text of the side button', control: 'text', @@ -115,10 +103,6 @@ export default { }, }, }, - sideButtonDataTest: { - description: 'Set the data-test attribute of the side button', - control: 'text', - }, variant: { description: 'Set the style of the modal (use the PuikModalVariant enum)', control: 'select', @@ -191,14 +175,15 @@ export enum PuikModalSize { }, }, }, + dataTest: { + description: + 'Set the data-test attribute for modal `title-${dataTest}` `mainButton-${dataTest}` `secondButton-${dataTest}` `sideButton-${dataTest}` `closeButton-${dataTest}`', + control: 'text', + }, default: { description: 'Modal content', control: 'none', }, - closeButtonDataTest: { - description: 'Set the data-test attribute of the close button', - control: 'text', - }, 'button-main': { control: 'none', description: 'Event emitted on main button click', @@ -220,11 +205,6 @@ export enum PuikModalSize { titleIcon: 'home', variant: PuikModalVariant.DIALOG, size: PuikModalSize.SMALL, - titleDataTest: '', - mainButtonDataTest: '', - secondButtonDataTest: '', - sideButtonDataTest: '', - closeButtonDataTest: '', }, parameters: { chromatic: { delay: 3000 }, diff --git a/packages/components/pagination/src/pagination-large.ts b/packages/components/pagination/src/pagination-large.ts index 08316006..aa3e87f4 100644 --- a/packages/components/pagination/src/pagination-large.ts +++ b/packages/components/pagination/src/pagination-large.ts @@ -37,17 +37,7 @@ export const paginationLargeProps = buildProps({ required: false, default: undefined, }, - labelDataTest: { - type: String, - required: false, - default: undefined, - }, - previousButtonDataTest: { - type: String, - required: false, - default: undefined, - }, - nextButtonDataTest: { + dataTest: { type: String, required: false, default: undefined, diff --git a/packages/components/pagination/src/pagination-large.vue b/packages/components/pagination/src/pagination-large.vue index f325e05e..9ca1dfcd 100644 --- a/packages/components/pagination/src/pagination-large.vue +++ b/packages/components/pagination/src/pagination-large.vue @@ -1,5 +1,5 @@