Skip to content

Commit d15bb90

Browse files
Made test file for catalogfilterpanelcontent
1 parent ddc7726 commit d15bb90

File tree

4 files changed

+91
-5
lines changed

4 files changed

+91
-5
lines changed

contentcuration/contentcuration/frontend/channelList/views/Channel/CatalogFilters.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
4848
import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow';
4949
import CatalogFilterBar from './CatalogFilterBar';
50-
import CatalogFilterPanelContent from './CatalogFilterPanelContent';
50+
import CatalogFilterPanelContent from './components/CatalogFilterPanelContent.vue';
5151
import SidePanelModal from 'shared/views/SidePanelModal';
5252
5353
export default {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
});

contentcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogFilters.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils';
22
import { factory } from '../../../store';
33
import router from '../../../router';
44
import CatalogFilters from '../CatalogFilters';
5-
import CatalogFilterPanelContent from '../CatalogFilterPanelContent';
5+
import CatalogFilterPanelContent from '../components/CatalogFilterPanelContent.vue';
66

77
const store = factory();
88

contentcuration/contentcuration/frontend/channelList/views/Channel/CatalogFilterPanelContent.vue renamed to contentcuration/contentcuration/frontend/channelList/views/Channel/components/CatalogFilterPanelContent.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@
107107
108108
import { mapGetters } from 'vuex';
109109
import debounce from 'lodash/debounce';
110-
import { RouteNames } from '../../constants';
111-
import { catalogFilterMixin } from './mixins';
112-
import LanguageFilter from './components/LanguageFilter';
110+
import { RouteNames } from '../../../constants';
111+
import { catalogFilterMixin } from '../mixins';
112+
import LanguageFilter from './LanguageFilter.vue';
113113
import MultiSelect from 'shared/views/form/MultiSelect';
114114
import { constantsTranslationMixin } from 'shared/mixins';
115115
import Checkbox from 'shared/views/form/Checkbox';

0 commit comments

Comments
 (0)