|
| 1 | +import { render, screen } from '@testing-library/vue'; |
| 2 | +import { Store } from 'vuex'; |
| 3 | +import VueRouter from 'vue-router'; |
| 4 | +import CatalogFilterPanelContent from '../components/CatalogFilterPanelContent.vue'; |
| 5 | + |
| 6 | +const mockRouter = new VueRouter({ |
| 7 | + routes: [{ name: 'CATALOG_FAQ', path: '/catalog/faq' }], |
| 8 | +}); |
| 9 | + |
| 10 | +const createStore = () => { |
| 11 | + return new Store({ |
| 12 | + getters: { |
| 13 | + loggedIn: () => true, |
| 14 | + }, |
| 15 | + }); |
| 16 | +}; |
| 17 | + |
| 18 | +const renderComponent = () => { |
| 19 | + const store = createStore(); |
| 20 | + |
| 21 | + return render(CatalogFilterPanelContent, { |
| 22 | + store, |
| 23 | + routes: mockRouter, |
| 24 | + }); |
| 25 | +}; |
| 26 | + |
| 27 | +beforeEach(() => { |
| 28 | + window.libraryMode = false; |
| 29 | + window.publicKinds = ['video', 'audio', 'document']; |
| 30 | + window.publicLicenses = [1, 2, 3]; |
| 31 | +}); |
| 32 | + |
| 33 | +describe('CatalogFilterPanelContent', () => { |
| 34 | + it('renders all filter components', () => { |
| 35 | + renderComponent(); |
| 36 | + |
| 37 | + expect(screen.getByLabelText('Keywords')).toBeInTheDocument(); |
| 38 | + expect(screen.getByLabelText('Licenses')).toBeInTheDocument(); |
| 39 | + expect(screen.getByLabelText('Formats')).toBeInTheDocument(); |
| 40 | + expect(screen.getByRole('checkbox', { name: 'Starred' })).toBeInTheDocument(); |
| 41 | + expect(screen.getByText('Display only channels with')).toBeInTheDocument(); |
| 42 | + expect(screen.getByRole('checkbox', { name: 'Resources for coaches' })).toBeInTheDocument(); |
| 43 | + expect(screen.getByRole('checkbox', { name: 'Captions or subtitles' })).toBeInTheDocument(); |
| 44 | + expect(screen.getByText('Frequently asked questions')).toBeInTheDocument(); |
| 45 | + expect(screen.getByAltText('Learning Equality logo')).toBeInTheDocument(); |
| 46 | + }); |
| 47 | + |
| 48 | + it('renders keyword search input', () => { |
| 49 | + renderComponent(); |
| 50 | + expect(screen.getByLabelText('Keywords')).toBeInTheDocument(); |
| 51 | + }); |
| 52 | + |
| 53 | + it('hides license filter in library mode', () => { |
| 54 | + window.libraryMode = true; |
| 55 | + renderComponent(); |
| 56 | + expect(screen.queryByLabelText('Licenses')).not.toBeInTheDocument(); |
| 57 | + }); |
| 58 | + |
| 59 | + it('shows license filter in non-library mode', () => { |
| 60 | + window.libraryMode = false; |
| 61 | + renderComponent(); |
| 62 | + expect(screen.getByLabelText('Licenses')).toBeInTheDocument(); |
| 63 | + }); |
| 64 | + |
| 65 | + it('renders help tooltip for coach resources', () => { |
| 66 | + renderComponent(); |
| 67 | + expect(screen.getByRole('checkbox', { name: 'Resources for coaches' })).toBeInTheDocument(); |
| 68 | + }); |
| 69 | + |
| 70 | + it('renders footer with copyright', () => { |
| 71 | + renderComponent(); |
| 72 | + const currentYear = new Date().getFullYear(); |
| 73 | + expect(screen.getByText(`© ${currentYear} Learning Equality`)).toBeInTheDocument(); |
| 74 | + }); |
| 75 | + |
| 76 | + it('renders FAQ link with external icon', () => { |
| 77 | + renderComponent(); |
| 78 | + const faqLink = screen.getByText('Frequently asked questions'); |
| 79 | + expect(faqLink).toBeInTheDocument(); |
| 80 | + }); |
| 81 | + |
| 82 | + it('renders language filter', () => { |
| 83 | + renderComponent(); |
| 84 | + expect(screen.getByText('Languages')).toBeInTheDocument(); |
| 85 | + }); |
| 86 | +}); |
0 commit comments