V14 added test for the Templates (#15179)

* Updated existing locator as it was prone to failing

* Removed old tests from earlier versions

* Added a timeout and an await. This was because the locator sometimes failed

* Added missing import for crypto

* Updated locator as it sometimes failed.

* Updated the README to include information for using the UI mode for playwright

* Bumped the timeout time for our tests

* We updated the naming for out methods in our testHelpers, so we need to update the usage as well

* Added additional timeout

* Updated the config so it is easier to understand what you need to input

* Added UI acceptance tests for templates

* Added types/node, allows us to use crypto. Updated the testhelpers to use the newest version.

* fixed error with testhelper dependency

* Bumped testhelper version

* Moved to settings instead of templating
This commit is contained in:
Andreas Zerbst
2023-11-13 09:36:23 +01:00
committed by GitHub
parent 589c74e918
commit 3d6c5850dc
13 changed files with 333 additions and 126 deletions

View File

@@ -32,6 +32,18 @@ For example to run the Login Test,
npx playwright test tests/DefaultConfig/Login/Login.spec.ts
### Executing tests in UI Mode
If you would like to have an overview of all your test, to be able to see all the steps in the tests being executed and you would like to be able to run all of your tests one after another, and maybe only just one test. Then you should use UI Mode. As before, you need to run these commands in the 'tests/Umbraco.Tests.AcceptanceTest' folder.
npx playwright test --ui
You can also specify which tests you want to run
npx playwright test --ui tests/DefaultConfig
When entering UI Mode, you might only able to see the authenticate test. To fix this you will need to click on the 'Projects' in UI mode and select 'Chromium'. After you've done this. You should be able to see all your tests for the location you specified when running the command.
### Environment Configuration
The environment configuration is begin setup by the npm installation script.
@@ -48,4 +60,4 @@ You can change this if you like or run the config script to reset the values, ty
### Documentation
For further documentation on Playwright, see the [Playwright documentation](https://playwright.dev/docs/intro).
For further documentation on Playwright, see the [Playwright documentation](https://playwright.dev/docs/intro).

View File

@@ -3,12 +3,12 @@ const fs = require('fs');
const properties = [
{
description: 'Enter your superadmin username/email',
description: 'Enter your umbraco superadmin username/email',
name: 'username',
required: true
},
{
description: 'Enter your superadmin password',
description: 'Enter your umbraco superadmin password',
name: 'password',
hidden: true,
required: true
@@ -22,7 +22,7 @@ const properties = [
const configPath = './.env'
console.log("Configure your test enviroment")
console.log("Configure your umbraco test environment")
prompt.start();

View File

@@ -8,7 +8,7 @@
"hasInstallScript": true,
"dependencies": {
"@umbraco/json-models-builders": "^1.0.6",
"@umbraco/playwright-testhelpers": "2.0.0-beta.4",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.5",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",
@@ -18,6 +18,7 @@
},
"devDependencies": {
"@playwright/test": "^1.38",
"@types/node": "^20.9.0",
"del": "^6.0.0",
"ncp": "^2.0.0",
"prompt": "^1.2.0",
@@ -86,12 +87,12 @@
}
},
"node_modules/@playwright/test": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.38.0.tgz",
"integrity": "sha512-xis/RXXsLxwThKnlIXouxmIvvT3zvQj1JE39GsNieMUrMpb3/GySHDh2j8itCG22qKVD4MYLBp7xB73cUW/UUw==",
"version": "1.39.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.39.0.tgz",
"integrity": "sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==",
"dev": true,
"dependencies": {
"playwright": "1.38.0"
"playwright": "1.39.0"
},
"bin": {
"playwright": "cli.js"
@@ -122,9 +123,13 @@
"dev": true
},
"node_modules/@types/node": {
"version": "7.10.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.14.tgz",
"integrity": "sha512-29GS75BE8asnTno3yB6ubOJOO0FboExEqNJy4bpz0GSmW/8wPTNL4h9h63c6s1uTrOopCmJYe/4yJLh5r92ZUA=="
"version": "20.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/@umbraco/json-models-builders": {
"version": "1.0.6",
@@ -136,12 +141,10 @@
}
},
"node_modules/@umbraco/playwright-testhelpers": {
"version": "2.0.0-beta.4",
"resolved": "file:../../../LogViewerHelpers/umbraco-playwright-testhelpers-2.0.0-beta.4.tgz",
"integrity": "sha512-Ea0U9BdtKI1hHECUl5F8qny2NKcQ75MJHC/FblauzejjXvE9lIAXzkhcqoZl7vxlVgF/Ihz5nBNuEYQ4HMI5lg==",
"license": "MIT",
"version": "2.0.0-beta.5",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.5.tgz",
"integrity": "sha512-vOMqYhtlret7IGmp3xXoR0r+EzTXY3maVBUgt9LZPZo1VOQwG1o6oTfR9QGF9VY+usRXesQjYEf2S2ZT6dGrSg==",
"dependencies": {
"@types/node": "^7.0.5",
"@umbraco/json-models-builders": "^1.0.6",
"camelize": "^1.0.0",
"faker": "^4.1.0",
@@ -181,7 +184,7 @@
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "0.25.0",
@@ -297,7 +300,7 @@
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"engines": {
"node": ">=0.4.0"
}
@@ -337,12 +340,12 @@
"node_modules/faker": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/faker/-/faker-4.1.0.tgz",
"integrity": "sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8="
"integrity": "sha512-ILKg69P6y/D8/wSmDXw35Ly0re8QzQ8pMfBCflsGiZG2ZjMUNLYNexA6lz5pkmJlepVdsiDFUxYAzPQ9/+iGLA=="
},
"node_modules/fast-glob": {
"version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
"integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==",
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
"dev": true,
"dependencies": {
"@nodelib/fs.stat": "^2.0.2",
@@ -356,9 +359,9 @@
}
},
"node_modules/fastq": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz",
"integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==",
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz",
"integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==",
"dev": true,
"dependencies": {
"reusify": "^1.0.4"
@@ -377,9 +380,9 @@
}
},
"node_modules/follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
"version": "1.15.3",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz",
"integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==",
"dev": true,
"funding": [
{
@@ -482,15 +485,15 @@
}
},
"node_modules/graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"dev": true
},
"node_modules/ignore": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
"integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
"version": "5.2.4",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",
"integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==",
"dev": true,
"engines": {
"node": ">= 4"
@@ -576,15 +579,15 @@
"dev": true
},
"node_modules/joi": {
"version": "17.6.3",
"resolved": "https://registry.npmjs.org/joi/-/joi-17.6.3.tgz",
"integrity": "sha512-YlQsIaS9MHYekzf1Qe11LjTkNzx9qhYluK3172z38RxYoAUf82XMX1p1DG1H4Wtk2ED/vPdSn9OggqtDu+aTow==",
"version": "17.11.0",
"resolved": "https://registry.npmjs.org/joi/-/joi-17.11.0.tgz",
"integrity": "sha512-NgB+lZLNoqISVy1rZocE9PZI36bL/77ie924Ri43yEvi9GUUMPeyVIr8KdFTMUlby1p0PBYMk9spIxEUQYqrJQ==",
"dev": true,
"dependencies": {
"@hapi/hoek": "^9.0.0",
"@hapi/topo": "^5.0.0",
"@sideway/address": "^4.1.3",
"@sideway/formula": "^3.0.0",
"@sideway/formula": "^3.0.1",
"@sideway/pinpoint": "^2.0.0"
}
},
@@ -617,19 +620,19 @@
}
},
"node_modules/mime-db": {
"version": "1.51.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
"integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==",
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.34",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
"integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.51.0"
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
@@ -648,9 +651,9 @@
}
},
"node_modules/minimist": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -672,9 +675,9 @@
}
},
"node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
@@ -745,15 +748,15 @@
}
},
"node_modules/playwright": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.38.0.tgz",
"integrity": "sha512-fJGw+HO0YY+fU/F1N57DMO+TmXHTrmr905J05zwAQE9xkuwP/QLDk63rVhmyxh03dYnEhnRbsdbH9B0UVVRB3A==",
"version": "1.39.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.39.0.tgz",
"integrity": "sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==",
"dev": true,
"dependencies": {
"playwright-core": "1.38.0"
"playwright-core": "1.39.0"
},
"bin": {
"playwright-core": "cli.js"
"playwright": "cli.js"
},
"engines": {
"node": ">=16"
@@ -763,9 +766,9 @@
}
},
"node_modules/playwright-core": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.0.tgz",
"integrity": "sha512-f8z1y8J9zvmHoEhKgspmCvOExF2XdcxMW8jNRuX4vkQFrzV4MlZ55iwb5QeyiFQgOFCUolXiRHgpjSEnqvO48g==",
"version": "1.39.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz",
"integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==",
"dev": true,
"bin": {
"playwright-core": "cli.js"
@@ -880,9 +883,9 @@
}
},
"node_modules/rxjs": {
"version": "7.5.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz",
"integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==",
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz",
"integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==",
"dev": true,
"dependencies": {
"tslib": "^2.1.0"
@@ -924,15 +927,15 @@
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
"dev": true
},
"node_modules/typescript": {
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
@@ -942,6 +945,12 @@
"node": ">=4.2.0"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
},
"node_modules/wait-on": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/wait-on/-/wait-on-6.0.1.tgz",
@@ -976,12 +985,12 @@
}
},
"node_modules/winston": {
"version": "2.4.6",
"resolved": "https://registry.npmjs.org/winston/-/winston-2.4.6.tgz",
"integrity": "sha512-J5Zu4p0tojLde8mIOyDSsmLmcP8I3Z6wtwpTDHx1+hGcdhxcJaAmG4CFtagkb+NiN1M9Ek4b42pzMWqfc9jm8w==",
"version": "2.4.7",
"resolved": "https://registry.npmjs.org/winston/-/winston-2.4.7.tgz",
"integrity": "sha512-vLB4BqzCKDnnZH9PHGoS2ycawueX4HLqENXQitvFHczhgW2vFpSOn31LZtVr1KU8YTw7DS4tM+cqyovxo8taVg==",
"dev": true,
"dependencies": {
"async": "^3.2.3",
"async": "^2.6.4",
"colors": "1.0.x",
"cycle": "1.0.x",
"eyes": "0.1.x",
@@ -992,6 +1001,15 @@
"node": ">= 0.10.0"
}
},
"node_modules/winston/node_modules/async": {
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dev": true,
"dependencies": {
"lodash": "^4.17.14"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@@ -11,6 +11,7 @@
},
"devDependencies": {
"@playwright/test": "^1.38",
"@types/node": "^20.9.0",
"del": "^6.0.0",
"ncp": "^2.0.0",
"prompt": "^1.2.0",
@@ -20,7 +21,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^1.0.6",
"@umbraco/playwright-testhelpers": "2.0.0-beta.4",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.5",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",

View File

@@ -8,7 +8,7 @@ export const STORAGE_STATE = path.join(__dirname, 'playwright/.auth/user.json');
export default defineConfig({
testDir: './tests/',
/* Maximum time one test can run for. */
timeout: 40 * 1000,
timeout: 60 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.

View File

@@ -7,7 +7,7 @@ test.describe('Template tests', () => {
const templateAlias = AliasHelper.toAlias(templateName);
test.beforeEach(async ({page, umbracoApi}) => {
await umbracoApi.template.ensureNameNotExistsAtRoot(templateName);
await umbracoApi.template.ensureNameNotExists(templateName);
});
test.afterEach(async ({page, umbracoApi}) => {
@@ -18,7 +18,7 @@ test.describe('Template tests', () => {
templateId = await umbracoApi.template.create(templateName, templateAlias, 'Template Stuff');
// Assert
await expect(umbracoApi.template.exists(templateId)).toBeTruthy();
await expect(umbracoApi.template.doesExist(templateId)).toBeTruthy();
});
test('can update a template', async ({page, umbracoApi, umbracoUi}) => {
@@ -33,7 +33,7 @@ test.describe('Template tests', () => {
await umbracoApi.template.update(templateId, templateData);
// Assert
await expect(umbracoApi.template.exists(templateId)).toBeTruthy();
await expect(umbracoApi.template.doesExist(templateId)).toBeTruthy();
// Checks if the template alias was updated
const updatedTemplate = await umbracoApi.template.get(templateId);
await expect(updatedTemplate.alias).toEqual(newTemplateAlias);
@@ -42,11 +42,11 @@ test.describe('Template tests', () => {
test('can delete template', async ({page, umbracoApi, umbracoUi}) => {
templateId = await umbracoApi.template.create(templateName, templateAlias, 'More Template Stuff');
await expect(umbracoApi.template.exists(templateId)).toBeTruthy();
await expect(umbracoApi.template.doesExist(templateId)).toBeTruthy();
await umbracoApi.template.delete(templateId);
// Assert
await expect(await umbracoApi.template.exists(templateId)).toBeFalsy();
await expect(await umbracoApi.template.doesExist(templateId)).toBeFalsy();
});
});

View File

@@ -1,5 +1,6 @@
import {test} from "@umbraco/playwright-testhelpers";
import {expect} from "@playwright/test";
import * as crypto from 'crypto';
test.describe('Temporary File tests', () => {
const temporaryFileId = crypto.randomUUID();

View File

@@ -1,5 +1,6 @@
import {test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";
import * as crypto from 'crypto';
test.describe('User Avatar Tests', () => {
// User

View File

@@ -1,41 +0,0 @@
import { test } from '@umbraco/playwright-testhelpers';
import { expect } from '@playwright/test';
test.describe("Help panel links", () => {
const enCulture = "en-US";
test.beforeEach(async ({ umbracoApi }, testInfo) => {
await umbracoApi.report.report(testInfo);
await umbracoApi.login();
await umbracoApi.users.setCurrentLanguage(enCulture);
});
test.afterEach(async ({ umbracoApi }) => {
await umbracoApi.users.setCurrentLanguage(enCulture);
});
test("Check the youtube link works as expected", async ({ page, umbracoUi }) => {
// Action
await umbracoUi.clickElement(umbracoUi.getGlobalHelp());
let watchVideoLink = await page.locator('[key="help_umbracoLearningBase"]');
await watchVideoLink.click();
// Wait for a popup event
const youtubeConsent = page.waitForEvent("popup");
const youtubePopup = await youtubeConsent;
if (youtubePopup) {
// If the YouTube consent popup is displayed, interact with it
const rejectAllButton = await youtubePopup.locator('[aria-label="Reject all"]').first();
await rejectAllButton.waitFor({ state: "visible" });
await rejectAllButton.click();
// Assert the URL of the popup
await expect(youtubePopup).toHaveURL(/.*UmbracoLearningBase/);
await youtubePopup.close();
} else {
await expect(page).toHaveURL(/.*UmbracoLearningBase/);
}
});
});

View File

@@ -17,7 +17,8 @@ test.describe('Log Viewer tests', () => {
// Assert
// Checks if there is a log with the telemetry level to minimal
await expect(page.getByRole('group').first()).toContainText('Telemetry level set to "' + telemetryLevel + '"');
await page.waitForTimeout(1000);
await expect(await page.getByRole('group').first()).toContainText('Telemetry level set to "' + telemetryLevel + '"');
// Clean
await umbracoApi.telemetry.setLevel(startTelemetryLevel);

View File

@@ -0,0 +1,215 @@
import {AliasHelper, ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";
test.describe('Template tests', () => {
const templateName = 'TestTemplate';
test.beforeEach(async ({page, umbracoApi}) => {
await umbracoApi.template.ensureNameNotExists(templateName);
});
test('can create a template', async ({page, umbracoApi, umbracoUi}) => {
// Act
await page.goto(umbracoApi.baseUrl + '/umbraco');
await umbracoUi.goToSection(ConstantHelper.sections.settings);
await page.locator('umb-tree-item', {hasText: 'Templates'}).getByLabel('Open actions menu').click({force: true});
await page.getByLabel('Create').click();
await page.getByLabel('template name').fill(templateName);
// TODO: Remove this timeout when frontend validation is implemented
await page.waitForTimeout(1000);
await page.getByLabel('Save').click();
// Assert
await umbracoUi.isSuccessNotificationVisible();
expect(await umbracoApi.template.doesNameExist(templateName)).toBeTruthy();
// Clean
await umbracoApi.template.ensureNameNotExists(templateName);
});
test('can update a template', async ({page, umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
const updatedTemplateContent = '@using Umbraco.Cms.Web.Common.PublishedModels;\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n' +
'@{\r\n' +
'\tLayout = null;\r\n' +
'}\r\n' +
'<p>AcceptanceTests</p>';
await umbracoApi.template.create(templateName, templateAlias, '');
// Act
await page.goto(umbracoApi.baseUrl + '/umbraco');
await umbracoUi.goToTemplate(templateName)
await page.locator('textarea.inputarea').clear();
await page.locator('textarea.inputarea').fill(updatedTemplateContent);
await page.getByLabel('Save').click();
// Assert
await umbracoUi.isSuccessNotificationVisible();
// Checks if the template was updated
const updatedTemplate = await umbracoApi.template.getByName(templateName);
expect(updatedTemplate.content).toBe(updatedTemplateContent);
// Clean
await umbracoApi.template.ensureNameNotExists(templateName);
});
test('can delete a template', async ({page, umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
await umbracoApi.template.create(templateName, templateAlias, '');
// Act
await page.goto(umbracoApi.baseUrl + '/umbraco');
await umbracoUi.goToSection(ConstantHelper.sections.settings);
await page.locator('umb-tree-item', {hasText: 'Templates'}).locator('#caret-button').click();
await page.locator('umb-tree-item').locator('[label="' + templateName + '"] >> [label="Open actions menu"]').click();
await page.getByLabel('Delete').click();
await page.locator('#confirm').getByLabel('Delete').click();
// Assert
await umbracoUi.isSuccessNotificationVisible();
expect(await umbracoApi.template.doesNameExist(templateName)).toBeFalsy();
});
test('can set a template as master template', async ({page, umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
const childTemplateName = 'ChildTemplate';
const childTemplateAlias = AliasHelper.toAlias(childTemplateName);
await umbracoApi.template.ensureNameNotExists(childTemplateName);
await umbracoApi.template.create(templateName, templateAlias, '');
await umbracoApi.template.create(childTemplateName, childTemplateAlias, '');
// Act
await page.goto(umbracoApi.baseUrl + '/umbraco');
await umbracoUi.goToTemplate(childTemplateName);
await page.getByLabel('Change Master template').click();
await page.locator('umb-tree-picker-modal').locator('#caret-button').click();
await page.getByRole('button', {name: templateName}).click();
await page.getByLabel('Submit').click();
await page.getByLabel('Save').click();
// Assert
await umbracoUi.isSuccessNotificationVisible();
await expect(page.locator('[label="Change Master template"]', {hasText: 'Master template: ' + templateName})).toBeVisible();
// Checks if the childTemplate has the masterTemplate set
const childTemplate = await umbracoApi.template.getByName(childTemplateName);
const masterTemplate = await umbracoApi.template.getByName(templateName);
expect(childTemplate.masterTemplateId).toBe(masterTemplate.id);
// Clean
await umbracoApi.template.ensureNameNotExists(templateName);
await umbracoApi.template.ensureNameNotExists(childTemplateName);
});
test('can use query builder for a template', async ({page, umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
await umbracoApi.template.create(templateName, templateAlias, '');
const expectedTemplateContent = '\r\n' +
'@{\r\n' +
'\tvar selection = Umbraco.ContentAtRoot().FirstOrDefault()\r\n' +
' .Children()\r\n' +
' .Where(x => x.IsVisible());\r\n' +
'}\r\n' +
'<ul>\r\n' +
'\t@foreach (var item in selection)\r\n' +
'\t{\r\n' +
'\t\t<li>\r\n' +
'\t\t\t<a href="@item.Url()">@item.Name()</a>\r\n' +
'\t\t</li>\r\n' +
'\t}\r\n' +
'</ul>\r\n' +
'\r\n' +
'@using Umbraco.Cms.Web.Common.PublishedModels;\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n' +
'@{\r\n' +
'\tLayout = null;\r\n' +
'}';
// Act
await page.goto(umbracoApi.baseUrl + '/umbraco');
await umbracoUi.goToTemplate(templateName);
await page.locator('#query-builder-button').getByLabel('Query builder').click();
await page.waitForTimeout(1000);
await page.locator('#property-alias-dropdown').getByLabel('Property alias').click({force: true});
await page.waitForTimeout(1000);
await page.locator('#property-alias-dropdown').getByText('CreateDate').click({force:true});
await page.getByLabel('Submit').click();
await page.getByLabel('Save').click();
// Assert
await umbracoUi.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(expectedTemplateContent);
// Clean
await umbracoApi.template.ensureNameNotExists(templateName);
});
test('can insert sections into a template', async ({page, umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
await umbracoApi.template.create(templateName, templateAlias, '');
const templateContent = '@RenderBody()@using Umbraco.Cms.Web.Common.PublishedModels;\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n' +
'@{\r\n' +
'\tLayout = null;\r\n' +
'}';
// Act
await page.goto(umbracoApi.baseUrl + '/umbraco');
await umbracoUi.goToTemplate(templateName);
await page.locator('#sections-button', {hasText: 'Sections'}).click();
await page.getByLabel('Submit').click();
await page.getByLabel('Save').click();
// Assert
await umbracoUi.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(templateContent);
// Clean
await umbracoApi.template.ensureNameNotExists(templateName);
});
test('can insert dictionaryItem into a template', async ({page, umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
await umbracoApi.template.create(templateName, templateAlias, '');
const dictionaryName = 'TestDictionary';
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoApi.dictionary.create(dictionaryName);
const templateContent = '@Umbraco.GetDictionaryValue("TestDictionary")@using Umbraco.Cms.Web.Common.PublishedModels;\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n' +
'@{\r\n' +
'\tLayout = null;\r\n' +
'}';
// Act
await page.goto(umbracoApi.baseUrl + '/umbraco');
await umbracoUi.goToTemplate(templateName);
await page.getByLabel('Choose value to insert').click();
await page.getByLabel('Insert Dictionary item').click({force: true});
// We need to wait for the modal to load before clicking the button
await page.waitForTimeout(1000);
await page.locator('umb-tree-picker-modal').locator('#caret-button').click({force: true});
await page.getByLabel(dictionaryName).click();
await page.getByLabel('Submit').click();
await page.getByLabel('Save').click();
// Assert
await umbracoUi.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(templateContent);
// Clean
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoApi.template.ensureNameNotExists(templateName);
});
});

View File

@@ -20,8 +20,7 @@ test.describe('Telemetry tests', () => {
await page.getByRole('tab', { name: 'Settings' }).click();
await page.getByRole('tab', {name: 'Telemetry Data'}).click();
await page.locator('[name="telemetryLevel"] >> input[id=input]').fill('1');
await page.getByRole('button', { name: 'Save telemetry settings' }).click();
await page.getByLabel('Save').click();
// Assert
// UI
await page.reload();

View File

@@ -1,5 +1,5 @@
import {test as setup, expect} from '@playwright/test';
import {STORAGE_STATE} from '../playwright.config'
import {STORAGE_STATE} from '../playwright.config';
import {UiHelpers} from "@umbraco/playwright-testhelpers";
setup('authenticate', async ({page}) => {
@@ -11,7 +11,7 @@ setup('authenticate', async ({page}) => {
await page.getByRole('button', {name: 'Login'}).click();
// Assert
await expect(page.getByRole('tab', {name: 'Settings'})).toBeVisible();
await expect(page.locator('uui-tab-group').locator('[label="Settings"]')).toBeVisible({timeout: 10000});
await umbracoUi.goToSection('Settings');
await page.context().storageState({path: STORAGE_STATE});
});