Skip to content

Commit 58e16b1

Browse files
committed
refactor: Expose data-test attributes
1 parent e861581 commit 58e16b1

File tree

5 files changed

+5
-17
lines changed

5 files changed

+5
-17
lines changed

index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export interface VueDatePickerProps {
215215
style?: Record<string, string>;
216216
slot?: string;
217217
noTz?: boolean;
218+
testId?: string;
218219
}[];
219220
flow?: ('month' | 'year' | 'calendar' | 'time' | 'minutes' | 'hours' | 'seconds')[];
220221
partialFlow?: boolean;

src/VueDatePicker/components/DatepickerInput.vue

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
v-if="!$slots['dp-input']"
2727
:id="uid ? `dp-input-${uid}` : undefined"
2828
ref="inputRef"
29+
data-test="dp-input"
2930
:name="name"
3031
:class="inputClass"
3132
:inputmode="defaultedTextInput.enabled ? 'text' : 'none'"

src/VueDatePicker/components/DatepickerMenu.vue

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
:style="preset.style || {}"
5454
class="dp__btn dp--preset-range"
5555
:class="{ 'dp--preset-range-collapsed': collapse }"
56+
:data-test="preset.testId ?? undefined"
5657
@click.prevent="presetDate(preset.value, preset.noTz)"
5758
@keydown.enter.prevent="presetDate(preset.value, preset.noTz)"
5859
@keydown.space.prevent="presetDate(preset.value, preset.noTz)"

src/VueDatePicker/interfaces.ts

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export type PresetDate = {
130130
style?: Record<string, string>;
131131
slot?: string;
132132
noTz?: boolean;
133+
testId?: string;
133134
};
134135

135136
export type Flow = 'month' | 'year' | 'calendar' | 'time' | 'minutes' | 'hours' | 'seconds';

vite.config.ts

+1-17
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,8 @@ import minimist from 'minimist';
66

77
const { f } = minimist(process.argv.slice(2));
88

9-
function removeDataTestAttrs(node: any) {
10-
if (node.type === 1) {
11-
node.props = node.props.filter((prop: any) => {
12-
if (prop.name === 'data-test') return false;
13-
return !(prop.name === 'bind' && prop.arg?.content === 'data-test');
14-
});
15-
}
16-
}
179
export default defineConfig({
18-
plugins: [
19-
vue({
20-
template: {
21-
compilerOptions: {
22-
nodeTransforms: process.env.NODE_ENV === 'production' ? [removeDataTestAttrs] : [],
23-
},
24-
},
25-
}),
26-
],
10+
plugins: [vue()],
2711
resolve: {
2812
alias: {
2913
'@': fileURLToPath(new URL('./src/VueDatePicker', import.meta.url)),

0 commit comments

Comments
 (0)