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

feat(quantic): added support for custom options in the quanticSort component #4101

Merged
merged 45 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b8c10fe
added slot and quantic sort option component
SimonMilord Jun 17, 2024
d9ac704
added check and getter for custom options
SimonMilord Jun 17, 2024
ab1a0fd
fixed type
SimonMilord Jun 18, 2024
e5fc914
removed unessary type declaration
SimonMilord Jun 18, 2024
ce7c358
cleanup
SimonMilord Jun 18, 2024
8676d83
added quantic E2E tests for custom options display and select
SimonMilord Jun 21, 2024
01d7088
added comment for doc and validation with Bueno
SimonMilord Jun 25, 2024
48f50b5
added e2e cypress test to check that the error message is displayed i…
SimonMilord Jun 25, 2024
12f0683
changed e2e files to remove properties public and support actions and…
SimonMilord Jun 26, 2024
d407a71
created action add custom sort options and split the quanticSort exam…
SimonMilord Jun 26, 2024
19c6318
changed the quanticSort component to only use the quanticErrorCompone…
SimonMilord Jun 27, 2024
88b8e93
added named slots for quanticSort
SimonMilord Jun 27, 2024
8131d61
changed up the validation with bueno to use schemas
SimonMilord Jun 28, 2024
4210c06
applied some feedback in the e2e tests cypress
SimonMilord Jul 2, 2024
9b3eda4
some more improvements
SimonMilord Jul 2, 2024
fbf1557
fix tests
SimonMilord Jul 2, 2024
baabb26
applied another round of feedback
SimonMilord Jul 3, 2024
0ea5ee8
changed the ts-ignore locations
SimonMilord Jul 5, 2024
966e6b8
revert value getter
SimonMilord Jul 8, 2024
a387b97
more changes for state related issue
SimonMilord Jul 9, 2024
a7a8c86
added logic to send and get sortOptions to the quantic store for refi…
SimonMilord Jul 10, 2024
5b88f49
added unit tests in quanticHeadlessLoader
SimonMilord Jul 11, 2024
68874d9
added cypress test to see that the custom sort options are linked bet…
SimonMilord Jul 11, 2024
eb0eeed
applied a batch of feedback for e2e tests
SimonMilord Jul 15, 2024
f373197
fixed unit test
SimonMilord Jul 15, 2024
85e114a
updated property name from shouldDisplaySort to sortOptionsInitialized
SimonMilord Jul 16, 2024
86ae47f
forgot to save a file
SimonMilord Jul 18, 2024
3a85cd4
some changes
SimonMilord Jul 18, 2024
fedd4e4
refactored selectors
SimonMilord Jul 18, 2024
a9cc052
added check for search request in refine modal
SimonMilord Jul 18, 2024
20e3956
added custom label
SimonMilord Jul 30, 2024
8635294
applied some more feedback, changed getter naming
SimonMilord Jul 30, 2024
7a24904
changed selectors for refine modal
SimonMilord Jul 30, 2024
3238634
fix search requests in sort file
SimonMilord Jul 30, 2024
9675632
Merge branch 'master' into SFINT-5491
SimonMilord Jul 30, 2024
e917755
fixed failing tests by removing superfluous check
SimonMilord Jul 30, 2024
b3cf568
applied more feedback
SimonMilord Aug 6, 2024
ca5c736
Merge branch 'master' into SFINT-5491
SimonMilord Aug 6, 2024
f76c3a7
fixed test, added check again for refine toggle
SimonMilord Aug 8, 2024
70cb789
applied fix for sortOptions initialization
SimonMilord Aug 13, 2024
48fac10
fix bug
SimonMilord Aug 14, 2024
c004b57
renamed getter
SimonMilord Aug 14, 2024
acd71fb
forgot to push this commit
SimonMilord Aug 14, 2024
5ac65bf
Merge branch 'master' into SFINT-5491
SimonMilord Aug 14, 2024
4976b57
Merge branch 'master' into SFINT-5491
SimonMilord Aug 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
RefineContentSelectors,
} from './refine-modal-content-selectors';

