Skip to content

Commit d3b8046

Browse files
committed
BZ-40556:test: Add testId input property for modal and select properties
- Adding a new property in modal and select properties that uniquely identifies items - Enhances the testing capabilities
1 parent eaef9e3 commit d3b8046

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

src/lib/Modal/Modal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
</div>
113113
{/if}
114114
{#if properties.header.rightImage}
115-
<div role="button" tabindex="0" on:click={handleRightImageClick} on:keydown data-pw={`${properties.header.dataPw}-button`}>
115+
<div role="button" tabindex="0" on:click={handleRightImageClick} on:keydown data-pw={`${properties.header.buttonTestId}`}>
116116
<img class="header-right-img" src={properties.header.rightImage} alt="" />
117117
</div>
118118
{/if}

src/lib/Modal/properties.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export type ModalProperties = {
1515
leftImage: string | null;
1616
rightImage: string | null;
1717
text: string | null;
18-
dataPw?: string | null;
18+
dataPw?: string;
19+
buttonTestId?: string;
1920
};
2021
footer?: {
2122
primaryButton?: ButtonProperties,

src/lib/Select/Select.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
</script>
139139

140140
{#if properties.label !== null && properties.label !== ''}
141-
<label class="label-container" for={properties.label} data-pw={`${properties.dataPw}-heading`}>
141+
<label class="label-container" for={properties.label} data-pw={`${properties.dataPwHeading}`}>
142142
{properties.label}
143143
</label>
144144
{/if}
@@ -220,7 +220,7 @@
220220
class="item {isSelected(properties.selectedItem, item) ? ' item-selected' : ''}"
221221
role="button"
222222
tabindex="0"
223-
data-pw={`${properties.dataPw}-item-${item}`}
223+
data-pw={`${properties.dataPwItemButton}-${item}`}
224224
>
225225
{#if properties.selectMultipleItems}
226226
<CheckListItem checked={isSelected(properties.selectedItem, item)} text="" />

src/lib/Select/properties.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ export type SelectProperties = {
1414
showSelectedItem?: boolean;
1515
showSelectedItemCount?: boolean;
1616
dataPw?: string;
17+
dataPwHeading?: string;
18+
dataPwItemButton?: string;
1719
};

src/lib/Toast/Toast.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@
104104
</div>
105105
{/if}
106106

107-
<div class="toast-message">
107+
<div class="toast-message" data-pw={properties.dataPwMessage}>
108108
{properties.message}
109109
{#if properties.subtext}
110-
<div class="toast-subtext">{properties.subtext}</div>
110+
<div class="toast-subtext" data-pw={properties.dataPwSubText}>{properties.subtext}</div>
111111
{/if}
112112

113113
{#if $$slots.bottomContent}
@@ -116,7 +116,7 @@
116116
</div>
117117

118118
{#if properties.rightIcon}
119-
<div class="close-button" tabindex="0" role="button" on:click={hideToast} on:keypress>
119+
<div class="close-button" tabindex="0" role="button" on:click={hideToast} on:keypress data-pw={properties.dataPwCloseIcon}>
120120
<img class="toast-icon" src={properties.rightIcon} alt="close-icon" />
121121
</div>
122122
{/if}

src/lib/Toast/properties.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export type ToastProperties = {
1414
inAnimationDuration?: number;
1515
outAnimationOffset?: number;
1616
outAnimationDuration?: number;
17+
dataPw?: string;
18+
dataPwMessage?: string;
19+
dataPwSubText?: string;
20+
dataPwCloseIcon?: string;
1721
};
1822

1923
export const defaultToastProperties: ToastProperties = {

0 commit comments

Comments
 (0)