Skip to content

Commit 714dc25

Browse files
authored
Merge pull request #1069 from Sysvale/hotfix/fix-date-input-tests-16465431169864620625
Fix DateInput tests and standardize date handling
2 parents 217084a + 80e146a commit 714dc25

7 files changed

Lines changed: 19 additions & 9 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sysvale/cuida",
3-
"version": "3.154.11",
3+
"version": "3.154.12",
44
"description": "A design system built by Sysvale, using storybook and Vue components",
55
"repository": {
66
"type": "git",

src/components/InlineDateInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export default {
184184
inputControl: 0,
185185
attributes: [
186186
{
187-
dates: new Date(),
187+
dates: DateTime.now().toJSDate(),
188188
dot: true,
189189
},
190190
],

src/components/InternalComponents/MonthSelectorGrid.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<script setup>
2121
import CdsGrid from '../Grid.vue';
2222
import { computed, ref, onMounted, watch } from 'vue';
23+
import { DateTime } from 'luxon';
2324
2425
defineOptions({ name: 'CdsMonthSelectorGrid' });
2526
@@ -45,7 +46,7 @@ const props = defineProps({
4546
},
4647
year: {
4748
type: Number,
48-
default: new Date().getFullYear(),
49+
default: DateTime.now().year,
4950
},
5051
});
5152

src/components/InternalComponents/YearSelectorGrid.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
<script setup>
3636
import { ref, computed, onUnmounted } from 'vue';
37+
import { DateTime } from 'luxon';
3738
import CdsGrid from '../Grid.vue';
3839
3940
defineOptions({ name: 'CdsYearSelectorGrid' });
@@ -61,7 +62,7 @@ const props = defineProps({
6162
const emits = defineEmits(['click']);
6263
6364
/* REACTIVE DATA */
64-
const todayYear = new Date().getFullYear();
65+
const todayYear = DateTime.now().year;
6566
const selectedYear = computed(() => {
6667
if (!props.selectedDate) return null;
6768
return parseInt(props.selectedDate.split('-')[0]);

src/tests/SelectorGridHighlight.spec.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import { describe, test, expect, beforeEach, vi } from 'vitest';
1+
import { describe, test, expect, beforeEach, afterEach, vi } from 'vitest';
22
import { mount } from '@vue/test-utils';
33
import MonthSelectorGrid from '../components/InternalComponents/MonthSelectorGrid.vue';
44
import YearSelectorGrid from '../components/InternalComponents/YearSelectorGrid.vue';
5+
import { Settings } from 'luxon';
56

67
describe('SelectorGrid Highlight Fix', () => {
78
beforeEach(() => {
89
vi.useFakeTimers();
9-
vi.setSystemTime(new Date(2026, 1, 10)); // Feb 10, 2026
10+
const mockDate = new Date(2026, 1, 10); // Feb 10, 2026
11+
vi.setSystemTime(mockDate);
12+
Settings.now = () => mockDate.getTime();
13+
});
14+
15+
afterEach(() => {
16+
vi.useRealTimers();
17+
Settings.now = () => Date.now();
1018
});
1119

1220
describe('MonthSelectorGrid', () => {

src/utils/constants/inputTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default ['text', 'textarea', 'email', 'password', 'tel', 'number', 'search', 'url'];
1+
export default ['text', 'textarea', 'email', 'password', 'tel', 'number', 'search', 'url', 'date'];

0 commit comments

Comments
 (0)