function defineContentActions(selector: RefineContentSelector) {
function refineContentActions(selector: RefineContentSelector) {
return {
clickClearAllFilters: () => {
selector
Expand Down Expand Up @@ -43,9 +43,27 @@ function defineContentActions(selector: RefineContentSelector) {
'when clicking the first option of the duplicated timeframe facet'
);
},
openRefineModalSortDropdown: () => {
selector
.refineSortDropdown()
.click()
.logAction('when opening the sort dropdown in the refine modal');
},
};
}

function sortActions(selector: RefineContentSelector) {
return {
openSortDropdown: () => {
selector
.sortDropdown()
.click()
.logAction('when opening the sort dropdown');
},
};
}

export const RefineContentActions = {
...defineContentActions(RefineContentSelectors),
...refineContentActions(RefineContentSelectors),
...sortActions(RefineContentSelectors),
SimonMilord marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {Interception} from 'cypress/types/net-stubbing';
import {InterceptAliases} from '../../../page-objects/search';
import {should} from '../../common-selectors';
import {
RefineContentSelector,
RefineContentSelectors,
SortSelector,
} from './refine-modal-content-selectors';

const COMMON_FACET_PROPERTIES = ['facetId', 'field', 'label'];
Expand Down Expand Up @@ -186,13 +189,6 @@ function refineContentExpectations(selector: RefineContentSelector) {
.logDetail('should display the duplicated date facet');
},

displaySort: (display: boolean) => {
selector
.sort()
.should(display ? 'exist' : 'not.exist')
.logDetail(`${should(display)} display the Quantic Sort component`);
},

displayDuplicatedTimeframeFacetClearFiltersButton: (display: boolean) => {
selector
.timeframeFacetClearFiltersButton()
Expand Down Expand Up @@ -263,9 +259,65 @@ function refineContentExpectations(selector: RefineContentSelector) {
})
.logDetail('should order the facets correctly');
},

displayRefineModalSort: (display: boolean) => {
selector
.refineSort()
.should(display ? 'exist' : 'not.exist')
.logDetail(
`${should(display)} display the Quantic Sort component in the refine modal`
);
},

refineSortOptionsEqual: (options: {value: string; label: string}[]) => {
options.forEach((option) => {
selector
.refineSortOption(option.value)
.should('exist')
.should('contain', option.label)
.logDetail(
`should contain the sort option ${option.label} in the refine modal sort component`
);
});
},
};
}

function sortExpectations(selector: SortSelector) {
return {
displaySort: (display: boolean) => {
selector
.sort()
.should(display ? 'exist' : 'not.exist')
.logDetail(`${should(display)} display the Quantic Sort component`);
},
SimonMilord marked this conversation as resolved.
Show resolved Hide resolved

sortOptionsEqual: (options: {value: string; label: string}[]) => {
options.forEach((option) => {
selector
.sortOption(option.value)
.should('exist')
.should('contain', option.label)
.logDetail(
`should contain the sort option ${option.label} in the sort component`
);
});
},

sortCriteriaInSearchRequest: (value: string) => {
cy.get<Interception>(InterceptAliases.Search)
.then((interception) => {
const body = interception.request.body;
expect(body.sortCriteria).to.equal(value);
})
.logDetail(
'should have the correct sort criteria in the search request'
);
},
};
}

