Skip to content

Commit f24dbc0

Browse files
Test Fixes
1 parent e15ca4d commit f24dbc0

2 files changed

Lines changed: 33 additions & 48 deletions

File tree

app/frontend/src/components/designer/FloatButton.vue

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ const isAtTopOfPage = ref(true);
7171
7272
const { mdAndDown } = useDisplay();
7373
74-
// const FORM_TITLE = ref('');
7574
// // We need to handle scroll through an event listener because computed values do not update on a scroll event
7675
window.addEventListener('scroll', onEventScroll);
7776
@@ -129,24 +128,6 @@ function onClickScroll() {
129128
});
130129
}
131130
132-
// watch(
133-
// () => [form.value.name, mdAndDown],
134-
// ([name, isMdAndDown]) => {
135-
// const MAX_TITLE_LENGTH = 50;
136-
// if (!name) {
137-
// FORM_TITLE.value = '';
138-
// return;
139-
// }
140-
141-
// if (isMdAndDown && name.length > MAX_TITLE_LENGTH) {
142-
// FORM_TITLE.value = name.slice(0, MAX_TITLE_LENGTH - 3) + '...';
143-
// } else {
144-
// FORM_TITLE.value = name;
145-
// }
146-
// },
147-
// { immediate: true } // run on mount too
148-
// );
149-
150131
const DISPLAY_VERSION = computed(() =>
151132
form.value?.versions?.length ? form.value.versions.length + 1 : 1
152133
);
@@ -246,7 +227,23 @@ defineExpose({
246227
</div>
247228
248229
<v-divider vertical inset :thickness="2" />
249-
230+
<!-- Save Button -->
231+
<div
232+
class="d-flex flex-column align-center icon-button"
233+
data-cy="saveButton"
234+
>
235+
<v-btn
236+
:disabled="!properties.canSave && properties.isFormSaved"
237+
density="compact"
238+
icon
239+
stacked
240+
@click="emit('save')"
241+
>
242+
<v-icon v-if="!properties.isSaving" icon="mdi:mdi-content-save" />
243+
<v-progress-circular v-else indeterminate size="20" />
244+
{{ SAVE_TEXT }}
245+
</v-btn>
246+
</div>
250247
<!-- Preview Button -->
251248
<div
252249
class="d-flex flex-column align-center icon-button"
@@ -389,16 +386,14 @@ defineExpose({
389386
<v-divider vertical inset :thickness="2" />
390387
391388
<!-- Save Button -->
392-
<div
393-
class="d-flex flex-column align-center icon-button"
394-
data-cy="saveButton"
395-
>
389+
<div class="d-flex flex-column align-center icon-button">
396390
<v-btn
397391
:disabled="!properties.canSave && properties.isFormSaved"
398392
density="compact"
393+
data-cy="saveButton"
399394
icon
400395
stacked
401-
@click="onClickSave"
396+
@click="emit('save')"
402397
>
403398
<v-icon v-if="!properties.isSaving" icon="mdi:mdi-content-save" />
404399
<v-progress-circular v-else indeterminate size="20" />
@@ -410,32 +405,13 @@ defineExpose({
410405
<div class="toolbar-dropdown">
411406
<v-menu location="bottom end">
412407
<template #activator="{ props }">
413-
<v-btn icon stacked v-bind="props">
408+
<v-btn icon stacked v-bind="props" data-cy="menuButton">
414409
<v-icon icon="mdi:mdi-dots-vertical" />
415410
Menu
416411
</v-btn>
417412
</template>
418413
419414
<v-list>
420-
<!-- Save Button -->
421-
<v-list-item>
422-
<div class="d-flex flex-column" data-cy="saveButton">
423-
<v-btn
424-
:disabled="!properties.canSave && properties.isFormSaved"
425-
density="compact"
426-
prepend-icon
427-
@click="onClickSave"
428-
>
429-
<v-icon
430-
v-if="!properties.isSaving"
431-
class="mr-1"
432-
icon="mdi:mdi-content-save"
433-
/>
434-
<v-progress-circular v-else indeterminate size="20" />
435-
{{ SAVE_TEXT }}
436-
</v-btn>
437-
</div>
438-
</v-list-item>
439415
<!-- Preview Button -->
440416
<v-list-item>
441417
<div

app/frontend/tests/unit/components/designer/FloatButton.spec.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ vi.mock('vue-router', () => ({
2020
})),
2121
}));
2222

23+
vi.mock('vuetify', () => ({
24+
useDisplay: vi.fn(() => ({
25+
mdAndDown: false,
26+
width: 1920,
27+
height: 1080,
28+
})),
29+
}));
30+
2331
describe('FloatButton.vue', () => {
2432
const pinia = createPinia();
2533
setActivePinia(pinia);
@@ -49,12 +57,13 @@ describe('FloatButton.vue', () => {
4957
},
5058
});
5159

52-
expect(wrapper.html()).toContain('publish');
53-
expect(wrapper.html()).toContain('manage');
5460
expect(wrapper.html()).toContain('redo');
5561
expect(wrapper.html()).toContain('undo');
56-
expect(wrapper.html()).toContain('preview');
5762
expect(wrapper.html()).toContain('bottom');
63+
expect(wrapper.html()).toContain('publish');
64+
expect(wrapper.html()).toContain('manage');
65+
66+
expect(wrapper.html()).toContain('preview');
5867
});
5968

6069
it('unmounted should remove the scroll event listener', async () => {

0 commit comments

Comments
 (0)