From 51b7dbb29b63bfd023948b10058fedb29aeda747 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Wed, 15 Apr 2026 20:46:11 -0700 Subject: [PATCH] feat(demo): add HintChip component with per-view localStorage dismiss --- web/src/components/HintChip.vue | 63 +++++++++++++++++++ web/src/components/__tests__/HintChip.test.ts | 28 +++++++++ 2 files changed, 91 insertions(+) create mode 100644 web/src/components/HintChip.vue create mode 100644 web/src/components/__tests__/HintChip.test.ts diff --git a/web/src/components/HintChip.vue b/web/src/components/HintChip.vue new file mode 100644 index 0000000..bc8960b --- /dev/null +++ b/web/src/components/HintChip.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/web/src/components/__tests__/HintChip.test.ts b/web/src/components/__tests__/HintChip.test.ts new file mode 100644 index 0000000..ccbbabf --- /dev/null +++ b/web/src/components/__tests__/HintChip.test.ts @@ -0,0 +1,28 @@ +import { describe, it, expect, beforeEach } from 'vitest' +import { mount } from '@vue/test-utils' +import HintChip from '../HintChip.vue' + +beforeEach(() => { localStorage.clear() }) + +const factory = (viewKey = 'home', message = 'Test hint') => + mount(HintChip, { props: { viewKey, message } }) + +describe('HintChip', () => { + it('renders the message', () => { + const w = factory() + expect(w.text()).toContain('Test hint') + }) + + it('is hidden when localStorage key is already set', () => { + localStorage.setItem('peregrine_hint_home', '1') + const w = factory() + expect(w.find('.hint-chip').exists()).toBe(false) + }) + + it('hides and sets localStorage when dismiss button is clicked', async () => { + const w = factory() + await w.find('.hint-chip__dismiss').trigger('click') + expect(w.find('.hint-chip').exists()).toBe(false) + expect(localStorage.getItem('peregrine_hint_home')).toBe('1') + }) +})