Skip to content

Commit 6624759

Browse files
damcoumillotp
andauthored
feat(specs): add CustomFields to CT Source Input (#2742)
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
1 parent 72bcc2c commit 6624759

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ jobs:
286286
key: node-modules-tests-${{ env.CACHE_VERSION }}-${{ hashFiles('tests/output/javascript/yarn.lock') }}
287287

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

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

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

377377
- name: Generate code snippets for documentation
378378
run: yarn cli snippets ${{ matrix.client.language }} ${{ matrix.client.toRun }}

scripts/cli/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,17 @@ ctsCommand
124124
.command('run')
125125
.description('Run the tests for the CTS')
126126
.addArgument(args.language)
127+
.addArgument(args.clients)
127128
.option(flags.verbose.flag, flags.verbose.description)
128-
.action(async (langArg: LangArg, { verbose }) => {
129-
const { language } = transformSelection({
129+
.action(async (langArg: LangArg, clientArg: string[], { verbose }) => {
130+
const { language, clientList } = transformSelection({
130131
langArg,
131-
clientArg: [ALL],
132+
clientArg,
132133
});
133134

134135
setVerbose(Boolean(verbose));
135136

136-
await runCts(language === ALL ? LANGUAGES : [language]);
137+
await runCts(language === ALL ? LANGUAGES : [language], clientList);
137138
});
138139

139140
ctsCommand

scripts/cts/runCts.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as fsp from 'fs/promises';
22

33
import { run, runComposerInstall, toAbsolutePath } from '../common.js';
44
import { createSpinner } from '../spinners.js';
5+
import type { Language } from '../types.js';
56

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

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

73-
export async function runCts(languages: string[]): Promise<void> {
74-
const close = await startTestServer();
75-
74+
// 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.
75+
export async function runCts(languages: Language[], clients: string[]): Promise<void> {
76+
const useTestServer = clients.includes('search');
77+
let close: () => Promise<void> = async () => {};
78+
if (useTestServer) {
79+
close = await startTestServer();
80+
}
7681
for (const lang of languages) {
7782
await runCtsOne(lang);
7883
}
7984

80-
await close();
85+
if (useTestServer) {
86+
await close();
8187

82-
if (languages.length !== getTimeoutCounter()) {
83-
throw new Error(`Expected ${languages.length} timeout(s), got ${getTimeoutCounter()} instead.`);
88+
if (languages.length !== getTimeoutCounter()) {
89+
throw new Error(
90+
`Expected ${languages.length} timeout(s), got ${getTimeoutCounter()} instead.`
91+
);
92+
}
8493
}
8594
}

specs/ingestion/common/schemas/source.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,35 @@ SourceCommercetools:
120120
default: true
121121
description: >
122122
Determines the value that will be stored in the Algolia record if there's no inventory information on the product.
123+
customFields:
124+
$ref: '#/CommercetoolsCustomFields'
123125
required:
124126
- url
125127
- projectKey
126128
x-discriminator-fields:
127129
- projectKey
128130

131+
CommercetoolsCustomFields:
132+
type: object
133+
additionalProperties: false
134+
description: Custom fields from Commercetools to index in the records (see https://docs.commercetools.com/tutorials/custom-types).
135+
properties:
136+
inventory:
137+
type: array
138+
items:
139+
type: string
140+
description: Inventory custom fields.
141+
price:
142+
type: array
143+
items:
144+
type: string
145+
description: Price custom fields.
146+
category:
147+
type: array
148+
items:
149+
type: string
150+
description: Category custom fields.
151+
129152
SourceBigCommerce:
130153
type: object
131154
additionalProperties: false
@@ -347,6 +370,8 @@ SourceUpdateCommercetools:
347370
Array of locales that must match the following pattern: ^[a-z]{2}(-[A-Z]{2})?$. For example ["fr-FR", "en"].
348371
items:
349372
type: string
373+
customFields:
374+
$ref: '#/CommercetoolsCustomFields'
350375

351376
SourceUpdateInput:
352377
oneOf:

0 commit comments

Comments
 (0)