diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34a802c6..66d1add4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,11 @@ on: branches: [main, develop, 'feature/**', 'hotfix/**', 'release/**'] pull_request: branches: [main, develop] + # Nightly, on the default branch: the browser tests in Firefox and WebKit as well as + # Chromium, which pull requests run alone to stay fast. + schedule: + - cron: '30 3 * * *' + workflow_dispatch: jobs: tests: @@ -238,6 +243,11 @@ jobs: # authoritative: a deployment dumped with --classmap-authoritative answers # from the classmap alone. Theme and plugin classes are autoloaded at # runtime, and every front-end page once answered 404 there (#320). + # Chromium on pushes and pull requests; all three engines on the nightly and on a + # manual run. + env: + E2E_BROWSERS: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && 'chromium,firefox,webkit' || 'chromium' }} + strategy: fail-fast: false matrix: @@ -328,7 +338,7 @@ jobs: working-directory: packages/framework/tests/e2e run: | npm ci - npx playwright install --with-deps chromium + npx playwright install --with-deps ${E2E_BROWSERS//,/ } # DDEV serves HTTPS with a mkcert certificate when mkcert is present. # Say which case the runner is in rather than guessing. diff --git a/tests/e2e/fixtures/plugins/e2e-features/app/Endpoints/Translations.php b/tests/e2e/fixtures/plugins/e2e-features/app/Endpoints/Translations.php new file mode 100644 index 00000000..67ff1f04 --- /dev/null +++ b/tests/e2e/fixtures/plugins/e2e-features/app/Endpoints/Translations.php @@ -0,0 +1,36 @@ + __('E2E greeting', 'e2e-features'), + 'untranslated' => __('E2E string outside the catalogue', 'e2e-features'), + 'laravel' => __('Shipping :brand', ['brand' => 'Example']), + 'wpNative' => __wp('E2E greeting', 'e2e-features'), + ]; + } +} diff --git a/tests/e2e/fixtures/plugins/e2e-features/languages/e2e-features-fr_FR.mo b/tests/e2e/fixtures/plugins/e2e-features/languages/e2e-features-fr_FR.mo new file mode 100644 index 00000000..60a64038 Binary files /dev/null and b/tests/e2e/fixtures/plugins/e2e-features/languages/e2e-features-fr_FR.mo differ diff --git a/tests/e2e/fixtures/plugins/e2e-features/languages/e2e-features-fr_FR.po b/tests/e2e/fixtures/plugins/e2e-features/languages/e2e-features-fr_FR.po new file mode 100644 index 00000000..15ce14ff --- /dev/null +++ b/tests/e2e/fixtures/plugins/e2e-features/languages/e2e-features-fr_FR.po @@ -0,0 +1,13 @@ +# Pollora browser test fixture: the catalogue the i18n test reads in fr_FR. +msgid "" +msgstr "" +"Project-Id-Version: E2E Features\n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Domain: e2e-features\n" + +msgid "E2E greeting" +msgstr "Bonjour depuis le catalogue" diff --git a/tests/e2e/playwright.config.ts b/tests/e2e/playwright.config.ts index 9ee9ee1f..f0b3451e 100644 --- a/tests/e2e/playwright.config.ts +++ b/tests/e2e/playwright.config.ts @@ -9,6 +9,7 @@ import { defineConfig, devices } from '@playwright/test'; * WP_BASE_URL WordPress itself (`siteurl`), e.g. https://pollora-test.ddev.site/cms/ — * read by @wordpress/e2e-test-utils-playwright for wp-admin, login and REST * E2E_WP_CLI how to run WP-CLI against that site, e.g. "ddev wp" (default) + * E2E_BROWSERS comma-separated: chromium (default), firefox, webkit — the nightly runs all three */ const homeUrl = process.env.E2E_HOME_URL ?? 'https://pollora-test.ddev.site'; // Trailing slash: relative paths such as wp-login.php must resolve inside /cms. @@ -29,6 +30,20 @@ if (! process.env.NODE_EXTRA_CA_CERTS) { } } +const browsers: Record = { + chromium: 'Desktop Chrome', + firefox: 'Desktop Firefox', + webkit: 'Desktop Safari', +}; + +const projects = (process.env.E2E_BROWSERS ?? 'chromium').split(',').map((name) => name.trim()).map((name) => { + if (! (name in browsers)) { + throw new Error(`E2E_BROWSERS: unknown browser "${name}" (known: ${Object.keys(browsers).join(', ')})`); + } + + return { name, use: { ...devices[browsers[name]] } }; +}); + export default defineConfig({ testDir: './specs', globalSetup: './global-setup.ts', @@ -46,5 +61,5 @@ export default defineConfig({ screenshot: 'only-on-failure', video: 'retain-on-failure', }, - projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }], + projects, }); diff --git a/tests/e2e/specs/features.spec.ts b/tests/e2e/specs/features.spec.ts index d16eed5c..da4cd76c 100644 --- a/tests/e2e/specs/features.spec.ts +++ b/tests/e2e/specs/features.spec.ts @@ -163,6 +163,21 @@ test.describe('Assets', () => { }); }); +test.describe('Translations through __()', () => { + test("a text domain goes to WordPress's catalogues, replacements to Laravel", async () => { + const context = await visitor(); + const translations = await (await context.get(homeUrl('/wp-json/e2e/v1/translations'))).json(); + await context.dispose(); + + expect(translations).toEqual({ + wordpress: 'Bonjour depuis le catalogue', + untranslated: 'E2E string outside the catalogue', + laravel: 'Shipping Example', + wpNative: 'Bonjour depuis le catalogue', + }); + }); +}); + test.describe('The active theme', () => { test('registers the menu locations its config/menus.php declares', async ({ requestUtils }) => { const configFile = join(siteDir, 'themes', activeTheme(), 'config', 'menus.php');