Skip to content

Commit

Permalink
Merge branch 'KIT-2114-convert-scripts-to-esm' of https://github.com/…
Browse files Browse the repository at this point in the history
…coveo/ui-kit into KIT-2114-add-prerelease
  • Loading branch information
btaillon-coveo committed Nov 22, 2022
2 parents 49021bb + 19a21f4 commit 292a913
Show file tree
Hide file tree
Showing 23 changed files with 297 additions and 138 deletions.
14 changes: 13 additions & 1 deletion packages/headless/src/features/folding/folding-slice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {createReducer} from '@reduxjs/toolkit';
import {Result} from '../../api/search/search/result';
import {isArray} from '../../utils/utils';
import {executeSearch, fetchMoreResults} from '../search/search-actions';
import {
executeSearch,
fetchMoreResults,
fetchPage,
} from '../search/search-actions';
import {loadCollection, registerFolding} from './folding-actions';
import {
FoldedCollection,
Expand Down Expand Up @@ -168,6 +172,14 @@ export const foldingReducer = createReducer(
)
: {};
})
.addCase(fetchPage.fulfilled, (state, {payload}) => {
state.collections = state.enabled
? createCollections(
payload.response.results as ResultWithFolding[],
state.fields
)
: {};
})
.addCase(fetchMoreResults.fulfilled, (state, {payload}) => {
state.collections = state.enabled
? {
Expand Down
6 changes: 3 additions & 3 deletions packages/quantic/cypress/e2e/default-1/pager/pager.cypress.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {performSearch} from '../../../page-objects/actions/action-perform-search';
import {configure} from '../../../page-objects/configurator';
import {
getAlias,
getQueryAlias,
interceptSearch,
interceptSearchIndefinitely,
} from '../../../page-objects/search';
Expand Down Expand Up @@ -32,7 +32,7 @@ describe('quantic-pager', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(options.useCase));
cy.wait(getQueryAlias(options.useCase));
}
}

Expand Down Expand Up @@ -100,7 +100,7 @@ describe('quantic-pager', () => {

scope('when performing a new search query', () => {
performSearch();
cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));
Expect.selectedPageContains(1);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {performSearch} from '../../../page-objects/actions/action-perform-search';
import {configure} from '../../../page-objects/configurator';
import {getAlias, interceptSearch} from '../../../page-objects/search';
import {getQueryAlias, interceptSearch} from '../../../page-objects/search';
import {
useCaseParamTest,
useCaseEnum,
Expand Down Expand Up @@ -38,7 +38,7 @@ describe('quantic-result-per-page', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(options.useCase));
cy.wait(getQueryAlias(options.useCase));
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/quantic/cypress/e2e/default-1/sort/sort.cypress.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {performSearch} from '../../../page-objects/actions/action-perform-search';
import {configure} from '../../../page-objects/configurator';
import {
getAlias,
getQueryAlias,
interceptSearch,
interceptSearchIndefinitely,
} from '../../../page-objects/search';
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('quantic-sort', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(options.useCase));
cy.wait(getQueryAlias(options.useCase));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../../../page-objects/actions/action-set-results-per-page';
import {configure} from '../../../page-objects/configurator';
import {
getAlias,
getQueryAlias,
interceptSearch,
interceptSearchIndefinitely,
mockSearchNoResults,
Expand All @@ -31,7 +31,7 @@ describe('quantic-summary', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(useCase));
cy.wait(getQueryAlias(useCase));
}
}

Expand Down Expand Up @@ -60,7 +60,7 @@ describe('quantic-summary', () => {
it('should work as expected', () => {
visitSummary(param.useCase, false);

cy.wait(getAlias(param.useCase)).then((interception) => {
cy.wait(getQueryAlias(param.useCase)).then((interception) => {
Expect.displaySummary(true);
Expect.displayQuery(false);
Expect.displayRange(true);
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('quantic-summary', () => {
setPageSizeValue(customResultsPerPage);
setResultsPerPage();

cy.wait(getAlias(param.useCase)).then((interception) => {
cy.wait(getQueryAlias(param.useCase)).then((interception) => {
Expect.displaySummary(true);
Expect.displayQuery(false);
Expect.displayRange(true);
Expand All @@ -123,7 +123,7 @@ describe('quantic-summary', () => {

getNextResults();

cy.wait(getAlias(param.useCase)).then((interception) => {
cy.wait(getQueryAlias(param.useCase)).then((interception) => {
Expect.displaySummary(true);
Expect.displayQuery(false);
Expect.displayRange(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {performSearch} from '../../../page-objects/actions/action-perform-search';
import {configure} from '../../../page-objects/configurator';
import {getAlias, interceptSearch} from '../../../page-objects/search';
import {getQueryAlias, interceptSearch} from '../../../page-objects/search';
import {
useCaseParamTest,
useCaseEnum,
Expand Down Expand Up @@ -38,7 +38,7 @@ describe('quantic-tab-bar', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(options.useCase));
cy.wait(getQueryAlias(options.useCase));
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/quantic/cypress/e2e/default-1/tab/tab.cypress.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {performSearch} from '../../../page-objects/actions/action-perform-search';
import {configure} from '../../../page-objects/configurator';
import {
getAlias,
getQueryAlias,
interceptSearch,
mockSearchNoResults,
} from '../../../page-objects/search';
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('quantic-tab', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(options.useCase));
cy.wait(getQueryAlias(options.useCase));
}
}

Expand Down Expand Up @@ -75,7 +75,7 @@ describe('quantic-tab', () => {
it('should not show tabs before search completes', () => {
Expect.displayTabs(false);

cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));
Expect.displayTabs(true);
});

Expand Down Expand Up @@ -111,7 +111,7 @@ describe('quantic-tab', () => {

mockSearchNoResults(param.useCase);
performSearch();
cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));
Expect.displayTabs(true);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getAlias} from '../../../page-objects/search';
import {getQueryAlias} from '../../../page-objects/search';
import {should} from '../../common-selectors';
import {EventExpectations} from '../../event-expectations';
import {ResultListSelector, ResultListSelectors} from './result-list-selectors';
Expand Down Expand Up @@ -34,7 +34,7 @@ function resultListExpectations(selector: ResultListSelector) {
});
},
requestFields: (expectedFieldsToInclude: string[], useCase: string) => {
cy.wait(getAlias(useCase))
cy.wait(getQueryAlias(useCase))
.then((interception) => {
const fieldsToInclude = interception.request.body.fieldsToInclude;
expectedFieldsToInclude.forEach((field) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {performSearch} from '../../../page-objects/actions/action-perform-search
import {configure} from '../../../page-objects/configurator';
import {
extractResults,
getAlias,
getQueryAlias,
interceptSearch,
interceptSearchIndefinitely,
} from '../../../page-objects/search';
Expand Down Expand Up @@ -46,7 +46,7 @@ describe('quantic-resultlist', () => {
}

function aliasResultValues(useCase: string) {
cy.wait(getAlias(useCase)).then((interception) => {
cy.wait(getQueryAlias(useCase)).then((interception) => {
const results = extractResults(interception.response);
cy.wrap(results).as(indexResultsAlias.substring(1));
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {performSearch} from '../../../page-objects/actions/action-perform-search';
import {configure} from '../../../page-objects/configurator';
import {
getAlias,
getQueryAlias,
InterceptAliases,
interceptSearch,
} from '../../../page-objects/search';
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('quantic-category-facet', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(options.useCase));
cy.wait(getQueryAlias(options.useCase));
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ describe('quantic-category-facet', () => {

function setupShowLess(useCase: string) {
setupShowMore(useCase);
cy.wait(getAlias(useCase));
cy.wait(getQueryAlias(useCase));
Actions.clickShowLessButton();
}

Expand Down Expand Up @@ -441,7 +441,7 @@ describe('quantic-category-facet', () => {
},
false
);
cy.wait(getAlias(param.useCase)).then((interception) => {
cy.wait(getQueryAlias(param.useCase)).then((interception) => {
const facetRequest = interception.request.body.facets[0];
expect(facetRequest.sortCriteria).to.eq(sorting);
});
Expand Down
16 changes: 8 additions & 8 deletions packages/quantic/cypress/e2e/facets-1/facet/facet.cypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {performSearch} from '../../../page-objects/actions/action-perform-search
import {configure} from '../../../page-objects/configurator';
import {
extractFacetValues,
getAlias,
getQueryAlias,
InterceptAliases,
interceptSearch,
interceptSearchIndefinitely,
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('Facet Test Suite', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(options.useCase));
cy.wait(getQueryAlias(options.useCase));
}
}

Expand All @@ -68,7 +68,7 @@ describe('Facet Test Suite', () => {
}

function aliasFacetValues(useCase: string) {
cy.wait(getAlias(useCase)).then((interception) => {
cy.wait(getQueryAlias(useCase)).then((interception) => {
const indexValues = extractFacetValues(interception.response);
cy.wrap(indexValues).as(indexFacetValuesAlias.substring(1));
});
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('Facet Test Suite', () => {

function collapseFacet() {
Actions.clickCollapseButton();
cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));
}

selectFirstFacetValue();
Expand All @@ -211,7 +211,7 @@ describe('Facet Test Suite', () => {
function clearSelectedValues() {
Actions.clickExpandButton();
Actions.clickClearFilter();
cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));
}
clearSelectedValues();

Expand Down Expand Up @@ -492,7 +492,7 @@ describe('Facet Test Suite', () => {
function clearSelectedValues() {
Actions.clickExpandButton();
Actions.clickClearFilter();
cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));
}

clearSelectedValues();
Expand Down Expand Up @@ -706,7 +706,7 @@ describe('Facet Test Suite', () => {
scope('when clicking show less button', () => {
function showLessValues() {
showMoreValuesAgain();
cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));
Actions.clickShowLessButton();
}

Expand Down Expand Up @@ -779,7 +779,7 @@ describe('Facet Test Suite', () => {
},
false
);
cy.wait(getAlias(param.useCase)).then((interception) => {
cy.wait(getQueryAlias(param.useCase)).then((interception) => {
const facetRequest = interception.request.body.facets[0];
expect(facetRequest.sortCriteria).to.eq(sorting);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {performSearch} from '../../../page-objects/actions/action-perform-search';
import {configure, reset} from '../../../page-objects/configurator';
import {
getAlias,
getQueryAlias,
InterceptAliases,
interceptSearch,
} from '../../../page-objects/search';
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('quantic-breadcrumb-manager', () => {
performSearch();
}
if (waitForSearch) {
cy.wait(getAlias(options.useCase));
cy.wait(getQueryAlias(options.useCase));
}
}

Expand Down Expand Up @@ -199,10 +199,10 @@ describe('quantic-breadcrumb-manager', () => {
Expect.facetBreadcrumb.numberOfValues(1);

Actions.facet.clickShowMoreButton();
cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));

Actions.facet.selectLastLinkValue();
cy.wait(getAlias(param.useCase));
cy.wait(getQueryAlias(param.useCase));

Expect.facetBreadcrumb.numberOfValues(1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Interception} from 'cypress/types/net-stubbing';
import {performSearch} from '../../../page-objects/actions/action-perform-search';
import {configure} from '../../../page-objects/configurator';
import {
getAlias,
getQueryAlias,
getRoute,
interceptSearch,
} from '../../../page-objects/search';
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('quantic-facet-manager', () => {
res.body.facets = reordered;
res.send();
});
}).as(getAlias(useCase).substring(1));
}).as(getQueryAlias(useCase).substring(1));
}

function getFacetOrder(interception: Interception) {
Expand All @@ -66,15 +66,15 @@ describe('quantic-facet-manager', () => {
describe(param.label, () => {
it('should load facets in the same order as in the search response', () => {
visit({useCase: param.useCase});
cy.wait(getAlias(param.useCase)).then((interception) =>
cy.wait(getQueryAlias(param.useCase)).then((interception) =>
getFacetOrder(interception)
);
Expect.containsFacets(responseFacetIdsAlias);

scope('when reordering the facets', () => {
mockFacetOrder(['language', 'objecttype', 'date'], param.useCase);
performSearch()
.wait(getAlias(param.useCase))
.wait(getQueryAlias(param.useCase))
.then((interception) => getFacetOrder(interception));
Expect.containsFacets(responseFacetIdsAlias);
});
Expand Down
Loading

0 comments on commit 292a913

Please sign in to comment.