Skip to content

Commit 525091a

Browse files
committed
[WIP] playwright
1 parent 9d29e35 commit 525091a

File tree

11 files changed

+263
-0
lines changed

11 files changed

+263
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the TYPO3 CMS project.
7+
*
8+
* It is free software; you can redistribute it and/or modify it under
9+
* the terms of the GNU General Public License, either version 2
10+
* of the License, or any later version.
11+
*
12+
* For the full copyright and license information, please read the
13+
* LICENSE.txt file that was distributed with this source code.
14+
*
15+
* The TYPO3 project - inspiring people to share!
16+
*/
17+
18+
namespace ContainerTests\DatasetImport\Command;
19+
20+
use Symfony\Component\Console\Attribute\AsCommand;
21+
use Symfony\Component\Console\Command\Command;
22+
use Symfony\Component\Console\Input\InputArgument;
23+
use Symfony\Component\Console\Input\InputInterface;
24+
use Symfony\Component\Console\Output\OutputInterface;
25+
use Symfony\Component\Console\Style\SymfonyStyle;
26+
use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\DataSet;
27+
28+
/**
29+
* CLI command for setting up TYPO3 via CLI
30+
*/
31+
#[AsCommand('dataset:import', 'Import Dataset')]
32+
class DatasetImportCommand extends Command
33+
{
34+
protected function configure(): void
35+
{
36+
$this->addArgument('path', InputArgument::REQUIRED, 'Path to CSV dataset to import');
37+
}
38+
39+
protected function execute(InputInterface $input, OutputInterface $output): int
40+
{
41+
if (!class_exists(DataSet::class)) {
42+
$io = new SymfonyStyle($input, $output);
43+
$io->getErrorStyle()->error('Missing typo3/testing-framework dependency.');
44+
return Command::FAILURE;
45+
}
46+
DataSet::import($input->getArgument('path'));
47+
return Command::SUCCESS;
48+
}
49+
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
public: false
6+
7+
ContainerTests\DatasetImport\:
8+
resource: '../Classes/*'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "containertests/dataset-import",
3+
"type": "typo3-cms-extension",
4+
"description": "Support extension providing dataset:import command",
5+
"license": "GPL-2.0-or-later",
6+
"require": {
7+
"typo3/cms-core": "^13.4",
8+
"typo3/testing-framework": "*"
9+
},
10+
"extra": {
11+
"typo3/cms": {
12+
"extension-key": "dataset_import"
13+
}
14+
},
15+
"autoload": {
16+
"psr-4": {
17+
"ContainerTests\\DatasetImport\\": "Classes/"
18+
}
19+
}
20+
}

Tests/playwright/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
/test-results/
3+
/playwright-report/
4+
/blob-report/
5+
/playwright/.cache/
6+
/.state/
7+
/.env

