diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index 92621c30d3..28e6ed25b8 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -567,7 +567,8 @@ stages: "UMBRACO_USER_LOGIN=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL) UMBRACO_USER_PASSWORD=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD) URL=$(ASPNETCORE_URLS) - STORAGE_STAGE_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth/user.json" | Out-File .env + STORAGE_STAGE_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth/user.json + CONSOLE_ERRORS_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/console-errors.json" | Out-File .env displayName: Generate .env workingDirectory: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest @@ -650,6 +651,14 @@ stages: displayName: Copy Playwright results condition: succeededOrFailed() + # Copy console error log + - pwsh: | + if (Test-Path tests/Umbraco.Tests.AcceptanceTest/console-errors.json) { + Copy-Item tests/Umbraco.Tests.AcceptanceTest/console-errors.json $(Build.ArtifactStagingDirectory) + } + displayName: Copy console error log + condition: succeededOrFailed() + # Publish test artifacts - task: PublishPipelineArtifact@1 displayName: Publish test artifacts @@ -725,7 +734,8 @@ stages: "UMBRACO_USER_LOGIN=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL) UMBRACO_USER_PASSWORD=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD) URL=$(ASPNETCORE_URLS) - STORAGE_STAGE_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth/user.json" | Out-File .env + STORAGE_STAGE_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth/user.json + CONSOLE_ERRORS_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/console-errors.json" | Out-File .env displayName: Generate .env workingDirectory: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest @@ -826,6 +836,14 @@ stages: displayName: Copy Playwright results condition: succeededOrFailed() + # Copy console error log + - pwsh: | + if (Test-Path tests/Umbraco.Tests.AcceptanceTest/console-errors.json) { + Copy-Item tests/Umbraco.Tests.AcceptanceTest/console-errors.json $(Build.ArtifactStagingDirectory) + } + displayName: Copy console error log + condition: succeededOrFailed() + # Publish test artifacts - task: PublishPipelineArtifact@1 displayName: Publish test artifacts diff --git a/build/nightly-E2E-test-pipelines.yml b/build/nightly-E2E-test-pipelines.yml index 8aa2f1fd64..629b7ac841 100644 --- a/build/nightly-E2E-test-pipelines.yml +++ b/build/nightly-E2E-test-pipelines.yml @@ -180,7 +180,8 @@ stages: "UMBRACO_USER_LOGIN=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL) UMBRACO_USER_PASSWORD=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD) URL=$(ASPNETCORE_URLS) - STORAGE_STAGE_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth/user.json" | Out-File .env + STORAGE_STAGE_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth/user.json + CONSOLE_ERRORS_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/console-errors.json" | Out-File .env displayName: Generate .env workingDirectory: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest @@ -268,6 +269,14 @@ stages: displayName: Copy Playwright results condition: succeededOrFailed() + # Copy console error log + - pwsh: | + if (Test-Path tests/Umbraco.Tests.AcceptanceTest/console-errors.json) { + Copy-Item tests/Umbraco.Tests.AcceptanceTest/console-errors.json $(Build.ArtifactStagingDirectory) + } + displayName: Copy console error log + condition: succeededOrFailed() + # Publish - task: PublishPipelineArtifact@1 displayName: Publish test artifacts @@ -343,7 +352,8 @@ stages: "UMBRACO_USER_LOGIN=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL) UMBRACO_USER_PASSWORD=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD) URL=$(ASPNETCORE_URLS) - STORAGE_STAGE_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth/user.json" | Out-File .env + STORAGE_STAGE_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth/user.json + CONSOLE_ERRORS_PATH=$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/console-errors.json" | Out-File .env displayName: Generate .env workingDirectory: $(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest @@ -449,6 +459,14 @@ stages: displayName: Copy Playwright results condition: succeededOrFailed() + # Copy console error log + - pwsh: | + if (Test-Path tests/Umbraco.Tests.AcceptanceTest/console-errors.json) { + Copy-Item tests/Umbraco.Tests.AcceptanceTest/console-errors.json $(Build.ArtifactStagingDirectory) + } + displayName: Copy console error log + condition: succeededOrFailed() + # Publish - task: PublishPipelineArtifact@1 displayName: Publish test artifacts diff --git a/tests/Umbraco.Tests.AcceptanceTest/config.js b/tests/Umbraco.Tests.AcceptanceTest/config.js index 173ecdced8..39be141915 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/config.js +++ b/tests/Umbraco.Tests.AcceptanceTest/config.js @@ -2,45 +2,48 @@ const prompt = require('prompt'); const fs = require('fs'); const properties = [ - { - description: 'Enter your Umbraco superadmin username/email', - name: 'username', - required: true - }, - { - description: 'Enter your Umbraco superadmin password', - name: 'password', - hidden: true, - required: true - }, - { - description: 'Enter CMS URL, or leave empty for default(https://localhost:44339)', - name: 'baseUrl' - } + { + description: 'Enter your Umbraco superadmin username/email', + name: 'username', + required: true + }, + { + description: 'Enter your Umbraco superadmin password', + name: 'password', + hidden: true, + required: true + }, + { + description: 'Enter CMS URL, or leave empty for default(https://localhost:44339)', + name: 'baseUrl' + } ]; +const configPath = './.env'; -const configPath = './.env' - -console.log("Configure your Umbraco test environment") +console.log("Configure your Umbraco test environment"); prompt.start(); prompt.get(properties, function (error, result) { - if (error) { return onError(error); } + if (error) { + return onError(error); + } -var fileContent = `UMBRACO_USER_LOGIN=${result.username} + const fileContent = `UMBRACO_USER_LOGIN=${result.username} UMBRACO_USER_PASSWORD=${result.password} URL=${result.baseUrl || "https://localhost:44339"} -STORAGE_STAGE_PATH=${__dirname.replace(/\\/g,'/')}/playwright/.auth/user.json`; +STORAGE_STAGE_PATH=${__dirname.replace(/\\/g, '/')}/playwright/.auth/user.json +CONSOLE_ERRORS_PATH=${__dirname.replace(/\\/g, '/')}/console-errors.json`; - fs.writeFile(configPath, fileContent, function (error) { - if (error) return console.error(error); - console.log('Configuration saved'); - }); + + fs.writeFile(configPath, fileContent, function (error) { + if (error) return console.error(error); + console.log('Configuration saved'); + }); }); function onError(error) { - console.error(error); - return true; + console.error(error); + return true; } diff --git a/tests/Umbraco.Tests.AcceptanceTest/postinstall.js b/tests/Umbraco.Tests.AcceptanceTest/postinstall.js index dd2dcaba31..ea59ab25d6 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/postinstall.js +++ b/tests/Umbraco.Tests.AcceptanceTest/postinstall.js @@ -1,14 +1,27 @@ const fs = require('fs'); const configPath = './.env'; +const consoleErrorsPath = './console-errors.json'; try { if (fs.existsSync(configPath)) { - //file exists + // file exists console.log("Skips configuration as file already exists, run 'npm run config' to change your configuration."); } else { require('./config.js'); } -} catch(err) { - console.error(err) +} catch (err) { + console.error(err); +} + +try { + if (!fs.existsSync(consoleErrorsPath)) { + const consoleErrorsFileContent = `{ + "consoleErrors": [] +}`; + + fs.writeFileSync(consoleErrorsPath, consoleErrorsFileContent); + } +} catch (err) { + console.error(err); }