Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENT-8400] Add subtitle facet to search header #382

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/catalog-search/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const FEATURE_LANGUAGE_FACET = 'LANGUAGE_FACET';
export const FEATURE_PROGRAM_TITLES_FACET = 'PROGRAM_TITLES_FACET';
export const LEARNING_TYPE_FACET = 'LEARNING_TYPE_FACET';
export const FEATURE_ENABLE_PATHWAYS = 'ENABLE_PATHWAYS';
export const FEATURE_SUBTITLE_FACET = 'SUBTITLE_FACET';

// eslint-disable-next-line import/prefer-default-export
export const features = {
Expand All @@ -19,4 +20,7 @@ export const features = {
ENABlE_PATHWAYS: (
process.env.FEATURE_ENABLE_PATHWAYS || hasFeatureFlagEnabled(FEATURE_ENABLE_PATHWAYS)
),
SUBTITLE_FACET: (
process.env.FEATURE_SUBTITLE_FACET || hasFeatureFlagEnabled(FEATURE_SUBTITLE_FACET)
mahamakifdar19 marked this conversation as resolved.
Show resolved Hide resolved
),
};
8 changes: 8 additions & 0 deletions packages/catalog-search/src/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ if (features.LEARNING_TYPE_FACET) {
});
}

if (features.SUBTITLE_FACET) {
SEARCH_FACET_FILTERS.push({
attribute: 'transcript_languages',
title: 'Subtitle',
isSortedAlphabetical: true,
});
}

export const BOOLEAN_FILTERS = [SHOW_ALL_NAME];
export const QUERY_PARAM_FOR_SEARCH_QUERY = 'q';
export const QUERY_PARAM_FOR_PAGE = 'page';
Expand Down
53 changes: 53 additions & 0 deletions packages/catalog-search/src/data/tests/constants.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
SEARCH_FACET_FILTERS,
ADDITIONAL_FACET_FILTERS,
} from '../constants';

jest.mock('../../config', () => ({
__esModule: true,
features: {
ENROLL_WITH_CODES: true,
LANGUAGE_FACET: true,
PROGRAM_TITLES_FACET: true,
LEARNING_TYPE_FACET: true,
ENABLE_PATHWAYS: true,
SUBTITLE_FACET: true,
},
}));

describe('Constants', () => {
test('Search facet filters are defined correctly', () => {
expect(SEARCH_FACET_FILTERS).toHaveLength(9);
});

test('Additional facet filters are defined correctly', () => {
expect(Array.isArray(ADDITIONAL_FACET_FILTERS)).toBe(true);
});

test('Language facet filter is added when feature is enabled', () => {
const languageFacet = SEARCH_FACET_FILTERS.find(
(facet) => facet.attribute === 'language',
);
expect(languageFacet).toBeDefined();
expect(languageFacet.title).toBe('Language');
expect(languageFacet.isSortedAlphabetical).toBe(true);
});

test('Learning type facet filter is added when feature is enabled', () => {
const learningTypeFacet = SEARCH_FACET_FILTERS.find(
(facet) => facet.attribute === 'content_type',
);
expect(learningTypeFacet).toBeDefined();
expect(learningTypeFacet.title).toBe('Learning type');
expect(learningTypeFacet.noDisplay).toBe(true);
});

test('Subtitle facet filter is added when feature is enabled', () => {
const subtitleFacet = SEARCH_FACET_FILTERS.find(
(facet) => facet.attribute === 'transcript_languages',
);
expect(subtitleFacet).toBeDefined();
expect(subtitleFacet.title).toBe('Subtitle');
expect(subtitleFacet.isSortedAlphabetical).toBe(true);
});
});
Loading