Tests/playwright/.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.2.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const {test, expect} = require('@playwright/test');
2+
3+
test.beforeEach(async ({page}) => {
4+
await page.goto('http://webserver:80/typo3/index.php');
5+
})
6+
7+
test('Form Framework Module loads', async ({page}) => {
8+
await page.click('[data-modulemenu-identifier="web_FormFormbuilder"]');
9+
await page.waitForLoadState('networkidle');
10+
const contentFrame = await page.frameLocator('#typo3-contentIframe');
11+
expect(await contentFrame.locator('.module-body')).toBeVisible();
12+
expect(await contentFrame.locator('.module-body > h1')).toHaveText('Form Management');
13+
// TODO
14+
// await betterTimes();
15+
});
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {test as setup, expect} from '@playwright/test';
2+
3+
setup('Backend login', async ({page}) => {
4+
//await page.goto('/typo3/index.php');
5+
await page.goto('http://webserver:80/typo3/index.php');
6+
await page.fill('#t3-username', process.env.BE_USER || 'admin');
7+
await page.fill('#t3-password', process.env.BE_USER_PASSWORD || 'Password.1');
8+
await page.waitForTimeout(500);
9+
await page.click('#t3-login-submit');
10+
await page.waitForLoadState('networkidle');
11+
await expect(await page.locator('.topbar-header-site-title')).toBeVisible();
12+
13+
await page.context().storageState({path: './.state/backend-login.json'});
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"pages"
2+
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","is_siteroot","slug"
3+
,1,0,256,0,0,0,0,0,0,"Root Page",1,"/"
4+
,2,1,256,0,0,0,0,0,0,"Another Page",0,"/another-page"
5+
,155,1,256,0,0,0,0,0,0,"404 Page not found",0,"/404-page-not-found"
6+
"tt_content"
7+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header"
8+
,1,1,256,0,0,0,0,0,0,0,0,"Regular Element #1"
9+
,2,1,512,0,0,0,0,0,0,0,0,"Regular Element #2"
10+
,3,155,512,0,0,0,0,0,0,0,0,"404 Welcome to nowhere"
11+
"be_users"
12+
,"uid","pid","tstamp","username","password","admin","disable","starttime","endtime","options","crdate","workspace_perms","deleted","TSconfig","lastlogin","workspace_id","db_mountpoints","usergroup","realName"
13+
# password of both users is "password"
14+
,1,0,1366642540,"admin","$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1",1,0,0,0,0,1366642540,1,0,,1371033743,0,0,0,"Klaus"
15+

Tests/playwright/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "playwright",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"scripts": {},
6+
"keywords": [],
7+
"author": "",
8+
"license": "ISC",
9+
"description": "",
10+
"devDependencies": {
11+
"@playwright/test": "^1.49.0",
12+
"@types/node": "^20.12.13",
13+
"dotenv": "^16.4.5"
14+
}
15+
}

Tests/playwright/playwright.config.js

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// @ts-check
2+
const {defineConfig, devices} = require('@playwright/test');
3+
const path = require("node:path");
4+
import dotenv from 'dotenv';
5+
6+
/**
7+
* Read environment variables from file.
8+
* https://github.com/motdotla/dotenv
9+
*/
10+
// Read from GitLab file variable $PLAYWRIGHT_ENV if set. ".env" file otherwise
11+
dotenv.config({ path: process.env.PLAYWRIGHT_ENV || path.resolve(__dirname, '.env') });
12+
13+
/**
14+
* @see https://playwright.dev/docs/test-configuration
15+
*/
16+
module.exports = defineConfig({
17+
testDir: './e2e',
18+
/* Run tests in files in parallel */
19+
fullyParallel: true,
20+
/* Fail the build on CI if you accidentally left test.only in the source code. */
21+
forbidOnly: !!process.env.CI,
22+
/* Retry on CI only */
23+
retries: process.env.CI ? 3 : 0,
24+
/* Opt out of parallel tests on CI. */
25+
workers: 1,
26+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
27+
reporter: [
28+
['html', {open: 'never'}],
29+
['list', {printSteps: true}],
30+
['junit'],
31+
],
32+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
33+
use: {
34+
/* Base URL to use in actions like `await page.goto('/')`. */
35+
// baseURL: process.env.BASE_URL ? process.env.BASE_URL : 'https://foo.ddev.site',
36+
baseURL: "http://webserver:80/",
37+
ignoreHTTPSErrors: true,
38+
39+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
40+
trace: 'on-first-retry',
41+
screenshot: 'on',
42+
},
43+
44+
/* Configure projects for major browsers */
45+
projects: [
46+
{
47+
name: 'frontend-cookie',
48+
testMatch: 'helper/frontend-cookie.setup.js',
49+
},
50+
{
51+
name: 'backend-login',
52+
testMatch: 'helper/backend-login.setup.js',
53+
},
54+
{
55+
name: 'frontend',
56+
testMatch: 'frontend/**/*.spec.js',
57+
dependencies: ['frontend-cookie'],
58+
use: {
59+
storageState: path.join(__dirname, '.state/frontend-cookie.json'),
60+
},
61+
},
62+
{
63+
name: 'backend',
64+
testMatch: 'backend/**/*.spec.js',
65+
dependencies: ['backend-login'],
66+
use: {
67+
storageState: path.join(__dirname, '.state/backend-login.json'),
68+
},
69+
},
70+
],
71+
});

Tests/playwright/yarn.lock

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@playwright/test@^1.49.0":
6+
version "1.49.1"
7+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.49.1.tgz#55fa360658b3187bfb6371e2f8a64f50ef80c827"
8+
integrity sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==
9+
dependencies:
10+
playwright "1.49.1"
11+
12+
"@types/node@^20.12.13":
13+
version "20.17.12"
14+
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.17.12.tgz#ee3b7d25a522fd95608c1b3f02921c97b93fcbd6"
15+
integrity sha512-vo/wmBgMIiEA23A/knMfn/cf37VnuF52nZh5ZoW0GWt4e4sxNquibrMRJ7UQsA06+MBx9r/H1jsI9grYjQCQlw==
16+
dependencies:
17+
undici-types "~6.19.2"
18+
19+
dotenv@^16.4.5:
20+
version "16.4.7"
21+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.7.tgz#0e20c5b82950140aa99be360a8a5f52335f53c26"
22+
integrity sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==
23+
24+
25+
version "2.3.2"
26+
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
27+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
28+
29+
30+
version "1.49.1"
31+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015"
32+
integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==
33+
34+
35+
version "1.49.1"
36+
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c"
37+
integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==
38+
dependencies:
39+
playwright-core "1.49.1"
40+
optionalDependencies:
41+
fsevents "2.3.2"
42+
43+
undici-types@~6.19.2:
44+
version "6.19.8"
45+
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
46+
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==

0 commit comments

Comments
 (0)