|
| 1 | +import { describe, it, expect } from 'vitest' |
| 2 | +import { mount } from '@vue/test-utils' |
| 3 | +import BoardActionRail from '../../components/board/BoardActionRail.vue' |
| 4 | + |
| 5 | +describe('BoardActionRail — button emissions', () => { |
| 6 | + it('renders all action buttons', () => { |
| 7 | + const wrapper = mount(BoardActionRail) |
| 8 | + |
| 9 | + expect(wrapper.text()).toContain('Board Actions') |
| 10 | + expect(wrapper.text()).toContain('Capture here') |
| 11 | + expect(wrapper.text()).toContain('Ask assistant') |
| 12 | + expect(wrapper.text()).toContain('Review proposals') |
| 13 | + expect(wrapper.text()).toContain('Open Inbox') |
| 14 | + expect(wrapper.text()).toContain('Add card') |
| 15 | + }) |
| 16 | + |
| 17 | + it('emits capture when Capture here button is clicked', async () => { |
| 18 | + const wrapper = mount(BoardActionRail) |
| 19 | + |
| 20 | + const btn = wrapper.findAll('button').find((b) => b.text().trim() === 'Capture here') |
| 21 | + await btn!.trigger('click') |
| 22 | + |
| 23 | + expect(wrapper.emitted('capture')).toHaveLength(1) |
| 24 | + }) |
| 25 | + |
| 26 | + it('emits chat when Ask assistant button is clicked', async () => { |
| 27 | + const wrapper = mount(BoardActionRail) |
| 28 | + |
| 29 | + const btn = wrapper.findAll('button').find((b) => b.text().trim() === 'Ask assistant') |
| 30 | + await btn!.trigger('click') |
| 31 | + |
| 32 | + expect(wrapper.emitted('chat')).toHaveLength(1) |
| 33 | + }) |
| 34 | + |
| 35 | + it('emits review when Review proposals button is clicked', async () => { |
| 36 | + const wrapper = mount(BoardActionRail) |
| 37 | + |
| 38 | + const btn = wrapper.findAll('button').find((b) => b.text().trim() === 'Review proposals') |
| 39 | + await btn!.trigger('click') |
| 40 | + |
| 41 | + expect(wrapper.emitted('review')).toHaveLength(1) |
| 42 | + }) |
| 43 | + |
| 44 | + it('emits inbox when Open Inbox button is clicked', async () => { |
| 45 | + const wrapper = mount(BoardActionRail) |
| 46 | + |
| 47 | + const btn = wrapper.findAll('button').find((b) => b.text().trim() === 'Open Inbox') |
| 48 | + await btn!.trigger('click') |
| 49 | + |
| 50 | + expect(wrapper.emitted('inbox')).toHaveLength(1) |
| 51 | + }) |
| 52 | + |
| 53 | + it('emits addCard when Add card button is clicked', async () => { |
| 54 | + const wrapper = mount(BoardActionRail) |
| 55 | + |
| 56 | + const btn = wrapper.findAll('button').find((b) => b.text().trim() === 'Add card') |
| 57 | + await btn!.trigger('click') |
| 58 | + |
| 59 | + expect(wrapper.emitted('addCard')).toHaveLength(1) |
| 60 | + }) |
| 61 | + |
| 62 | + it('shows the review-first trust hint', () => { |
| 63 | + const wrapper = mount(BoardActionRail) |
| 64 | + |
| 65 | + expect(wrapper.text()).toContain('Only approved changes land on this board.') |
| 66 | + }) |
| 67 | + |
| 68 | + it('has the data-board-action-rail attribute for test targeting', () => { |
| 69 | + const wrapper = mount(BoardActionRail) |
| 70 | + |
| 71 | + expect(wrapper.find('[data-board-action-rail]').exists()).toBe(true) |
| 72 | + }) |
| 73 | + |
| 74 | + it('distinguishes Add card button as primary', () => { |
| 75 | + const wrapper = mount(BoardActionRail) |
| 76 | + |
| 77 | + const addCardBtn = wrapper.findAll('button').find((b) => b.text().trim() === 'Add card') |
| 78 | + expect(addCardBtn!.classes()).toContain('td-action-rail__btn--primary') |
| 79 | + }) |
| 80 | +}) |
0 commit comments