export const RefineContentExpectations = {
...refineContentExpectations(RefineContentSelectors),
...sortExpectations(RefineContentSelectors),
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ import {ComponentSelector, CypressSelector} from '../../common-selectors';
const refineContentComponent = 'c-quantic-refine-modal-content';
const refineContentContainer = '.facets-container';

export interface RefineContentSelector extends FacetSelector {
container: FacetSelector;
sort: () => CypressSelector;
clearAllFiltersButton: () => CypressSelector;
filtersTitle: () => CypressSelector;
}

export interface FacetSelector extends ComponentSelector {
get: () => CypressSelector;
facetManager: () => CypressSelector;
Expand All @@ -28,6 +21,13 @@ export interface FacetSelector extends ComponentSelector {
timeframeFacetValues: () => CypressSelector;
}

export interface SortSelector extends ComponentSelector {
get: () => CypressSelector;
sort: () => CypressSelector;
sortOption: (value: string) => CypressSelector;
sortDropdown: () => CypressSelector;
}

const getCommonFacetSelectors = (
rootSelector: () => CypressSelector
): FacetSelector => {
Expand Down Expand Up @@ -60,12 +60,34 @@ const getCommonFacetSelectors = (
};
};

export interface RefineContentSelector extends FacetSelector, SortSelector {
container: FacetSelector;
clearAllFiltersButton: () => CypressSelector;
filtersTitle: () => CypressSelector;
refineSort: () => CypressSelector;
refineSortDropdown: () => CypressSelector;
refineSortOption: (value: string) => CypressSelector;
}

export const RefineContentSelectors: RefineContentSelector = {
container: getCommonFacetSelectors(() => cy.get(refineContentContainer)),
...getCommonFacetSelectors(() => cy.get(refineContentComponent)),
sort: () => RefineContentSelectors.get().find('c-quantic-sort'),
clearAllFiltersButton: () =>
RefineContentSelectors.get().find('.filters-header lightning-button'),
filtersTitle: () =>
RefineContentSelectors.get().find('[data-cy="filters-title"]'),
refineSort: () => cy.get('c-quantic-refine-modal-content c-quantic-sort'),
refineSortDropdown: () =>
RefineContentSelectors.refineSort().find('[data-cy="sort-dropdown"]'),
refineSortOption: (value: string) =>
RefineContentSelectors.refineSortDropdown().find(
`.slds-listbox__option[data-value="${value}"]`
),
sort: () => cy.get('c-quantic-sort[data-cy="main-sort"]'),
sortDropdown: () =>
RefineContentSelectors.sort().find('[data-cy="sort-dropdown"]'),
sortOption: (value: string) =>
RefineContentSelectors.sortDropdown().find(
`.slds-listbox__option[data-value="${value}"]`
),
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {configure} from '../../../page-objects/configurator';
import {InterceptAliases, interceptSearch} from '../../../page-objects/search';
import {interceptSearch, InterceptAliases} from '../../../page-objects/search';
import {scope} from '../../../reporters/detailed-collector';
import {RefineContentActions as Actions} from './refine-modal-content-actions';
import {RefineContentExpectations as Expect} from './refine-modal-content-expectations';
Expand All @@ -9,6 +9,35 @@ interface RefineContentOptions {
disableDynamicNavigation: boolean;
}

const customSortOptions = [
{
label: 'Date ascending',
value: 'date ascending',
criterion: {
by: 'date',
order: 'ascending',
},
},
{
label: 'Views Descending',
value: '@ytviewcount descending',
criterion: {
by: 'field',
field: 'ytviewcount',
order: 'descending',
},
},
{
label: 'NO SORT',
value: 'nosort',
criterion: {
by: 'nosort',
},
},
];

const defaultCustomOptionValue = 'date ascending';

describe('quantic-refine-content', () => {
const pageUrl = 's/quantic-refine-modal-content';

Expand Down Expand Up @@ -37,7 +66,7 @@ describe('quantic-refine-content', () => {
Expect.displayDuplicatedCategoryFacet();
Expect.displayDuplicatedTimeframeFacet();
Expect.displayDuplicatedDateFacet();
Expect.displaySort(true);
Expect.displayRefineModalSort(true);
Expect.correctFacetsOrder();
});

Expand Down Expand Up @@ -85,7 +114,7 @@ describe('quantic-refine-content', () => {
Actions.clickDuplicatedTimeframeFacetExpandButton();
Expect.displayDuplicatedTimeframeFacetValues();
Expect.displayDuplicatedDateFacet();
Expect.displaySort(false);
Expect.displayRefineModalSort(false);
Expect.correctFacetsOrder();
});
});
Expand All @@ -108,8 +137,35 @@ describe('quantic-refine-content', () => {
Actions.clickDuplicatedTimeframeFacetExpandButton();
Expect.displayDuplicatedTimeframeFacetValues();
Expect.displayDuplicatedDateFacet();
Expect.displaySort(true);
Expect.displayRefineModalSort(true);
});
});
});

describe('when using custom sort options', () => {
it('should render the same custom sort options in the sort component and in the refine modal', () => {
visitRefineContent({});
SimonMilord marked this conversation as resolved.
Show resolved Hide resolved
Expect.sortCriteriaInSearchRequest(defaultCustomOptionValue);

scope(
'when opening the sort options of the quantic sort component',
() => {
Expect.displaySort(true);
Actions.openSortDropdown();

Expect.sortOptionsEqual(customSortOptions);
}
);

scope(
'when opening the sort options of the quantic sort component inside the refine modal',
() => {
Expect.displayRefineModalSort(true);
Actions.openRefineModalSortDropdown();

Expect.refineSortOptionsEqual(customSortOptions);
}
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ function refineToggleSelector(selector: RefineToggleSelector) {
.logDetail(`The view results should contain "${label}"`);
},

displaySort: (display: boolean) => {
selector
.sort()
.should(display ? 'exist' : 'not.exist')
.logDetail(
`${should(
display
)} display the sort component inside the refine modal content`
);
},

displayFacetManager: (display = true) => {
selector
.facetManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface RefineToggleSelector extends ComponentSelector {
modalFooter: () => CypressSelector;
viewResultsButton: () => CypressSelector;
total: () => CypressSelector;
sort: () => CypressSelector;
filtersCountBadge: () => CypressSelector;
timeframeFacetExpandButton: () => CypressSelector;
defaultFacetExpandButton: () => CypressSelector;
Expand Down Expand Up @@ -47,7 +46,6 @@ export const RefineToggleSelectors: RefineToggleSelector = {
viewResultsButton: () =>
RefineToggleSelectors.modalFooter().find('.slds-button'),
total: () => RefineToggleSelectors.get().find('.summary__total'),
sort: () => RefineToggleSelectors.modalContent().find('c-quantic-sort'),
filtersCountBadge: () =>
RefineToggleSelectors.get().find('.refine-button_filters-badge'),
timeframeFacetExpandButton: () =>
Expand Down
Loading
Loading