diff --git a/src/translations/index.ts b/src/translations/index.ts index 99ec6c070..d81ca772d 100644 --- a/src/translations/index.ts +++ b/src/translations/index.ts @@ -198,6 +198,8 @@ export namespace TranslationsModel { translateUntranslatedOnly?: boolean; translateWithPerfectMatchOnly?: boolean; markAddedTranslationsAsDone?: boolean; + labelIds?: number[]; + excludeLabelIds?: number[]; } export interface BuildProjectDirectoryTranslationRequest { @@ -241,6 +243,8 @@ export namespace TranslationsModel { duplicateTranslations: boolean; translateUntranslatedOnly: boolean; translateWithPerfectMatchOnly: boolean; + labelIds?: number[]; + excludeLabelIds?: number[]; } export type Method = 'tm' | 'mt'; diff --git a/tests/translations/api.test.ts b/tests/translations/api.test.ts index f842cef27..80830eadc 100644 --- a/tests/translations/api.test.ts +++ b/tests/translations/api.test.ts @@ -18,6 +18,8 @@ describe('Translations API', () => { const directoryId = 61; const progress = 50; const languageId = 'uk'; + const sampleLabelIds = [101, 102]; + const sampleExcludeLabelIds = [103, 104]; const limit = 25; @@ -175,6 +177,29 @@ describe('Translations API', () => { data: { url: url, }, + }) + .post( + `/projects/${projectId}/pre-translations`, + { + languageIds: [], + fileIds: [], + labelIds: sampleLabelIds, + excludeLabelIds: sampleExcludeLabelIds, + }, + { + reqheaders: { + Authorization: `Bearer ${api.token}`, + }, + }, + ) + .reply(200, { + data: { + identifier: preTranslationId, + attributes: { + labelIds: sampleLabelIds, + excludeLabelIds: sampleExcludeLabelIds, + }, + }, }); }); @@ -190,6 +215,18 @@ describe('Translations API', () => { expect(preTranslation.data.identifier).toBe(preTranslationId); }); + it('Apply Pre-Translation with Label Filters', async () => { + const preTranslation = await api.applyPreTranslation(projectId, { + fileIds: [], + languageIds: [], + labelIds: sampleLabelIds, + excludeLabelIds: sampleExcludeLabelIds, + }); + expect(preTranslation.data.identifier).toBe(preTranslationId); + expect(preTranslation.data.attributes.labelIds).toEqual(sampleLabelIds); + expect(preTranslation.data.attributes.excludeLabelIds).toEqual(sampleExcludeLabelIds); + }); + it('Pre-translation status', async () => { const preTranslation = await api.preTranslationStatus(projectId, preTranslationId); expect(preTranslation.data.identifier).toBe(preTranslationId);