Skip to content

Commit

Permalink
Merge branch 'master' into KIT-2541
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprudhomme authored Sep 5, 2024
2 parents f4c052f + 7163f6a commit 1235c25
Show file tree
Hide file tree
Showing 49 changed files with 537 additions and 297 deletions.
1 change: 0 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"behaviour",
"bloup",
"bpsb",
"btoashim",
"CAPI",
"cfcomment",
"cfpage",
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/e2e-atomic-screenshots/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ inputs:
runs:
using: composite
steps:
- run: npx cypress install
shell: bash
- uses: cypress-io/github-action@v5
name: Run Cypress
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/e2e-atomic/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ inputs:
runs:
using: composite
steps:
- run: npx cypress install
shell: bash
- uses: cypress-io/github-action@v5
name: Run Cypress
with:
Expand Down
71 changes: 40 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/atomic-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@angular/cli": "17.3.9",
"@angular/compiler-cli": "17.3.12",
"@coveo/headless": "2.80.0",
"@types/jasmine": "5.1.4",
"@types/node": "20.14.12",
"jasmine-core": "5.2.0",
"karma": "6.4.3",
Expand Down
7 changes: 4 additions & 3 deletions packages/atomic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
"@coveo/atomic": "2.78.0"
},
"devDependencies": {
"@coveo/release": "1.0.0",
"@coveo/headless": "2.80.0",
"@coveo/release": "1.0.0",
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-replace": "^5.0.0",
"@rollup/plugin-terser": "0.4.4",
"@rollup/plugin-typescript": "^11.0.0",
"@types/node": "20.14.12",
"@types/react": "18.3.3",
Expand All @@ -45,8 +47,7 @@
"react": "18.3.1",
"react-dom": "18.3.1",
"rollup": "3.29.4",
"rollup-plugin-polyfill-node": "^0.13.0",
"@rollup/plugin-terser": "0.4.4"
"rollup-plugin-polyfill-node": "^0.13.0"
},
"peerDependencies": {
"@coveo/headless": "2.80.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/atomic-react/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
Expand Down Expand Up @@ -54,6 +55,7 @@ const outputIIFECommerce = ({minify}) => ({
});

const plugins = [
json(),
nodePolyfills(),
typescript({tsconfig: 'tsconfig.iife.json'}),
commonjs(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import {buildInteractiveResult, TestUtils} from '@coveo/headless';
import {
buildInteractiveResult,
buildSearchEngine,
Result,
} from '@coveo/headless';
import {h} from '@stencil/core';
import {newSpecPage, SpecPage} from '@stencil/core/testing';
import {MissingParentError} from '../../common/item-list/item-decorators';
Expand Down Expand Up @@ -54,18 +58,21 @@ describe('resultContext method', () => {
});

it("revolves the bindings when it's a child of an atomic-result element", async () => {
const mockEngine = TestUtils.buildMockSearchEngine(
TestUtils.createMockState()
);
const mockResult = TestUtils.buildMockResult();
const engine = buildSearchEngine({
configuration: {
accessToken: 'accessToken',
organizationId: 'organizationId',
},
});
const mockResult = jest.mocked({} as Result);

const page = await newSpecPage({
components: [AtomicResult],
template: () => (
<atomic-result
content={document.createElement('div')}
result={TestUtils.buildMockResult()}
interactiveResult={buildInteractiveResult(mockEngine, {
result={mockResult}
interactiveResult={buildInteractiveResult(engine, {
options: {result: mockResult},
})}
store={createAtomicStore()}
Expand Down
16 changes: 13 additions & 3 deletions packages/atomic/src/utils/initialization-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {buildSearchBox, Controller, TestUtils} from '@coveo/headless';
import {buildSearchBox, buildSearchEngine, Controller} from '@coveo/headless';
import {newSpecPage, SpecPage} from '@stencil/core/testing';
import i18next from 'i18next';
import {AtomicSearchBox} from '../components/search/atomic-search-box/atomic-search-box';
Expand Down Expand Up @@ -105,7 +105,12 @@ describe('InitializeBindings decorator', () => {
it(`when "engine" is defined
should render the content `, () => {
component['bindings'] = {
engine: TestUtils.buildMockSearchEngine(TestUtils.createMockState()),
engine: buildSearchEngine({
configuration: {
accessToken: 'accessToken',
organizationId: 'organizationId',
},
}),
i18n: i18next,
store: createAtomicStore(),
interfaceElement: document.createElement('atomic-search-interface'),
Expand All @@ -127,7 +132,12 @@ describe('BindStateToController decorator', () => {
console.error = jest.fn();
component = {
bindings: {
engine: TestUtils.buildMockSearchEngine(TestUtils.createMockState()),
engine: buildSearchEngine({
configuration: {
accessToken: 'accessToken',
organizationId: 'organizationId',
},
}),
i18n: i18next,
store: createAtomicStore(),
interfaceElement: document.createElement('atomic-search-interface'),
Expand Down
25 changes: 12 additions & 13 deletions packages/atomic/src/utils/result-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import {
buildSearchEngine,
getSampleSearchEngineConfiguration,
Raw,
Result,
} from '@coveo/headless';
import {TestUtils} from '@coveo/headless';
import {Bindings} from '../components/search/atomic-search-interface/atomic-search-interface';
import {buildStringTemplateFromResult} from './result-utils';

describe('buildStringTemplateFromResult', () => {
const mockRaw = jest.mocked({source: 'the source'} as Raw);
const mockResult = jest.mocked({
title: 'foo',
uri: 'http://uri.foo.com',
raw: mockRaw,
} as Result);
const engine = buildSearchEngine({
configuration: getSampleSearchEngineConfiguration(),
});
const bindings = {engine} as Bindings;
const result = TestUtils.buildMockResult({
title: 'foo',
uri: 'http://uri.foo.com',
raw: {
...TestUtils.buildMockResult().raw,
source: 'the source',
},
});

it('should create string templates', () => {
const templates = [
Expand All @@ -30,9 +29,9 @@ describe('buildStringTemplateFromResult', () => {
];

templates.forEach((template) =>
expect(buildStringTemplateFromResult(template.in, result, bindings)).toBe(
template.out
)
expect(
buildStringTemplateFromResult(template.in, mockResult, bindings)
).toBe(template.out)
);
});

Expand All @@ -41,7 +40,7 @@ describe('buildStringTemplateFromResult', () => {
expect(
buildStringTemplateFromResult(
'${title}/${raw.notafield}',
result,
mockResult,
bindings
)
).toBe('foo/');
Expand Down
3 changes: 1 addition & 2 deletions packages/headless-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
"publint": "0.2.9",
"rimraf": "5.0.9",
"ts-jest": "29.2.3",
"typescript": "5.4.5",
"undici": "5.28.4"
"typescript": "5.4.5"
},
"peerDependencies": {
"react": "^18",
Expand Down
Loading

0 comments on commit 1235c25

Please sign in to comment.