Files
Umbraco-CMS/tests/Umbraco.Tests.AcceptanceTest
Andreas Zerbst 922c79ae86 V11/bugfix/fixed flaky test (#13893)
* Moved deleteAllMedia to afterEach, the reason for that is that we delete all the media in each test.

* Added additional timeout and a WaitForTimeout(), the reason for the WaitForTimeout is because it can take a second for the modelsbuilder to update the view.

* Added more timeout for the isSuccessNotificationVisible. Updated the helper ensureNameNotExists so they actually delete the partialViews

* Updated the locators for deleting the UK language. Added an expect for checking if the UK language is visible in the UI

* Updated the position where the dragAndDrop drops to

* Changed the trace so we only save the trace on the first retry, it saves a lot of time when the tests are running, since we dont need to save the trace and then delete the trace after each successful test

* Updated locators. Added an expect so the test waits until the / is visible in the URL before going further into the test

* Changed back to retain on failure on the pipelines, the reason for that is if a test only fails once, then we wont see what the actual error was in the test when looking on the pipeline.

* Added an expect so we wait until the page is  loaded for packages

* Updated the dragAndDrop so they hopefully work.

* Changed values for dragAndDrop

* Updated the dragAndDrop values

* Bumped playwright version
2023-03-01 08:52:26 +01:00
..

Umbraco Acceptance Tests

You can watch a video following these instructions here and a longer UmbraCollab recording here. Make sure to use the latest recommended contribution branch rather than v10 that's mentioned in the video. Alternatively, follow along the instructions below.

Prerequisites

  • NodeJS 16+
  • A running installed Umbraco on url: https://localhost:44331 (Default development port)
    • Install using a SqlServer/LocalDb as the tests execute too fast for Sqlite to handle.

Getting started

The tests are located in the project/folder as Umbraco.Tests.AcceptanceTests. Make sure you run npm ci & npx playwright install in that folder, or let your IDE do that.

The script will ask you to enter the username and password for a superadmin user of your Umbraco CMS.

Executing tests

There are two npm scripts that can be used to execute the test:

  1. npm run test
    • Executes the tests headless.
  2. npm run ui
    • Executes the tests in a browser handled by a playwright application.

In case of errors it is recommended to use await page.pause() so you can step through your test.

Executing single tests

If you wish to run a single test, which may be helpful when writing tests you can use the following command. As before, you need to run these tests in the 'tests/Umbraco.Tests.AcceptanceTest' folder.

npx playwright test <testname.ts>

For example to run the Login Test,

npx playwright test tests/DefaultConfig/Login/Login.spec.ts

Environment Configuration

The environment configuration is begin setup by the npm installation script. This results in the creation of this file: .env. This file is already added to .gitignore and can contain values that are different for each developer machine.

The file has the following content:

UMBRACO_USER_LOGIN=email for superadmin
UMBRACO_USER_PASSWORD=password for superadmin
URL=https://localhost:44331

You can change this if you like or run the config script to reset the values, type "npm run config" in your terminal.

Documentation

For further documentation on Playwright, see the Playwright documentation.