V14 QA Fixed the failed acceptance tests (#15527)

* Fixed failing tests

* Updated tests to use the updated helpers

* Clean up tests

* Enabled our pipeline for E2E testing

* Updated the CMS URl for our E2E tests

* Bumped version of our testHelpers

* Did some fixing, still a bit more to do

* Updated auth tests to use LoginUiHelper

* Updated Telemetry tests to use TelemetryUiHelper

* Updated LogViewer tests to use LogViewerUiHelper

* Updated api tests to apply AAA pattern and fix failed tests

* Removed unused import

* Fixed comments

* Bumped version of test helper

* Updated the version to 10 instead of 11

* Updated the package-lock.json file to contain the correct versions

* Added a waitForTimeout
The reason for this is that this test is failing on the pipeline

* Bumped version of testhelpers

* Removed TODO

* Updated EnsurePathExists so we create the stylesheet and scripts folder

* Added a waits for response, otherwise our test would be too fast

* Sometimes it reloads before the save is complete

* Added timeout for locator

* Removed duplicate

* Wait until save

* This was an actual bug, so we should not use a workaround, we should fix it

* Skips the tests for script.

* Bug was fixed, so this can be used again

---------

Co-authored-by: Andreas Zerbst <andr317c@live.dk>
This commit is contained in:
Nhu Dinh
2024-01-12 19:32:25 +07:00
committed by GitHub
parent a8fd00a3b4
commit 664da17c39
26 changed files with 703 additions and 757 deletions

View File

@@ -434,149 +434,149 @@ stages:
Tests__Database__SQLServerMasterConnectionString: $(connectionString)
Umbraco__CMS__Global__MainDomLock: 'SqlMainDomLock'
# - stage: E2E
# variables:
# npm_config_cache: $(Pipeline.Workspace)/.npm_e2e
# displayName: E2E Tests
# dependsOn: Build
# jobs:
# # E2E Tests
# - job:
# displayName: E2E Tests
# timeoutInMinutes: 120
# variables:
# Umbraco__CMS__Unattended__UnattendedUserName: Playwright Test
# Umbraco__CMS__Unattended__UnattendedUserPassword: UmbracoAcceptance123!
# Umbraco__CMS__Unattended__UnattendedUserEmail: playwright@umbraco.com
# ASPNETCORE_URLS: https://localhost:8443
# strategy:
# matrix:
# Linux:
# vmImage: 'ubuntu-latest'
# dockerfile: umbraco-linux.docker
# dockerImageName: umbraco-linux
# Windows:
# vmImage: 'windows-latest'
# DOTNET_GENERATE_ASPNET_CERTIFICATE: true # Automatically generate HTTPS development certificate on Windows
# # Enable console logging in Release mode
# Serilog__WriteTo__0__Name: Async
# Serilog__WriteTo__0__Args__configure__0__Name: Console
# # Set unattended install settings
# Umbraco__CMS__Unattended__InstallUnattended: true
# Umbraco__CMS__Global__InstallMissingDatabase: true
# UmbracoDatabaseServer: (LocalDB)\MSSQLLocalDB
# UmbracoDatabaseName: AcceptanceTestDB
# ConnectionStrings__umbracoDbDSN: Server=$(UmbracoDatabaseServer);Database=$(UmbracoDatabaseName);Integrated Security=true;
# # Custom Umbraco settings
# Umbraco__CMS__Global__VersionCheckPeriod: 0
# Umbraco__CMS__Global__UseHttps: true
# Umbraco__CMS__HealthChecks__Notification__Enabled: false
# Umbraco__CMS__KeepAlive__DisableKeepAliveTask: true
# pool:
# vmImage: $(vmImage)
# steps:
# - task: DownloadPipelineArtifact@2
# displayName: Download nupkg
# inputs:
# artifact: nupkg
# path: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/misc/nupkg
# - task: NodeTool@0
# displayName: Use Node.js $(nodeVersion)
# retryCountOnTaskFailure: 3
# inputs:
# versionSpec: $(nodeVersion)
# - task: Cache@2
# displayName: Cache node_modules
# inputs:
# key: '"npm_e2e" | "$(Agent.OS)" | $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/package-lock.json'
# restoreKeys: |
# "npm_e2e" | "$(Agent.OS)"
# "npm_e2e"
# path: $(npm_config_cache)
# - pwsh: |
# New-Item -Path "." -Name ".env" -ItemType "file" -Value "UMBRACO_USER_LOGIN=$(Umbraco__CMS__Unattended__UnattendedUserEmail)
# UMBRACO_USER_PASSWORD=$(Umbraco__CMS__Unattended__UnattendedUserPassword)
# URL=$(ASPNETCORE_URLS)"
# displayName: Generate .env
# workingDirectory: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/
# - script: npm ci --no-fund --no-audit --prefer-offline
# workingDirectory: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/
# displayName: Run npm ci
# - pwsh: sqllocaldb start mssqllocaldb
# displayName: Start localdb (Windows only)
# condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
# - pwsh: Invoke-Sqlcmd -Query "CREATE DATABASE $env:UmbracoDatabaseName" -ServerInstance $env:UmbracoDatabaseServer
# displayName: Create database (Windows only)
# condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
# - task: UseDotNet@2
# displayName: Use .NET $(dotnetVersion)
# inputs:
# version: $(dotnetVersion)
# performMultiLevelLookup: true
# includePreviewVersions: $(dotnetIncludePreviewVersions)
# - pwsh: |
# $sha = 'g$(Build.SourceVersion)'.substring(0, 8)
# docker build -t $(dockerImageName):$sha -f $(dockerfile) .
# mkdir -p $(Build.ArtifactStagingDirectory)/docker-images
# docker save -o $(Build.ArtifactStagingDirectory)/docker-images/$(dockerImageName).$sha.tar $(dockerImageName):$sha
# dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p $(Umbraco__CMS__Unattended__UnattendedUserPassword)
# docker run --name $(dockerImageName) -dp 8080:5000 -dp 8443:5001 -e UMBRACO__CMS__GLOBAL__ID=$(UMBRACO__CMS__GLOBAL__ID) -e ASPNETCORE_Kestrel__Certificates__Default__Password="$(Umbraco__CMS__Unattended__UnattendedUserPassword)" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v ${HOME}/.aspnet/https:/https/ $(dockerImageName):$sha
# docker ps
# condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
# displayName: Build and run container (Linux only)
# workingDirectory: tests/Umbraco.Tests.AcceptanceTest/misc
# - pwsh: |
# dotnet new --install ./nupkg/Umbraco.Templates.*.nupkg
# dotnet new umbraco --name AcceptanceTestProject --no-restore --output .
# dotnet restore --configfile ./nuget.config
# dotnet build --configuration $(buildConfiguration) --no-restore
# dotnet dev-certs https
# $process = Start-Process -FilePath "dotnet" -ArgumentList "run --configuration $(buildConfiguration) --no-build --no-launch-profile 2>&1" -PassThru -RedirectStandardOutput $(Build.ArtifactStagingDirectory)/playwright.log
# Write-Host "##vso[task.setvariable variable=AcceptanceTestProcessId]$($process.Id)"
# condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
# displayName: Build and run app (Windows only)
# workingDirectory: tests/Umbraco.Tests.AcceptanceTest/misc
# - pwsh: npx wait-on -v --interval 1000 --timeout 120000 $(ASPNETCORE_URLS)
# displayName: Wait for app
# workingDirectory: tests/Umbraco.Tests.AcceptanceTest
# - pwsh: npx playwright install --with-deps
# displayName: Install Playwright
# workingDirectory: tests/Umbraco.Tests.AcceptanceTest
# - pwsh: npm run test --ignore-certificate-errors
# displayName: Run Playwright (Desktop)
# continueOnError: true
# workingDirectory: tests/Umbraco.Tests.AcceptanceTest
# env:
# CI: true
# CommitId: $(Build.SourceVersion)
# AgentOs: $(Agent.OS)
# - pwsh: |
# docker logs $(dockerImageName) > $(Build.ArtifactStagingDirectory)/playwright.log 2>&1
# docker stop $(dockerImageName)
# condition: eq(variables['Agent.OS'], 'Linux')
# displayName: Stop app (Linux only)
# - pwsh: Stop-Process $env:AcceptanceTestProcessId
# condition: eq(variables['Agent.OS'], 'Windows_NT')
# displayName: Stop app (Windows only)
# - task: PowerShell@2
# displayName: Check if artifacts folder exists
# inputs:
# targetType: inline
# script: |
# $MyVariable = Test-Path -Path $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/results
# Write-Host "##vso[task.setvariable variable=resultFolderExists;]$MyVariable"
# - task: CopyFiles@2
# displayName: Prepare artifacts
# condition: eq(variables.resultFolderExists, 'True')
# inputs:
# sourceFolder: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/results/
# targetFolder: $(Build.ArtifactStagingDirectory)/playwright
# - task: PublishPipelineArtifact@1
# condition: always()
# displayName: Publish test artifacts
# inputs:
# targetPath: $(Build.ArtifactStagingDirectory)
# artifact: 'E2E artifacts - $(Agent.OS) - Attempt #$(System.JobAttempt)'
- stage: E2E
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm_e2e
displayName: E2E Tests
dependsOn: Build
jobs:
# E2E Tests
- job:
displayName: E2E Tests
timeoutInMinutes: 120
variables:
Umbraco__CMS__Unattended__UnattendedUserName: Playwright Test
Umbraco__CMS__Unattended__UnattendedUserPassword: UmbracoAcceptance123!
Umbraco__CMS__Unattended__UnattendedUserEmail: playwright@umbraco.com
ASPNETCORE_URLS: https://localhost:8443
strategy:
matrix:
Linux:
vmImage: 'ubuntu-latest'
dockerfile: umbraco-linux.docker
dockerImageName: umbraco-linux
Windows:
vmImage: 'windows-latest'
DOTNET_GENERATE_ASPNET_CERTIFICATE: true # Automatically generate HTTPS development certificate on Windows
# Enable console logging in Release mode
Serilog__WriteTo__0__Name: Async
Serilog__WriteTo__0__Args__configure__0__Name: Console
# Set unattended install settings
Umbraco__CMS__Unattended__InstallUnattended: true
Umbraco__CMS__Global__InstallMissingDatabase: true
UmbracoDatabaseServer: (LocalDB)\MSSQLLocalDB
UmbracoDatabaseName: AcceptanceTestDB
ConnectionStrings__umbracoDbDSN: Server=$(UmbracoDatabaseServer);Database=$(UmbracoDatabaseName);Integrated Security=true;
# Custom Umbraco settings
Umbraco__CMS__Global__VersionCheckPeriod: 0
Umbraco__CMS__Global__UseHttps: true
Umbraco__CMS__HealthChecks__Notification__Enabled: false
Umbraco__CMS__KeepAlive__DisableKeepAliveTask: true
pool:
vmImage: $(vmImage)
steps:
- task: DownloadPipelineArtifact@2
displayName: Download nupkg
inputs:
artifact: nupkg
path: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/misc/nupkg
- task: NodeTool@0
displayName: Use Node.js $(nodeVersion)
retryCountOnTaskFailure: 3
inputs:
versionSpec: $(nodeVersion)
- task: Cache@2
displayName: Cache node_modules
inputs:
key: '"npm_e2e" | "$(Agent.OS)" | $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/package-lock.json'
restoreKeys: |
"npm_e2e" | "$(Agent.OS)"
"npm_e2e"
path: $(npm_config_cache)
- pwsh: |
New-Item -Path "." -Name ".env" -ItemType "file" -Value "UMBRACO_USER_LOGIN=$(Umbraco__CMS__Unattended__UnattendedUserEmail)
UMBRACO_USER_PASSWORD=$(Umbraco__CMS__Unattended__UnattendedUserPassword)
URL=$(ASPNETCORE_URLS)"
displayName: Generate .env
workingDirectory: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/
- script: npm ci --no-fund --no-audit --prefer-offline
workingDirectory: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/
displayName: Run npm ci
- pwsh: sqllocaldb start mssqllocaldb
displayName: Start localdb (Windows only)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- pwsh: Invoke-Sqlcmd -Query "CREATE DATABASE $env:UmbracoDatabaseName" -ServerInstance $env:UmbracoDatabaseServer
displayName: Create database (Windows only)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: UseDotNet@2
displayName: Use .NET $(dotnetVersion)
inputs:
version: $(dotnetVersion)
performMultiLevelLookup: true
includePreviewVersions: $(dotnetIncludePreviewVersions)
- pwsh: |
$sha = 'g$(Build.SourceVersion)'.substring(0, 8)
docker build -t $(dockerImageName):$sha -f $(dockerfile) .
mkdir -p $(Build.ArtifactStagingDirectory)/docker-images
docker save -o $(Build.ArtifactStagingDirectory)/docker-images/$(dockerImageName).$sha.tar $(dockerImageName):$sha
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p $(Umbraco__CMS__Unattended__UnattendedUserPassword)
docker run --name $(dockerImageName) -dp 8080:5000 -dp 8443:5001 -e UMBRACO__CMS__GLOBAL__ID=$(UMBRACO__CMS__GLOBAL__ID) -e ASPNETCORE_Kestrel__Certificates__Default__Password="$(Umbraco__CMS__Unattended__UnattendedUserPassword)" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v ${HOME}/.aspnet/https:/https/ $(dockerImageName):$sha
docker ps
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
displayName: Build and run container (Linux only)
workingDirectory: tests/Umbraco.Tests.AcceptanceTest/misc
- pwsh: |
dotnet new --install ./nupkg/Umbraco.Templates.*.nupkg
dotnet new umbraco --name AcceptanceTestProject --no-restore --output .
dotnet restore --configfile ./nuget.config
dotnet build --configuration $(buildConfiguration) --no-restore
dotnet dev-certs https
$process = Start-Process -FilePath "dotnet" -ArgumentList "run --configuration $(buildConfiguration) --no-build --no-launch-profile 2>&1" -PassThru -RedirectStandardOutput $(Build.ArtifactStagingDirectory)/playwright.log
Write-Host "##vso[task.setvariable variable=AcceptanceTestProcessId]$($process.Id)"
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
displayName: Build and run app (Windows only)
workingDirectory: tests/Umbraco.Tests.AcceptanceTest/misc
- pwsh: npx wait-on -v --interval 1000 --timeout 120000 $(ASPNETCORE_URLS)
displayName: Wait for app
workingDirectory: tests/Umbraco.Tests.AcceptanceTest
- pwsh: npx playwright install --with-deps
displayName: Install Playwright
workingDirectory: tests/Umbraco.Tests.AcceptanceTest
- pwsh: npm run test --ignore-certificate-errors
displayName: Run Playwright (Desktop)
continueOnError: true
workingDirectory: tests/Umbraco.Tests.AcceptanceTest
env:
CI: true
CommitId: $(Build.SourceVersion)
AgentOs: $(Agent.OS)
- pwsh: |
docker logs $(dockerImageName) > $(Build.ArtifactStagingDirectory)/playwright.log 2>&1
docker stop $(dockerImageName)
condition: eq(variables['Agent.OS'], 'Linux')
displayName: Stop app (Linux only)
- pwsh: Stop-Process $env:AcceptanceTestProcessId
condition: eq(variables['Agent.OS'], 'Windows_NT')
displayName: Stop app (Windows only)
- task: PowerShell@2
displayName: Check if artifacts folder exists
inputs:
targetType: inline
script: |
$MyVariable = Test-Path -Path $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/results
Write-Host "##vso[task.setvariable variable=resultFolderExists;]$MyVariable"
- task: CopyFiles@2
displayName: Prepare artifacts
condition: eq(variables.resultFolderExists, 'True')
inputs:
sourceFolder: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/results/
targetFolder: $(Build.ArtifactStagingDirectory)/playwright
- task: PublishPipelineArtifact@1
condition: always()
displayName: Publish test artifacts
inputs:
targetPath: $(Build.ArtifactStagingDirectory)
artifact: 'E2E artifacts - $(Agent.OS) - Attempt #$(System.JobAttempt)'
###############################################
@@ -587,7 +587,7 @@ stages:
dependsOn:
- Unit
- Integration
# - E2E # TODO: Enable when stable.
# - E2E
condition: and(succeeded(), or(eq(dependencies.Build.outputs['A.build.NBGV_PublicRelease'], 'True'), ${{parameters.myGetDeploy}}))
jobs:
- job: