diff --git a/Tests/Packages/dataset_import/Classes/Command/DatasetImportCommand.php b/Tests/Packages/dataset_import/Classes/Command/DatasetImportCommand.php new file mode 100644 index 00000000..fd1fcce3 --- /dev/null +++ b/Tests/Packages/dataset_import/Classes/Command/DatasetImportCommand.php @@ -0,0 +1,50 @@ +addArgument('path', InputArgument::REQUIRED, 'Path to CSV dataset to import'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + if (!class_exists(DataSet::class)) { + $io = new SymfonyStyle($input, $output); + $io->getErrorStyle()->error('Missing typo3/testing-framework dependency.'); + return Command::FAILURE; + } + DataSet::import($input->getArgument('path')); + return Command::SUCCESS; + } + +} diff --git a/Tests/Packages/dataset_import/Configuration/Services.yaml b/Tests/Packages/dataset_import/Configuration/Services.yaml new file mode 100644 index 00000000..9d2ad75c --- /dev/null +++ b/Tests/Packages/dataset_import/Configuration/Services.yaml @@ -0,0 +1,8 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + ContainerTests\DatasetImport\: + resource: '../Classes/*' diff --git a/Tests/Packages/dataset_import/composer.json b/Tests/Packages/dataset_import/composer.json new file mode 100644 index 00000000..a7b4a02f --- /dev/null +++ b/Tests/Packages/dataset_import/composer.json @@ -0,0 +1,20 @@ +{ + "name": "containertests/dataset-import", + "type": "typo3-cms-extension", + "description": "Support extension providing dataset:import command", + "license": "GPL-2.0-or-later", + "require": { + "typo3/cms-core": "^13.4", + "typo3/testing-framework": "*" + }, + "extra": { + "typo3/cms": { + "extension-key": "dataset_import" + } + }, + "autoload": { + "psr-4": { + "ContainerTests\\DatasetImport\\": "Classes/" + } + } +} diff --git a/Tests/playwright/.gitignore b/Tests/playwright/.gitignore new file mode 100644 index 00000000..b4709abf --- /dev/null +++ b/Tests/playwright/.gitignore @@ -0,0 +1,7 @@ +node_modules/ +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ +/.state/ +/.env diff --git a/Tests/playwright/.nvmrc b/Tests/playwright/.nvmrc new file mode 100644 index 00000000..44e031ba --- /dev/null +++ b/Tests/playwright/.nvmrc @@ -0,0 +1 @@ +22.2.0 diff --git a/Tests/playwright/e2e/backend/form_framework.spec.js b/Tests/playwright/e2e/backend/form_framework.spec.js new file mode 100644 index 00000000..8c202f7b --- /dev/null +++ b/Tests/playwright/e2e/backend/form_framework.spec.js @@ -0,0 +1,16 @@ +const {test, expect} = require('@playwright/test'); + +test.beforeEach(async ({page}) => { + await page.goto('http://webserver:80/typo3/index.php'); +}) + +test('Form Framework Module loads', async ({page}) => { + await page.click('[data-modulemenu-identifier="web_FormFormbuilder"]'); + await page.waitForLoadState('networkidle'); + const contentFrame = await page.frameLocator('#typo3-contentIframe'); + expect(await contentFrame.locator('.module-body')).toBeVisible(); + expect(await contentFrame.locator('.module-body > h1')).toHaveText('Form Management'); + // TODO + // await betterTimes(); +}); + diff --git a/Tests/playwright/e2e/helper/backend-login.setup.js b/Tests/playwright/e2e/helper/backend-login.setup.js new file mode 100644 index 00000000..a00df154 --- /dev/null +++ b/Tests/playwright/e2e/helper/backend-login.setup.js @@ -0,0 +1,14 @@ +import {test as setup, expect} from '@playwright/test'; + +setup('Backend login', async ({page}) => { + //await page.goto('/typo3/index.php'); + await page.goto('http://webserver:80/typo3/index.php'); + await page.fill('#t3-username', process.env.BE_USER || 'admin'); + await page.fill('#t3-password', process.env.BE_USER_PASSWORD || 'Password.1'); + await page.waitForTimeout(500); + await page.click('#t3-login-submit'); + await page.waitForLoadState('networkidle'); + await expect(await page.locator('.topbar-header-site-title')).toBeVisible(); + + await page.context().storageState({path: './.state/backend-login.json'}); +}); diff --git a/Tests/playwright/fixtures/backend/basic.csv b/Tests/playwright/fixtures/backend/basic.csv new file mode 100644 index 00000000..c6ddf2f3 --- /dev/null +++ b/Tests/playwright/fixtures/backend/basic.csv @@ -0,0 +1,15 @@ +"pages" +,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","is_siteroot","slug" +,1,0,256,0,0,0,0,0,0,"Root Page",1,"/" +,2,1,256,0,0,0,0,0,0,"Another Page",0,"/another-page" +,155,1,256,0,0,0,0,0,0,"404 Page not found",0,"/404-page-not-found" +"tt_content" +,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header" +,1,1,256,0,0,0,0,0,0,0,0,"Regular Element #1" +,2,1,512,0,0,0,0,0,0,0,0,"Regular Element #2" +,3,155,512,0,0,0,0,0,0,0,0,"404 Welcome to nowhere" +"be_users" +,"uid","pid","tstamp","username","password","admin","disable","starttime","endtime","options","crdate","workspace_perms","deleted","TSconfig","lastlogin","workspace_id","db_mountpoints","usergroup","realName" +# password of both users is "password" +,1,0,1366642540,"admin","$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1",1,0,0,0,0,1366642540,1,0,,1371033743,0,0,0,"Klaus" + diff --git a/Tests/playwright/package.json b/Tests/playwright/package.json new file mode 100644 index 00000000..d19d733f --- /dev/null +++ b/Tests/playwright/package.json @@ -0,0 +1,15 @@ +{ + "name": "playwright", + "version": "1.0.0", + "main": "index.js", + "scripts": {}, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "devDependencies": { + "@playwright/test": "^1.49.0", + "@types/node": "^20.12.13", + "dotenv": "^16.4.5" + } +} diff --git a/Tests/playwright/playwright.config.js b/Tests/playwright/playwright.config.js new file mode 100644 index 00000000..3f5e9d9b --- /dev/null +++ b/Tests/playwright/playwright.config.js @@ -0,0 +1,71 @@ +// @ts-check +const {defineConfig, devices} = require('@playwright/test'); +const path = require("node:path"); +import dotenv from 'dotenv'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// Read from GitLab file variable $PLAYWRIGHT_ENV if set. ".env" file otherwise +dotenv.config({ path: process.env.PLAYWRIGHT_ENV || path.resolve(__dirname, '.env') }); + +/** + * @see https://playwright.dev/docs/test-configuration + */ +module.exports = defineConfig({ + testDir: './e2e', + /* 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 ? 3 : 0, + /* Opt out of parallel tests on CI. */ + workers: 1, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: [ + ['html', {open: 'never'}], + ['list', {printSteps: true}], + ['junit'], + ], + /* 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: process.env.BASE_URL ? process.env.BASE_URL : 'https://foo.ddev.site', + baseURL: "http://webserver:80/", + ignoreHTTPSErrors: true, + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + screenshot: 'on', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'frontend-cookie', + testMatch: 'helper/frontend-cookie.setup.js', + }, + { + name: 'backend-login', + testMatch: 'helper/backend-login.setup.js', + }, + { + name: 'frontend', + testMatch: 'frontend/**/*.spec.js', + dependencies: ['frontend-cookie'], + use: { + storageState: path.join(__dirname, '.state/frontend-cookie.json'), + }, + }, + { + name: 'backend', + testMatch: 'backend/**/*.spec.js', + dependencies: ['backend-login'], + use: { + storageState: path.join(__dirname, '.state/backend-login.json'), + }, + }, + ], +}); diff --git a/Tests/playwright/yarn.lock b/Tests/playwright/yarn.lock new file mode 100644 index 00000000..426df897 --- /dev/null +++ b/Tests/playwright/yarn.lock @@ -0,0 +1,46 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@playwright/test@^1.49.0": + version "1.49.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.49.1.tgz#55fa360658b3187bfb6371e2f8a64f50ef80c827" + integrity sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g== + dependencies: + playwright "1.49.1" + +"@types/node@^20.12.13": + version "20.17.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.17.12.tgz#ee3b7d25a522fd95608c1b3f02921c97b93fcbd6" + integrity sha512-vo/wmBgMIiEA23A/knMfn/cf37VnuF52nZh5ZoW0GWt4e4sxNquibrMRJ7UQsA06+MBx9r/H1jsI9grYjQCQlw== + dependencies: + undici-types "~6.19.2" + +dotenv@^16.4.5: + version "16.4.7" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.7.tgz#0e20c5b82950140aa99be360a8a5f52335f53c26" + integrity sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ== + +fsevents@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +playwright-core@1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015" + integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg== + +playwright@1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c" + integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA== + dependencies: + playwright-core "1.49.1" + optionalDependencies: + fsevents "2.3.2" + +undici-types@~6.19.2: + version "6.19.8" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" + integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==