Skip to content

Commit

Permalink
feat(specs): add CustomFields to CT Source Input (#2742)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
damcou and millotp committed Feb 20, 2024
1 parent 72bcc2c commit 6624759
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ jobs:
key: node-modules-tests-${{ env.CACHE_VERSION }}-${{ hashFiles('tests/output/javascript/yarn.lock') }}

- name: Run CTS
run: yarn cli cts run javascript
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}

- name: Generate code snippets for documentation
run: yarn cli snippets javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
Expand Down Expand Up @@ -372,7 +372,7 @@ jobs:
run: yarn cli cts generate ${{ matrix.client.language }} ${{ matrix.client.toRun }}

- name: Run CTS
run: yarn cli cts run ${{ matrix.client.language }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }}

- name: Generate code snippets for documentation
run: yarn cli snippets ${{ matrix.client.language }} ${{ matrix.client.toRun }}
Expand Down
9 changes: 5 additions & 4 deletions scripts/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ ctsCommand
.command('run')
.description('Run the tests for the CTS')
.addArgument(args.language)
.addArgument(args.clients)
.option(flags.verbose.flag, flags.verbose.description)
.action(async (langArg: LangArg, { verbose }) => {
const { language } = transformSelection({
.action(async (langArg: LangArg, clientArg: string[], { verbose }) => {
const { language, clientList } = transformSelection({
langArg,
clientArg: [ALL],
clientArg,
});

setVerbose(Boolean(verbose));

await runCts(language === ALL ? LANGUAGES : [language]);
await runCts(language === ALL ? LANGUAGES : [language], clientList);
});

ctsCommand
Expand Down
21 changes: 15 additions & 6 deletions scripts/cts/runCts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fsp from 'fs/promises';

import { run, runComposerInstall, toAbsolutePath } from '../common.js';
import { createSpinner } from '../spinners.js';
import type { Language } from '../types.js';

import { getTimeoutCounter, startTestServer } from './testServer.js';

Expand Down Expand Up @@ -70,16 +71,24 @@ async function runCtsOne(language: string): Promise<void> {
spinner.succeed();
}

export async function runCts(languages: string[]): Promise<void> {
const close = await startTestServer();

// the clients option is only used to determine if we need to start the test server, it will run the tests for all clients anyway.
export async function runCts(languages: Language[], clients: string[]): Promise<void> {
const useTestServer = clients.includes('search');
let close: () => Promise<void> = async () => {};
if (useTestServer) {
close = await startTestServer();
}
for (const lang of languages) {
await runCtsOne(lang);
}

await close();
if (useTestServer) {
await close();

if (languages.length !== getTimeoutCounter()) {
throw new Error(`Expected ${languages.length} timeout(s), got ${getTimeoutCounter()} instead.`);
if (languages.length !== getTimeoutCounter()) {
throw new Error(
`Expected ${languages.length} timeout(s), got ${getTimeoutCounter()} instead.`
);
}
}
}
25 changes: 25 additions & 0 deletions specs/ingestion/common/schemas/source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,35 @@ SourceCommercetools:
default: true
description: >
Determines the value that will be stored in the Algolia record if there's no inventory information on the product.
customFields:
$ref: '#/CommercetoolsCustomFields'
required:
- url
- projectKey
x-discriminator-fields:
- projectKey

CommercetoolsCustomFields:
type: object
additionalProperties: false
description: Custom fields from Commercetools to index in the records (see https://docs.commercetools.com/tutorials/custom-types).
properties:
inventory:
type: array
items:
type: string
description: Inventory custom fields.
price:
type: array
items:
type: string
description: Price custom fields.
category:
type: array
items:
type: string
description: Category custom fields.

SourceBigCommerce:
type: object
additionalProperties: false
Expand Down Expand Up @@ -347,6 +370,8 @@ SourceUpdateCommercetools:
Array of locales that must match the following pattern: ^[a-z]{2}(-[A-Z]{2})?$. For example ["fr-FR", "en"].
items:
type: string
customFields:
$ref: '#/CommercetoolsCustomFields'

SourceUpdateInput:
oneOf:
Expand Down

0 comments on commit 6624759

Please sign in to comment.