diff --git a/apps/cms/turbo.json b/apps/cms/turbo.json index 01a6f7d99..fa8c31141 100644 --- a/apps/cms/turbo.json +++ b/apps/cms/turbo.json @@ -33,6 +33,12 @@ "!web/themes/custom/**", "!web/sites/default/files/**" ] + }, + "test:integration": { + "dependsOn": [ + "@custom-tests/e2e#test:integration:drupal", + "@custom-tests/schema#test:integration" + ] } } } diff --git a/apps/decap/turbo.json b/apps/decap/turbo.json index e7582c8eb..5d1464652 100644 --- a/apps/decap/turbo.json +++ b/apps/decap/turbo.json @@ -14,6 +14,9 @@ }, "prep": { "dependsOn": ["prep:vite", "prep:scripts"] + }, + "test:integration": { + "dependsOn": ["@custom-test/e2e#test:integration:decap"] } } } diff --git a/tests/e2e/package.json b/tests/e2e/package.json index fafd90c69..3a1ad523a 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -8,8 +8,10 @@ "type": "module", "scripts": { "test:static": "tsc --noEmit && eslint '**/*.{ts,tsx,js,jsx}' --ignore-path='./.gitignore'", - "test:integration": "playwright test", - "test:headed": "playwright test --headed", + "test:integration:drupal": "playwright test --config playwright.config.drupal.ts", + "test:integration:decap": "playwright test --config playwright.config.decap.ts", + "test:headed:drupal": "playwright test --headed --config playwright.config.drupal.ts", + "test:headed:decap": "playwright test --headed --config playwright.config.decap.ts", "dev": "playwright test --ui", "webform-snapshots": "playwright test --config playwright.config.webforms.ts", "webform-snapshots:headed": "playwright test --config playwright.config.webforms.ts --headed", diff --git a/tests/e2e/playwright.config.decap.ts b/tests/e2e/playwright.config.decap.ts new file mode 100644 index 000000000..c91a682b5 --- /dev/null +++ b/tests/e2e/playwright.config.decap.ts @@ -0,0 +1,49 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './specs', + webServer: [ + { + command: 'pnpm run --filter "@custom/website" serve', + port: 8000, + reuseExistingServer: !process.env.CI, + }, + ], + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://127.0.0.1:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + testMatch: /decap\/\.*.spec\.ts/, + use: { ...devices['Desktop Chrome'] }, + dependencies: ['setup'], + }, + ], +}); diff --git a/tests/e2e/playwright.config.ts b/tests/e2e/playwright.config.drupal.ts similarity index 95% rename from tests/e2e/playwright.config.ts rename to tests/e2e/playwright.config.drupal.ts index 4d8307971..de8c65619 100644 --- a/tests/e2e/playwright.config.ts +++ b/tests/e2e/playwright.config.drupal.ts @@ -46,11 +46,11 @@ export default defineConfig({ projects: [ { name: 'setup', - testMatch: /setup\.ts/, + testMatch: /drupal\/setup\.ts/, }, { name: 'chromium', - testMatch: /\.*.spec\.ts/, + testMatch: /drupal\/\.*.spec\.ts/, use: { ...devices['Desktop Chrome'] }, dependencies: ['setup'], }, diff --git a/tests/e2e/specs/decap-pages.spec.ts b/tests/e2e/specs/decap/decap-pages.spec.ts similarity index 92% rename from tests/e2e/specs/decap-pages.spec.ts rename to tests/e2e/specs/decap/decap-pages.spec.ts index 7e85a9a9b..e2044ae79 100644 --- a/tests/e2e/specs/decap-pages.spec.ts +++ b/tests/e2e/specs/decap/decap-pages.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('decap pages', () => { test('example decap page is rendered', async ({ page }) => { diff --git a/tests/e2e/specs/translatables.spec.ts b/tests/e2e/specs/decap/translatables.spec.ts similarity index 93% rename from tests/e2e/specs/translatables.spec.ts rename to tests/e2e/specs/decap/translatables.spec.ts index 3994a806f..3aeeea8ce 100644 --- a/tests/e2e/specs/translatables.spec.ts +++ b/tests/e2e/specs/decap/translatables.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test('translatable strings', async ({ page }) => { await page.goto(websiteUrl('/en')); diff --git a/tests/e2e/specs/blocks.spec.ts b/tests/e2e/specs/drupal/blocks.spec.ts similarity index 97% rename from tests/e2e/specs/blocks.spec.ts rename to tests/e2e/specs/drupal/blocks.spec.ts index 7be51d7a7..22c58036a 100644 --- a/tests/e2e/specs/blocks.spec.ts +++ b/tests/e2e/specs/drupal/blocks.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test('All blocks are rendered', async ({ page }) => { await page.goto(websiteUrl('/en/blocks-complete')); diff --git a/tests/e2e/specs/campaign-urls.spec.ts b/tests/e2e/specs/drupal/campaign-urls.spec.ts similarity index 94% rename from tests/e2e/specs/campaign-urls.spec.ts rename to tests/e2e/specs/drupal/campaign-urls.spec.ts index 76ef1ba63..1478fcabe 100644 --- a/tests/e2e/specs/campaign-urls.spec.ts +++ b/tests/e2e/specs/drupal/campaign-urls.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('campaign url redirects', () => { test('simple redirects', async ({ page }) => { diff --git a/tests/e2e/specs/content-editing.spec.ts b/tests/e2e/specs/drupal/content-editing.spec.ts similarity index 95% rename from tests/e2e/specs/content-editing.spec.ts rename to tests/e2e/specs/drupal/content-editing.spec.ts index 552b1f799..463d49dc7 100644 --- a/tests/e2e/specs/content-editing.spec.ts +++ b/tests/e2e/specs/drupal/content-editing.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { cmsUrl } from '../helpers/url'; +import { cmsUrl } from '../../helpers/url'; test.describe('content-editing', () => { test.use({ storageState: '.auth/admin.json' }); diff --git a/tests/e2e/specs/content-hub.spec.ts b/tests/e2e/specs/drupal/content-hub.spec.ts similarity index 97% rename from tests/e2e/specs/content-hub.spec.ts rename to tests/e2e/specs/drupal/content-hub.spec.ts index ae2468baf..718996d73 100644 --- a/tests/e2e/specs/content-hub.spec.ts +++ b/tests/e2e/specs/drupal/content-hub.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('content hub', () => { test.beforeEach(async ({ page }) => { diff --git a/tests/e2e/specs/drupal-pages.spec.ts b/tests/e2e/specs/drupal/drupal-pages.spec.ts similarity index 92% rename from tests/e2e/specs/drupal-pages.spec.ts rename to tests/e2e/specs/drupal/drupal-pages.spec.ts index 277910ac1..a019a74e6 100644 --- a/tests/e2e/specs/drupal-pages.spec.ts +++ b/tests/e2e/specs/drupal/drupal-pages.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('drupal pages', () => { test('example drupal page is rendered', async ({ page }) => { diff --git a/tests/e2e/specs/homepage.spec.ts b/tests/e2e/specs/drupal/homepage.spec.ts similarity index 97% rename from tests/e2e/specs/homepage.spec.ts rename to tests/e2e/specs/drupal/homepage.spec.ts index 8ce478ee9..89fc70f33 100644 --- a/tests/e2e/specs/homepage.spec.ts +++ b/tests/e2e/specs/drupal/homepage.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('the homepage', () => { test('exists in english', async ({ page }) => { diff --git a/tests/e2e/specs/links.spec.ts b/tests/e2e/specs/drupal/links.spec.ts similarity index 94% rename from tests/e2e/specs/links.spec.ts rename to tests/e2e/specs/drupal/links.spec.ts index 82e7e94d4..ded231855 100644 --- a/tests/e2e/specs/links.spec.ts +++ b/tests/e2e/specs/drupal/links.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('links', () => { test('media document links target file', async ({ page }) => { diff --git a/tests/e2e/specs/login.spec.ts b/tests/e2e/specs/drupal/login.spec.ts similarity index 88% rename from tests/e2e/specs/login.spec.ts rename to tests/e2e/specs/drupal/login.spec.ts index 797f432ef..085781977 100644 --- a/tests/e2e/specs/login.spec.ts +++ b/tests/e2e/specs/drupal/login.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { cmsUrl } from '../helpers/url'; +import { cmsUrl } from '../../helpers/url'; test.describe('authentication', () => { test.use({ storageState: '.auth/admin.json' }); diff --git a/tests/e2e/specs/menus.spec.ts b/tests/e2e/specs/drupal/menus.spec.ts similarity index 96% rename from tests/e2e/specs/menus.spec.ts rename to tests/e2e/specs/drupal/menus.spec.ts index 787209638..06f7f85be 100644 --- a/tests/e2e/specs/menus.spec.ts +++ b/tests/e2e/specs/drupal/menus.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('menus', () => { test('main navigation', async ({ page }) => { diff --git a/tests/e2e/specs/metatags.spec.ts b/tests/e2e/specs/drupal/metatags.spec.ts similarity index 95% rename from tests/e2e/specs/metatags.spec.ts rename to tests/e2e/specs/drupal/metatags.spec.ts index 32f922085..c2f36362c 100644 --- a/tests/e2e/specs/metatags.spec.ts +++ b/tests/e2e/specs/drupal/metatags.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test('Metatags on Basic page', async ({ page }) => { const pageUrl = websiteUrl('/en/page-complete'); diff --git a/tests/e2e/specs/notfound.spec.ts b/tests/e2e/specs/drupal/notfound.spec.ts similarity index 93% rename from tests/e2e/specs/notfound.spec.ts rename to tests/e2e/specs/drupal/notfound.spec.ts index d5daaad36..10f7c4cc2 100644 --- a/tests/e2e/specs/notfound.spec.ts +++ b/tests/e2e/specs/drupal/notfound.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('not found pages', () => { test('are english by default', async ({ page }) => { diff --git a/tests/e2e/specs/preview.spec.ts b/tests/e2e/specs/drupal/preview.spec.ts similarity index 96% rename from tests/e2e/specs/preview.spec.ts rename to tests/e2e/specs/drupal/preview.spec.ts index e04d59541..89ae402e8 100644 --- a/tests/e2e/specs/preview.spec.ts +++ b/tests/e2e/specs/drupal/preview.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { cmsUrl } from '../helpers/url'; +import { cmsUrl } from '../../helpers/url'; test.describe.fixme('instant preview', () => { test.use({ storageState: '.auth/admin.json' }); diff --git a/tests/e2e/specs/redirects.spec.ts b/tests/e2e/specs/drupal/redirects.spec.ts similarity index 86% rename from tests/e2e/specs/redirects.spec.ts rename to tests/e2e/specs/drupal/redirects.spec.ts index 6a73c06a5..c553b8bbf 100644 --- a/tests/e2e/specs/redirects.spec.ts +++ b/tests/e2e/specs/drupal/redirects.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test.describe('drupal redirects', () => { test('are detected', async ({ page }) => { diff --git a/tests/e2e/specs/setup.ts b/tests/e2e/specs/drupal/setup.ts similarity index 92% rename from tests/e2e/specs/setup.ts rename to tests/e2e/specs/drupal/setup.ts index 180840892..c9dfad05b 100644 --- a/tests/e2e/specs/setup.ts +++ b/tests/e2e/specs/drupal/setup.ts @@ -1,6 +1,6 @@ import { expect, test as setup } from '@playwright/test'; -import { cmsUrl } from '../helpers/url'; +import { cmsUrl } from '../../helpers/url'; setup('setup', async ({ page }) => { await page.goto(cmsUrl('/user/login')); diff --git a/tests/e2e/specs/drupal/translatables.spec.ts b/tests/e2e/specs/drupal/translatables.spec.ts new file mode 100644 index 000000000..3aeeea8ce --- /dev/null +++ b/tests/e2e/specs/drupal/translatables.spec.ts @@ -0,0 +1,18 @@ +import { expect, test } from '@playwright/test'; + +import { websiteUrl } from '../../helpers/url'; + +test('translatable strings', async ({ page }) => { + await page.goto(websiteUrl('/en')); + const footer = page.getByRole('contentinfo'); + await expect( + 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 Drupal Company. Alle Rechte vorbehalten.'), + ).toBeVisible(); +}); diff --git a/tests/e2e/specs/webforms.spec.ts b/tests/e2e/specs/drupal/webforms.spec.ts similarity index 96% rename from tests/e2e/specs/webforms.spec.ts rename to tests/e2e/specs/drupal/webforms.spec.ts index 5f3867d74..d4fb48a29 100644 --- a/tests/e2e/specs/webforms.spec.ts +++ b/tests/e2e/specs/drupal/webforms.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test'; -import { websiteUrl } from '../helpers/url'; +import { websiteUrl } from '../../helpers/url'; test('Webforms work', async ({ page }) => { await page.goto(websiteUrl('/en/blocks-complete'));