Skip to content

Commit

Permalink
Merge branch 'master' into SFINT-5847
Browse files Browse the repository at this point in the history
  • Loading branch information
mmitiche authored Dec 18, 2024
2 parents fd83882 + 5411883 commit 8919091
Show file tree
Hide file tree
Showing 33 changed files with 2,502 additions and 1,642 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
with:
egress-policy: audit

- uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # v4.3.0
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
3,434 changes: 1,981 additions & 1,453 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"@coveo/release": "1.0.0",
"@cspell/dict-fr-fr": "2.2.5",
"@cspell/eslint-plugin": "8.16.0",
"@nx/js": "19.8.11",
"@nx/storybook": "19.8.11",
"@nx/vite": "19.8.11",
"@nx/web": "19.8.11",
"@nx/js": "20.2.1",
"@nx/storybook": "20.2.1",
"@nx/vite": "20.2.1",
"@nx/web": "20.2.1",
"@octokit/rest": "21.0.2",
"@rollup/plugin-typescript": "11.1.6",
"@storybook/addon-essentials": "8.1.11",
Expand All @@ -52,7 +52,7 @@
"@swc-node/register": "~1.10.0",
"@swc/core": "~1.9.0",
"@swc/helpers": "~0.5.2",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@trivago/prettier-plugin-sort-imports": "5.2.0",
"@tsconfig/node20": "20.1.4",
"@types/execa": "^2.0.0",
"@types/jest": "29.5.14",
Expand Down Expand Up @@ -92,7 +92,7 @@
"ts-node": "10.9.2",
"tslib": "^2.3.0",
"typescript": "5.4.5",
"vite": "~5.4.0"
"vite": "5.4.1"
},
"overrides": {
"@coveo/release": {
Expand Down
14 changes: 7 additions & 7 deletions packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"dompurify": "3.2.0",
"escape-html": "1.0.3",
"focus-visible": "5.2.1",
"i18next": "23.16.8",
"i18next-http-backend": "2.7.1",
"i18next": "24.0.5",
"i18next-http-backend": "3.0.1",
"marked": "12.0.2",
"stencil-inline-svg": "1.1.0",
"ts-debounce": "^4.0.0"
Expand All @@ -86,10 +86,10 @@
"@coveo/atomic-storybook-utils": "file:./storybookUtils",
"@coveo/release": "1.0.0",
"@custom-elements-manifest/analyzer": "0.10.3",
"@nx/js": "19.8.11",
"@nx/storybook": "19.8.11",
"@nx/vite": "19.8.11",
"@nx/web": "19.8.11",
"@nx/js": "20.2.1",
"@nx/storybook": "20.2.1",
"@nx/vite": "20.2.1",
"@nx/web": "20.2.1",
"@playwright/test": "1.49.0",
"@rollup/plugin-alias": "5.1.1",
"@rollup/plugin-replace": "6.0.1",
Expand Down Expand Up @@ -153,7 +153,7 @@
"ts-node": "10.9.2",
"tslib": "^2.3.0",
"typescript": "5.5.4",
"vite": "5.4.11",
"vite": "5.4.1",
"vite-plugin-cem": "0.8.1",
"wait-on": "8.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {wrapInCommerceInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper';
import {wrapInCommerceProductList} from '@coveo/atomic-storybook-utils/commerce/commerce-product-list-wrapper';
import {wrapInProductTemplate} from '@coveo/atomic-storybook-utils/commerce/commerce-product-template-wrapper';
import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters';
import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component';
import type {Meta, StoryObj as Story} from '@storybook/web-components';

const {
decorator: commerceInterfaceDecorator,
play: initializeCommerceInterface,
} = wrapInCommerceInterface({
skipFirstSearch: false,
type: 'product-listing',
engineConfig: {
context: {
view: {
url: 'https://sports.barca.group/browse/promotions/ui-kit-testing',
},
language: 'en',
country: 'US',
currency: 'USD',
},
},
});
const {decorator: commerceProductListDecorator} = wrapInCommerceProductList();
const {decorator: productTemplateDecorator} = wrapInProductTemplate();

const meta: Meta = {
component: 'atomic-product-numeric-field-value',
title: 'Atomic-Commerce/Product Template Components/ProductNumericFieldValue',
id: 'atomic-product-numeric-field-value',
render: renderComponent,
decorators: [
productTemplateDecorator,
commerceProductListDecorator,
commerceInterfaceDecorator,
],
parameters,
play: initializeCommerceInterface,
args: {
'attributes-field': 'ec_rating',
},
argTypes: {
'attributes-field': {
name: 'field',
type: 'string',
},
},
};

export default meta;

export const Default: Story = {
name: 'atomic-product-numeric-field-value',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {test, expect} from './fixture';

test.describe('atomic-product-numeric-field-value', () => {
test.beforeEach(async ({numericFieldValue}) => {
await numericFieldValue.load();
await numericFieldValue.hydrated.first().waitFor({state: 'visible'});
});

test('should be a11y compliant', async ({
numericFieldValue,
makeAxeBuilder,
}) => {
await numericFieldValue.hydrated.first().waitFor();
const accessibilityResults = await makeAxeBuilder().analyze();
expect(accessibilityResults.violations).toEqual([]);
});

test('should render the value', async ({numericFieldValue}) => {
const value = numericFieldValue.value.first();
await expect(value).toBeVisible();
});

test('should apply custom formatter', async ({page}) => {
const element = page.locator('atomic-product-numeric-field-value').first();

await element.evaluate((el) => {
const event = new CustomEvent('atomic/numberFormat', {
detail: (value: number) => `Formatted: ${value}`,
});
el.dispatchEvent(event);
});

const textContent = await element.textContent();
expect(textContent).toContain('Formatted:');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {test as base} from '@playwright/test';
import {
AxeFixture,
makeAxeBuilder,
} from '../../../../../../playwright-utils/base-fixture';
import {NumericFieldValuePageObject} from './page-object';

type MyFixtures = {
numericFieldValue: NumericFieldValuePageObject;
};

export const test = base.extend<MyFixtures & AxeFixture>({
makeAxeBuilder,
numericFieldValue: async ({page}, use) => {
await use(new NumericFieldValuePageObject(page));
},
});

export {expect} from '@playwright/test';
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type {Page} from '@playwright/test';
import {BasePageObject} from '../../../../../../playwright-utils/base-page-object';

export class NumericFieldValuePageObject extends BasePageObject<'atomic-product-numeric-field-value'> {
constructor(page: Page) {
super(page, 'atomic-product-numeric-field-value');
}

get value() {
return this.page.locator('atomic-product-numeric-field-value');
}
}
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"devDependencies": {
"@coveo/release": "1.0.0",
"rimraf": "6.0.1",
"vite": "5.4.11",
"vite": "5.4.1",
"jest": "29.7.0",
"ts-jest": "29.2.5"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/headless-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
"@testing-library/react": "14.3.1",
"@typescript-eslint/eslint-plugin": "7.17.0",
"eslint-plugin-react": "7.35.0",
"eslint-plugin-testing-library": "6.5.0",
"eslint-plugin-testing-library": "7.1.1",
"gts": "5.3.1",
"publint": "0.2.12",
"rimraf": "6.0.1",
"typescript": "5.4.5",
"vitest": "2.1.5"
"vitest": "2.1.8"
},
"peerDependencies": {
"react": "^18",
Expand Down
30 changes: 28 additions & 2 deletions packages/headless-react/src/ssr-commerce/commerce-engine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
defineCommerceEngine as defineBaseCommerceEngine,
CommerceEngineOptions,
SolutionType,
CommerceEngine,
} from '@coveo/headless/ssr-commerce';
// Workaround to prevent Next.js erroring about importing CSR only hooks
import React from 'react';
Expand All @@ -15,7 +16,11 @@ import {
buildHydratedStateProvider,
buildStaticStateProvider,
} from './common.js';
import {ContextState, ReactEngineDefinition} from './types.js';
import {
ContextState,
InferControllerHooksMapFromDefinition,
ReactEngineDefinition,
} from './types.js';

export type ReactCommerceEngineDefinition<
TControllers extends ControllerDefinitionsMap<Controller>,
Expand All @@ -38,7 +43,28 @@ export function createSingletonContext<
*/
export function defineCommerceEngine<
TControllers extends ControllerDefinitionsMap<Controller>,
>(options: CommerceEngineDefinitionOptions<TControllers>) {
>(
options: CommerceEngineDefinitionOptions<TControllers>
): {
useEngine: () => CommerceEngine | undefined;
controllers: InferControllerHooksMapFromDefinition<TControllers>;
listingEngineDefinition: ReactCommerceEngineDefinition<
TControllers,
SolutionType.listing
>;
searchEngineDefinition: ReactCommerceEngineDefinition<
TControllers,
SolutionType.search
>;
standaloneEngineDefinition: ReactCommerceEngineDefinition<
TControllers,
SolutionType.standalone
>;
recommendationEngineDefinition: ReactCommerceEngineDefinition<
TControllers,
SolutionType.recommendation
>;
} {
const singletonContext = createSingletonContext<TControllers>();

type ContextStateType<TSolutionType extends SolutionType> = SingletonGetter<
Expand Down
Loading

0 comments on commit 8919091

Please sign in to comment.