From 4a17e357721135b04154998ac7369a129785f6ab Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 5 Oct 2023 16:08:37 +0000 Subject: [PATCH 1/3] Added labelIds & excludedLabelIds to PreTranslationRequest --- src/translations/index.ts | 4 ++++ 1 file changed, 4 insertions(+) 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'; From 64e73b036cd073ae346318165e82e88bd9b77288 Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 5 Oct 2023 16:47:31 +0000 Subject: [PATCH 2/3] Test added for labelIds & excludedLabelIds --- tests/translations/api.test.ts | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/translations/api.test.ts b/tests/translations/api.test.ts index f842cef27..2014f80e2 100644 --- a/tests/translations/api.test.ts +++ b/tests/translations/api.test.ts @@ -18,6 +18,9 @@ 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 +178,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 +216,19 @@ 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); From 023a7addadb2c62a4539ad10b4c8c0e67895f086 Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 6 Oct 2023 14:18:27 +0000 Subject: [PATCH 3/3] prettier --- tests/translations/api.test.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/translations/api.test.ts b/tests/translations/api.test.ts index 2014f80e2..80830eadc 100644 --- a/tests/translations/api.test.ts +++ b/tests/translations/api.test.ts @@ -21,7 +21,6 @@ describe('Translations API', () => { const sampleLabelIds = [101, 102]; const sampleExcludeLabelIds = [103, 104]; - const limit = 25; beforeAll(() => { @@ -199,8 +198,8 @@ describe('Translations API', () => { attributes: { labelIds: sampleLabelIds, excludeLabelIds: sampleExcludeLabelIds, - } - } + }, + }, }); }); @@ -224,10 +223,9 @@ describe('Translations API', () => { excludeLabelIds: sampleExcludeLabelIds, }); expect(preTranslation.data.identifier).toBe(preTranslationId); - expect(preTranslation.data.attributes.labelIds).toEqual(sampleLabelIds); - expect(preTranslation.data.attributes.excludeLabelIds).toEqual(sampleExcludeLabelIds); + 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);