From 5723470f6533b65f6dc50f37afa99ca361b3fc26 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Mon, 22 Jun 2026 19:28:09 -0600 Subject: [PATCH] feat: merge print/export buttons into a single dropdown in WorkspaceToolbar --- src/components/WorkspaceToolbar.test.ts | 21 ++++++++++++++++++--- src/components/WorkspaceToolbar.vue | 4 ++-- src/components/WorkspaceView.test.ts | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/WorkspaceToolbar.test.ts b/src/components/WorkspaceToolbar.test.ts index 95b89ee..e31b33b 100644 --- a/src/components/WorkspaceToolbar.test.ts +++ b/src/components/WorkspaceToolbar.test.ts @@ -42,10 +42,25 @@ describe('WorkspaceToolbar', () => { expect(wrapper.get('button[data-testid="back"]').attributes('disabled')).toBeUndefined() }) - it('disables print, export and clear when there are no lessons', () => { + it('disables the export menu toggle and clear button when there are no lessons', () => { const wrapper = mountToolbar(0) - expect(wrapper.get('button[data-testid="print"]').attributes('disabled')).toBeDefined() - expect(wrapper.get('button[data-testid="export"]').attributes('disabled')).toBeDefined() + expect( + wrapper.get('button[data-testid="export-menu-toggle"]').attributes('disabled'), + ).toBeDefined() expect(wrapper.get('button[data-testid="clear"]').attributes('disabled')).toBeDefined() }) + + it('emits print when the print menu item is clicked', async () => { + const wrapper = mountToolbar(3) + await wrapper.get('button[data-testid="export-menu-toggle"]').trigger('click') + await wrapper.get('button[data-testid="print"]').trigger('click') + expect(wrapper.emitted('print')).toHaveLength(1) + }) + + it('emits export when the export menu item is clicked', async () => { + const wrapper = mountToolbar(3) + await wrapper.get('button[data-testid="export-menu-toggle"]').trigger('click') + await wrapper.get('button[data-testid="export"]').trigger('click') + expect(wrapper.emitted('export')).toHaveLength(1) + }) }) diff --git a/src/components/WorkspaceToolbar.vue b/src/components/WorkspaceToolbar.vue index b2f2e84..eb4486a 100644 --- a/src/components/WorkspaceToolbar.vue +++ b/src/components/WorkspaceToolbar.vue @@ -1,5 +1,6 @@