Skip to content

Commit b7f2f30

Browse files
fixed tests, just commented out tests and button for scroll to top/bottom button for user testing and feedback regarding removal.
1 parent 600059c commit b7f2f30

1 file changed

Lines changed: 173 additions & 174 deletions

File tree

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

Lines changed: 173 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -42,105 +42,104 @@ describe('FloatButton.vue', () => {
4242
},
4343
});
4444

45-
expect(wrapper.html()).toContain('collapse');
4645
expect(wrapper.html()).toContain('publish');
4746
expect(wrapper.html()).toContain('manage');
4847
expect(wrapper.html()).toContain('redo');
4948
expect(wrapper.html()).toContain('undo');
5049
expect(wrapper.html()).toContain('preview');
51-
expect(wrapper.html()).toContain('bottom');
50+
// expect(wrapper.html()).toContain('bottom');
5251
});
5352

54-
it('unmounted should remove the scroll event listener', async () => {
55-
const removeEventListenerSpy = vi.spyOn(window, 'removeEventListener');
56-
const wrapper = shallowMount(FloatButton, {
57-
global: {
58-
plugins: [pinia],
59-
stubs: {
60-
RouterLink: {
61-
name: 'RouterLink',
62-
template: '<div class="router-link-stub"><slot /></div>',
63-
},
64-
},
65-
},
66-
});
67-
68-
await wrapper.unmount();
69-
70-
expect(removeEventListenerSpy).toBeCalledTimes(1);
71-
expect(removeEventListenerSpy).toBeCalledWith(
72-
'scroll',
73-
wrapper.vm.onEventScroll
74-
);
75-
});
76-
77-
it('SCROLL_ICON will be up if we are not at the top of the page and down otherwise', async () => {
78-
const wrapper = shallowMount(FloatButton, {
79-
global: {
80-
plugins: [pinia],
81-
stubs: {
82-
RouterLink: {
83-
name: 'RouterLink',
84-
template: '<div class="router-link-stub"><slot /></div>',
85-
},
86-
},
87-
},
88-
});
89-
expect(wrapper.vm.SCROLL_ICON).toEqual('mdi:mdi-arrow-down');
90-
wrapper.vm.isAtTopOfPage = false;
91-
expect(wrapper.vm.SCROLL_ICON).toEqual('mdi:mdi-arrow-up');
92-
});
93-
94-
it('SCROLL_TEXT will be the top translation if we are not at the top of the page and bottom otherwise', async () => {
95-
const wrapper = shallowMount(FloatButton, {
96-
global: {
97-
plugins: [pinia],
98-
stubs: {
99-
RouterLink: {
100-
name: 'RouterLink',
101-
template: '<div class="router-link-stub"><slot /></div>',
102-
},
103-
},
104-
},
105-
});
106-
expect(wrapper.vm.SCROLL_TEXT).toEqual('trans.floatButton.bottom');
107-
wrapper.vm.isAtTopOfPage = false;
108-
expect(wrapper.vm.SCROLL_TEXT).toEqual('trans.floatButton.top');
109-
});
110-
111-
it('COLLAPSE_ICON will be close if we are not at collapsed and menu otherwise', async () => {
112-
const wrapper = shallowMount(FloatButton, {
113-
global: {
114-
plugins: [pinia],
115-
stubs: {
116-
RouterLink: {
117-
name: 'RouterLink',
118-
template: '<div class="router-link-stub"><slot /></div>',
119-
},
120-
},
121-
},
122-
});
123-
expect(wrapper.vm.COLLAPSE_ICON).toEqual('mdi:mdi-close');
124-
wrapper.vm.isCollapsed = true;
125-
expect(wrapper.vm.COLLAPSE_ICON).toEqual('mdi:mdi-menu');
126-
});
127-
128-
it('COLLAPSE_TEXT will be the collapse translation if we are not collapsed and actions otherwise', async () => {
129-
const wrapper = shallowMount(FloatButton, {
130-
global: {
131-
plugins: [pinia],
132-
stubs: {
133-
RouterLink: {
134-
name: 'RouterLink',
135-
template: '<div class="router-link-stub"><slot /></div>',
136-
},
137-
},
138-
},
139-
});
140-
expect(wrapper.vm.COLLAPSE_TEXT).toEqual('trans.floatButton.collapse');
141-
wrapper.vm.isCollapsed = true;
142-
expect(wrapper.vm.COLLAPSE_TEXT).toEqual('trans.floatButton.actions');
143-
});
53+
// it('unmounted should remove the scroll event listener', async () => {
54+
// const removeEventListenerSpy = vi.spyOn(window, 'removeEventListener');
55+
// const wrapper = shallowMount(FloatButton, {
56+
// global: {
57+
// plugins: [pinia],
58+
// stubs: {
59+
// RouterLink: {
60+
// name: 'RouterLink',
61+
// template: '<div class="router-link-stub"><slot /></div>',
62+
// },
63+
// },
64+
// },
65+
// });
66+
67+
// await wrapper.unmount();
68+
69+
// expect(removeEventListenerSpy).toBeCalledTimes(1);
70+
// expect(removeEventListenerSpy).toBeCalledWith(
71+
// 'scroll',
72+
// wrapper.vm.onEventScroll
73+
// );
74+
// });
75+
76+
// it('SCROLL_ICON will be up if we are not at the top of the page and down otherwise', async () => {
77+
// const wrapper = shallowMount(FloatButton, {
78+
// global: {
79+
// plugins: [pinia],
80+
// stubs: {
81+
// RouterLink: {
82+
// name: 'RouterLink',
83+
// template: '<div class="router-link-stub"><slot /></div>',
84+
// },
85+
// },
86+
// },
87+
// });
88+
// expect(wrapper.vm.SCROLL_ICON).toEqual('mdi:mdi-arrow-down');
89+
// wrapper.vm.isAtTopOfPage = false;
90+
// expect(wrapper.vm.SCROLL_ICON).toEqual('mdi:mdi-arrow-up');
91+
// });
92+
93+
// it('SCROLL_TEXT will be the top translation if we are not at the top of the page and bottom otherwise', async () => {
94+
// const wrapper = shallowMount(FloatButton, {
95+
// global: {
96+
// plugins: [pinia],
97+
// stubs: {
98+
// RouterLink: {
99+
// name: 'RouterLink',
100+
// template: '<div class="router-link-stub"><slot /></div>',
101+
// },
102+
// },
103+
// },
104+
// });
105+
// expect(wrapper.vm.SCROLL_TEXT).toEqual('trans.floatButton.bottom');
106+
// wrapper.vm.isAtTopOfPage = false;
107+
// expect(wrapper.vm.SCROLL_TEXT).toEqual('trans.floatButton.top');
108+
// });
109+
110+
// it('COLLAPSE_ICON will be close if we are not at collapsed and menu otherwise', async () => {
111+
// const wrapper = shallowMount(FloatButton, {
112+
// global: {
113+
// plugins: [pinia],
114+
// stubs: {
115+
// RouterLink: {
116+
// name: 'RouterLink',
117+
// template: '<div class="router-link-stub"><slot /></div>',
118+
// },
119+
// },
120+
// },
121+
// });
122+
// expect(wrapper.vm.COLLAPSE_ICON).toEqual('mdi:mdi-close');
123+
// wrapper.vm.isCollapsed = true;
124+
// expect(wrapper.vm.COLLAPSE_ICON).toEqual('mdi:mdi-menu');
125+
// });
126+
127+
// it('COLLAPSE_TEXT will be the collapse translation if we are not collapsed and actions otherwise', async () => {
128+
// const wrapper = shallowMount(FloatButton, {
129+
// global: {
130+
// plugins: [pinia],
131+
// stubs: {
132+
// RouterLink: {
133+
// name: 'RouterLink',
134+
// template: '<div class="router-link-stub"><slot /></div>',
135+
// },
136+
// },
137+
// },
138+
// });
139+
// expect(wrapper.vm.COLLAPSE_TEXT).toEqual('trans.floatButton.collapse');
140+
// wrapper.vm.isCollapsed = true;
141+
// expect(wrapper.vm.COLLAPSE_TEXT).toEqual('trans.floatButton.actions');
142+
// });
144143

