diff --git a/packages/drupal/test_content/import.php b/packages/drupal/test_content/import.php index 0f335ba1f..413450e84 100644 --- a/packages/drupal/test_content/import.php +++ b/packages/drupal/test_content/import.php @@ -1,6 +1,7 @@ save(); } + +// Create an example string translation for test cases. +$stringStorage = \Drupal::service('locale.storage'); +if ($stringStorage instanceof StringStorageInterface) { + /** @var \Drupal\locale\StringInterface $strings */ + $strings = $stringStorage->getStrings([ + 'source' => 'Company Name', + 'context' => 'gatsby', + ]); + $lid = 0; + if (empty($strings)) { + $lid = $stringStorage->createString([ + 'source' => 'Company name', + 'context' => 'gatsby', + ])->save()->lid; + } + else { + $lid = $strings[0]->lid; + } + $stringStorage->createTranslation([ + 'lid' => $lid, + 'language' => 'de', + 'translation' => 'Drupal Company', + ])->save(); +} diff --git a/tests/e2e/specs/translatables.spec.ts b/tests/e2e/specs/translatables.spec.ts index 0eed3af02..3994a806f 100644 --- a/tests/e2e/specs/translatables.spec.ts +++ b/tests/e2e/specs/translatables.spec.ts @@ -9,7 +9,10 @@ test('translatable strings', async ({ page }) => { footer.getByText('© 2024 Random Company. All rights reserved.'), ).toBeVisible(); await page.getByRole('link', { name: 'de' }).click(); + // Drupal provides the "Drupal Company" translation for the "Company Name" string. + // Decap provides the "Random Company" translation for the "Company Name" string, + // but Drupal translations have higher precedence. await expect( - footer.getByText('© 2024 Random Company. Alle Rechte vorbehalten.'), + footer.getByText('© 2024 Drupal Company. Alle Rechte vorbehalten.'), ).toBeVisible(); });