Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions frontend/src/components/form/base/__tests__/EColorPicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ describe('An EColorPicker', () => {

const mount = (options) => mountComponent(EColorPicker, { vuetify, i18n, ...options })

beforeAll(() => {
// prevent "[Vuetify] Unable to locate target [data-app]" warnings
document.body.setAttribute('data-app', 'true')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

})

beforeEach(() => {
vuetify = new Vuetify()
})
Expand All @@ -60,6 +65,21 @@ describe('An EColorPicker', () => {
expect(wrapper.find('input[type=text]').element.value).toBe(COLOR_1)
})

test('looks like a color picker', async () => {
const wrapper = mountComponent({
data: () => ({ color: COLOR_1 }),
template: '<div><e-color-picker v-model="color"></e-color-picker></div>',
components: { 'e-color-picker': EColorPicker }
}, {
vuetify,
i18n
})
await waitForDebounce()
expect(wrapper).toMatchSnapshot('pickerclosed')
await wrapper.find('button').trigger('click')
expect(document.body).toMatchSnapshot('pickeropen')
})

test('updates v-model when the value changes', async () => {
const wrapper = mountComponent({
data: () => ({ color: COLOR_1 }),
Expand Down Expand Up @@ -118,8 +138,6 @@ describe('An EColorPicker', () => {
})

test('accepts 3-digit hex color codes', async () => {
// prevent "[Vuetify] Unable to locate target [data-app]" warnings
document.body.setAttribute('data-app', 'true')
const wrapper = mount({
propsData: {
value: '#abc'
Expand Down
22 changes: 20 additions & 2 deletions frontend/src/components/form/base/__tests__/EDatePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ describe('An EDatePicker', () => {

const waitForDebounce = () => new Promise((resolve) => setTimeout(resolve, 110))

beforeAll(() => {
// prevent "[Vuetify] Unable to locate target [data-app]" warnings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

siehe kommentar oben

document.body.setAttribute('data-app', 'true')
})

const mount = (options) => mountComponent(EDatePicker, { vuetify, i18n, ...options })

describe.each(localeData)('in locale %s', (locale, data) => {
Expand All @@ -63,6 +68,21 @@ describe('An EDatePicker', () => {
expect(wrapper.find('input[type=text]').element.value).toBe(data.date_1)
})

test('looks like a date picker', async () => {
const wrapper = mountComponent({
data: () => ({ date: DATE_1 }),
template: '<div><e-date-picker v-model="date"></e-date-picker></div>',
components: { 'e-date-picker': EDatePicker }
}, {
vuetify,
i18n
})
await waitForDebounce()
expect(wrapper).toMatchSnapshot('pickerclosed')
await wrapper.find('button').trigger('click')
expect(document.body).toMatchSnapshot('pickeropen')
})

test('updates v-model when the value changes', async () => {
const wrapper = mountComponent({
data: () => ({ date: DATE_1 }),
Expand Down Expand Up @@ -99,8 +119,6 @@ describe('An EDatePicker', () => {
})

test('updates its value when a date is picked', async () => {
// prevent "[Vuetify] Unable to locate target [data-app]" warnings
document.body.setAttribute('data-app', 'true')
const wrapper = mount({
propsData: {
value: DATE_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ describe('An ETimePicker', () => {
vuetify,
i18n
})
await flushPromises()
await waitForDebounce()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlobeltrame that's the reason for v-text-field--is-booted appearing

expect(wrapper).toMatchSnapshot('pickerclosed')
await wrapper.find('button').trigger('click')
expect(document.querySelector('body')).toMatchSnapshot('pickeropen')
expect(document.body).toMatchSnapshot('pickeropen')
})

test('allows a different valueFormat', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`An EColorPicker looks like a color picker: pickerclosed 1`] = `
<div>
<div class="e-form-container"
vee-rules="[object Object]">
<div class="e-form-container"
value="#ff0000">
<div class="v-input v-input--hide-details v-input--is-label-active v-input--is-dirty theme--light v-text-field v-text-field--single-line v-text-field--filled v-text-field--is-booted v-text-field--enclosed">
<div class="v-input__prepend-outer">
<button type="button"
class="v-icon notranslate v-icon--link mdi mdi-palette theme--light"
style="color: rgb(255, 0, 0); caret-color: #ff0000;"></button>
</div>
<div class="v-input__control">
<div class="v-input__slot">
<div class="v-text-field__slot">
<input id
type="text">
</div>
</div>
</div>
</div>
</div>
<div class="v-menu">
<!---->
</div>
</div>
</div>
`;

exports[`An EColorPicker looks like a color picker: pickeropen 1`] = `
<body
data-app="true"
>
<div
class="v-menu__content theme--light menuable__content__active "
role="menu"
style="max-height: auto; min-width: 290px; max-width: 290px; top: 12px; left: 0px; transform-origin: top left; z-index: 8; display: none;"
>

<div
class="v-card v-sheet theme--light"
>
<div
class="v-color-picker v-sheet theme--light v-color-picker--flat theme--light"
style="max-width: 300px;"
>
<div
class="v-color-picker__canvas"
style="width: 300px; height: 150px;"
>
<canvas
height="150"
width="300"
/>
<div
class="v-color-picker__canvas-dot"
style="width: 10px; height: 10px; transform: translate(295px, -5px);"
/>
</div>
<div
class="v-color-picker__controls"
>
<div
class="v-color-picker__preview v-color-picker__preview--hide-alpha"
>
<div
class="v-color-picker__dot"
>
<div
style="background: rgb(255, 0, 0);"
/>
</div>
<div
class="v-color-picker__sliders"
>
<div
class="v-input v-color-picker__hue v-input--hide-details theme--light v-input__slider v-color-picker__track"
>
<div
class="v-input__control"
>
<div
class="v-input__slot"
>
<div
class="v-slider v-slider--horizontal theme--light"
>
<input
disabled="disabled"
id="input-26"
readonly="readonly"
tabindex="-1"
value="0"
/>
<div
class="v-slider__track-container"
>
<div
class="v-slider__track-background primary lighten-3"
style="right: 0px;"
/>
<div
class="v-slider__track-fill primary"
style="left: 0px; width: 0%;"
/>
</div>
<div
aria-orientation="horizontal"
aria-readonly="false"
aria-valuemax="360"
aria-valuemin="0"
aria-valuenow="0"
class="v-slider__thumb-container grey--text text--lighten-2"
role="slider"
style="left: 0%;"
tabindex="0"
>
<div
class="v-slider__thumb grey lighten-2"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="v-color-picker__edit"
>
<div
class="v-color-picker__input"
>
<input
max="255"
min="0"
step="1"
type="number"
/>
<span>
R
</span>
</div>
<div
class="v-color-picker__input"
>
<input
max="255"
min="0"
step="1"
type="number"
/>
<span>
G
</span>
</div>
<div
class="v-color-picker__input"
>
<input
max="255"
min="0"
step="1"
type="number"
/>
<span>
B
</span>
</div>
<button
class="v-btn v-btn--icon v-btn--round theme--light v-size--small"
type="button"
>
<span
class="v-btn__content"
>
<i
aria-hidden="true"
class="v-icon notranslate mdi mdi-unfold-more-horizontal theme--light"
/>
</span>
</button>
</div>
</div>
</div>

<div
class="spacer"
/>

<button
class="v-btn v-btn--text theme--light v-size--default primary--text"
data-testid="action-cancel"
type="button"
>
<span
class="v-btn__content"
>

Abbrechen

</span>
</button>

<button
class="v-btn v-btn--text theme--light v-size--default primary--text"
data-testid="action-ok"
type="button"
>
<span
class="v-btn__content"
>

In Ordnung

</span>
</button>
</div>
</div>
</body>
`;
Loading