Skip to content

Commit

Permalink
refactor(SLB-278): split integration tests and run them for the respe…
Browse files Browse the repository at this point in the history
…ctive backend
  • Loading branch information
pmelab committed Mar 26, 2024
1 parent a199144 commit 9ed3844
Show file tree
Hide file tree
Showing 23 changed files with 99 additions and 21 deletions.
6 changes: 6 additions & 0 deletions apps/cms/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
}
3 changes: 3 additions & 0 deletions apps/decap/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
},
"prep": {
"dependsOn": ["prep:vite", "prep:scripts"]
},
"test:integration": {
"dependsOn": ["@custom-test/e2e#test:integration:decap"]
}
}
}
6 changes: 4 additions & 2 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
49 changes: 49 additions & 0 deletions tests/e2e/playwright.config.decap.ts
Original file line number Diff line number Diff line change
@@ -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'],
},
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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'));
Expand Down
Original file line number Diff line number Diff line change
@@ -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'));
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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' });
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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' });
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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' });
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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'));
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e/specs/drupal/translatables.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
Original file line number Diff line number Diff line change
@@ -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'));
Expand Down

0 comments on commit 9ed3844

Please sign in to comment.