145144
it('SAVE_TEXT will match the savedStatus property otherwise it is just save', async () => {
146145
let wrapper = shallowMount(FloatButton, {
@@ -202,88 +201,88 @@ describe('FloatButton.vue', () => {
202201
expect(wrapper.vm.SAVE_TEXT).toEqual('trans.floatButton.notSaved');
203202
});
204203

205-
it('onEventScroll sets isAtTopOfPage to true if window scroll is at 0, false otherwise', async () => {
206-
const wrapper = shallowMount(FloatButton, {
207-
global: {
208-
plugins: [pinia],
209-
stubs: {
210-
RouterLink: {
211-
name: 'RouterLink',
212-
template: '<div class="router-link-stub"><slot /></div>',
213-
},
214-
},
215-
},
216-
});
217-
wrapper.vm.onEventScroll();
218-
expect(wrapper.vm.isAtTopOfPage).toBe(true);
219-
window.scrollY = 1;
220-
wrapper.vm.onEventScroll();
221-
expect(wrapper.vm.isAtTopOfPage).toBe(false);
222-
});
223-
224-
it('onClickCollapse will toggle the value of isCollapsed', async () => {
225-
const wrapper = shallowMount(FloatButton, {
226-
global: {
227-
plugins: [pinia],
228-
stubs: {
229-
RouterLink: {
230-
name: 'RouterLink',
231-
template: '<div class="router-link-stub"><slot /></div>',
232-
},
233-
},
234-
},
235-
});
236-
expect(wrapper.vm.isCollapsed).toBeFalsy();
237-
wrapper.vm.onClickCollapse();
238-
expect(wrapper.vm.isCollapsed).toBeTruthy();
239-
});
240-
241-
it('onClickSave will emit save', async () => {
242-
const wrapper = shallowMount(FloatButton, {
243-
global: {
244-
plugins: [pinia],
245-
stubs: {
246-
RouterLink: {
247-
name: 'RouterLink',
248-
template: '<div class="router-link-stub"><slot /></div>',
249-
},
250-
},
251-
},
252-
});
253-
wrapper.vm.onClickSave();
254-
expect(wrapper.emitted()).toHaveProperty('save');
255-
});
256-
257-
it('onClickScroll will scroll the window to either the top or bottom depending on if we are at the top of the page or not', async () => {
258-
const wrapper = shallowMount(FloatButton, {
259-
global: {
260-
plugins: [pinia],
261-
stubs: {
262-
RouterLink: {
263-
name: 'RouterLink',
264-
template: '<div class="router-link-stub"><slot /></div>',
265-
},
266-
},
267-
},
268-
});
269-
const scrollToSpy = vi.spyOn(window, 'scrollTo');
270-
wrapper.vm.onClickScroll();
271-
expect(scrollToSpy).toHaveBeenCalledTimes(1);
272-
expect(scrollToSpy).toBeCalledWith({
273-
left: 0,
274-
top: document.body.scrollHeight,
275-
behavior: 'smooth',
276-
});
277-
wrapper.vm.isAtTopOfPage = false;
278-
scrollToSpy.mockReset();
279-
wrapper.vm.onClickScroll();
280-
expect(scrollToSpy).toHaveBeenCalledTimes(1);
281-
expect(scrollToSpy).toBeCalledWith({
282-
left: 0,
283-
top: 0,
284-
behavior: 'smooth',
285-
});
286-
});
204+
// it('onEventScroll sets isAtTopOfPage to true if window scroll is at 0, false otherwise', async () => {
205+
// const wrapper = shallowMount(FloatButton, {
206+
// global: {
207+
// plugins: [pinia],
208+
// stubs: {
209+
// RouterLink: {
210+
// name: 'RouterLink',
211+
// template: '<div class="router-link-stub"><slot /></div>',
212+
// },
213+
// },
214+
// },
215+
// });
216+
// wrapper.vm.onEventScroll();
217+
// expect(wrapper.vm.isAtTopOfPage).toBe(true);
218+
// window.scrollY = 1;
219+
// wrapper.vm.onEventScroll();
220+
// expect(wrapper.vm.isAtTopOfPage).toBe(false);
221+
// });
222+
223+
// it('onClickCollapse will toggle the value of isCollapsed', async () => {
224+
// const wrapper = shallowMount(FloatButton, {
225+
// global: {
226+
// plugins: [pinia],
227+
// stubs: {
228+
// RouterLink: {
229+
// name: 'RouterLink',
230+
// template: '<div class="router-link-stub"><slot /></div>',
231+
// },
232+
// },
233+
// },
234+
// });
235+
// expect(wrapper.vm.isCollapsed).toBeFalsy();
236+
// wrapper.vm.onClickCollapse();
237+
// expect(wrapper.vm.isCollapsed).toBeTruthy();
238+
// });
239+
240+
// it('onClickSave will emit save', async () => {
241+
// const wrapper = shallowMount(FloatButton, {
242+
// global: {
243+
// plugins: [pinia],
244+
// stubs: {
245+
// RouterLink: {
246+
// name: 'RouterLink',
247+
// template: '<div class="router-link-stub"><slot /></div>',
248+
// },
249+
// },
250+
// },
251+
// });
252+
// wrapper.vm.onClickSave();
253+
// expect(wrapper.emitted()).toHaveProperty('save');
254+
// });
255+
256+
// it('onClickScroll will scroll the window to either the top or bottom depending on if we are at the top of the page or not', async () => {
257+
// const wrapper = shallowMount(FloatButton, {
258+
// global: {
259+
// plugins: [pinia],
260+
// stubs: {
261+
// RouterLink: {
262+
// name: 'RouterLink',
263+
// template: '<div class="router-link-stub"><slot /></div>',
264+
// },
265+
// },
266+
// },
267+
// });
268+
// const scrollToSpy = vi.spyOn(window, 'scrollTo');
269+
// wrapper.vm.onClickScroll();
270+
// expect(scrollToSpy).toHaveBeenCalledTimes(1);
271+
// expect(scrollToSpy).toBeCalledWith({
272+
// left: 0,
273+
// top: document.body.scrollHeight,
274+
// behavior: 'smooth',
275+
// });
276+
// wrapper.vm.isAtTopOfPage = false;
277+
// scrollToSpy.mockReset();
278+
// wrapper.vm.onClickScroll();
279+
// expect(scrollToSpy).toHaveBeenCalledTimes(1);
280+
// expect(scrollToSpy).toBeCalledWith({
281+
// left: 0,
282+
// top: 0,
283+
// behavior: 'smooth',
284+
// });
285+
// });
287286

288287
it('test that undo event was triggered', async () => {
289288
const wrapper = mount(FloatButton, {

0 commit comments

Comments
 (0)