Skip to content

Commit

Permalink
Add test to avoid empty drop creation
Browse files Browse the repository at this point in the history
Given a repository in which only some (but not all) locales are fully translated, when drop export is triggered specifying only locales which are fully translated, drop should not be created (because it would be empty).

This is a test for fix 88f3b06.
  • Loading branch information
wadimw committed Nov 17, 2023
1 parent f5908a5 commit fb3dfbe
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,38 @@ public void exportFullyTranslated() throws Exception {
assertEquals("A Drop should not have been added", findAllBefore.getTotalElements(), findAllAfter.getTotalElements());
}

@Test
public void exportSelectFullyTranslatedLocales() throws Exception {

Repository repository = createTestRepoUsingRepoService();

getL10nJCommander().run("push", "-r", repository.getName(),
"-s", getInputResourcesTestDir("source").getAbsolutePath());

Asset asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId());
importTranslations(asset.getId(), "source-xliff_", "fr-FR");
// do NOT import translations for ja-JP

waitForCondition("Must have text units that are fully translated", () -> {
RepositoryStatistic repositoryStatistic = repositoryRepository.findOne(repository.getId()).getRepositoryStatistic();
return repositoryStatistic.getUsedTextUnitCount() > 0
&& repositoryStatistic.getRepositoryLocaleStatistics().stream()
.filter(rls -> Sets.newHashSet("fr-FR").contains(rls.getLocale().getBcp47Tag()))
.allMatch(rls -> rls.getForTranslationCount() == 0);
});

Page<Drop> findAllBefore = dropClient.getDrops(repository.getId(), null, null, null);

// export only fr-FR which is fully translated
getL10nJCommander().run("drop-export", "-r", repository.getName(), "-l", "fr-FR");

Page<Drop> findAllAfter = dropClient.getDrops(repository.getId(), null, null, null);

// drop should not be created because it consists only of fully translated locales,
// even though repository as a whole is not fully translated (ja-JP is not translated)
assertEquals("A Drop should not have been added", findAllBefore.getTotalElements(), findAllAfter.getTotalElements());
}

@Test
public void exportReviewWithInheritance() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0">
<file original="" source-language="en" datatype="x-undefined">
<body>
<trans-unit id="" resname="100_character_description_" datatype="php">
<source>100 character description:</source>
</trans-unit>
<trans-unit id="" resname="15_min_duration" datatype="x-javascript+php">
<source>15 min</source>
<note>File lock dialog duration</note>
</trans-unit>
<trans-unit id="" resname="1_day_duration" datatype="x-javascript+php">
<source>1 day</source>
<note>File lock dialog duration</note>
</trans-unit>
<trans-unit id="" resname="1_hour_duration" datatype="x-javascript+php">
<source>1 hour</source>
<note>File lock dialog duration</note>
</trans-unit>
<trans-unit id="" resname="1_month_duration" datatype="x-javascript+php">
<source>1 month</source>
<note>File lock dialog duration</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0">
<file original="" source-language="en" target-language="fr-FR" datatype="x-undefined">
<body>
<trans-unit id="" resname="100_character_description_" datatype="php">
<source>100 character description:</source>
<target>Description de 100 caractères :</target>
</trans-unit>
<trans-unit id="" resname="15_min_duration" datatype="x-javascript+php">
<source>15 min</source>
<target>15 min</target>
<note>File lock dialog duration</note>
</trans-unit>
<trans-unit id="" resname="1_day_duration" datatype="x-javascript+php">
<source>1 day</source>
<target>1 jour</target>
<note>File lock dialog duration</note>
</trans-unit>
<trans-unit id="" resname="1_hour_duration" datatype="x-javascript+php">
<source>1 hour</source>
<target>1 heure</target>
<note>File lock dialog duration</note>
</trans-unit>
<trans-unit id="" resname="1_month_duration" datatype="x-javascript+php">
<source>1 month</source>
<target>1 mois</target>
<note>File lock dialog duration</note>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit fb3dfbe

Please sign in to comment.