From 092748d2de28f04444718f58dac5ff39da3843a2 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Mon, 4 Sep 2023 16:00:59 +1200 Subject: [PATCH 1/4] test smoke suite --- .github/workflows/cypress.yaml | 2 ++ cypress/e2e/composer/composer.spec.ts | 2 +- cypress/e2e/create-room/create-room.spec.ts | 2 +- cypress/e2e/crypto/crypto.spec.ts | 2 +- cypress/e2e/invite/invite-dialog.spec.ts | 2 +- cypress/e2e/login/login.spec.ts | 2 +- cypress/e2e/spotlight/spotlight.spec.ts | 4 +-- cypress/plugins/index.ts | 3 ++ cypress/support/e2e.ts | 2 ++ package.json | 3 +- yarn.lock | 39 ++++++++++++++++++--- 11 files changed, 51 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 070dee5b5ea..7b979ea5c9b 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -198,6 +198,8 @@ jobs: COMMIT_INFO_EMAIL: ${{ needs.prepare.outputs.commit_email }} CYPRESS_PULL_REQUEST_ID: ${{ needs.prepare.outputs.pr_id }} CYPRESS_PULL_REQUEST_URL: https://github.com/${{ github.repository }}/pull/${{ needs.prepare.outputs.pr_id }} + + CYPRESS_grepTags: smoke # pass the Percy token as an environment variable PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} diff --git a/cypress/e2e/composer/composer.spec.ts b/cypress/e2e/composer/composer.spec.ts index 85e258a127c..8756a9ef191 100644 --- a/cypress/e2e/composer/composer.spec.ts +++ b/cypress/e2e/composer/composer.spec.ts @@ -40,7 +40,7 @@ describe("Composer", () => { cy.createRoom({ name: "Composing Room" }).then((roomId) => cy.viewRoomById(roomId)); }); - it("sends a message when you click send or press Enter", () => { + it("sends a message when you click send or press Enter", { tags: ["smoke"]}, () => { // Type a message cy.findByRole("textbox", { name: "Send a messageā€¦" }).type("my message 0"); // It has not been sent yet diff --git a/cypress/e2e/create-room/create-room.spec.ts b/cypress/e2e/create-room/create-room.spec.ts index 1ebc1a7df7a..863d32e082e 100644 --- a/cypress/e2e/create-room/create-room.spec.ts +++ b/cypress/e2e/create-room/create-room.spec.ts @@ -25,7 +25,7 @@ function openCreateRoomDialog(): Chainable> { return cy.get(".mx_CreateRoomDialog"); } -describe("Create Room", () => { +describe("Create Room", { tags: ["smoke"] }, () => { let homeserver: HomeserverInstance; beforeEach(() => { diff --git a/cypress/e2e/crypto/crypto.spec.ts b/cypress/e2e/crypto/crypto.spec.ts index 3c815ab4088..d29e18c13cc 100644 --- a/cypress/e2e/crypto/crypto.spec.ts +++ b/cypress/e2e/crypto/crypto.spec.ts @@ -127,7 +127,7 @@ const verify = function (this: CryptoTestContext) { }); }; -describe("Cryptography", function () { +describe("Cryptography", { tags: ["smoke"]}, function () { let aliceCredentials: UserCredentials; beforeEach(function () { diff --git a/cypress/e2e/invite/invite-dialog.spec.ts b/cypress/e2e/invite/invite-dialog.spec.ts index ba6aa4040d4..67bbb50367f 100644 --- a/cypress/e2e/invite/invite-dialog.spec.ts +++ b/cypress/e2e/invite/invite-dialog.spec.ts @@ -17,7 +17,7 @@ limitations under the License. import type { MatrixClient } from "matrix-js-sdk/src/matrix"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; -describe("Invite dialog", function () { +describe("Invite dialog", { tags: ["smoke"] }, function () { let homeserver: HomeserverInstance; let bot: MatrixClient; const botName = "BotAlice"; diff --git a/cypress/e2e/login/login.spec.ts b/cypress/e2e/login/login.spec.ts index 2bb7d4c6a00..dab734e4232 100644 --- a/cypress/e2e/login/login.spec.ts +++ b/cypress/e2e/login/login.spec.ts @@ -19,7 +19,7 @@ limitations under the License. import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { doTokenRegistration } from "./utils"; -describe("Login", () => { +describe("Login", { tags: ["smoke"]}, () => { let homeserver: HomeserverInstance; afterEach(() => { diff --git a/cypress/e2e/spotlight/spotlight.spec.ts b/cypress/e2e/spotlight/spotlight.spec.ts index d7ce14eff9e..491f9a70fb9 100644 --- a/cypress/e2e/spotlight/spotlight.spec.ts +++ b/cypress/e2e/spotlight/spotlight.spec.ts @@ -214,7 +214,7 @@ describe("Spotlight", () => { cy.stopHomeserver(homeserver); }); - it("should be able to add and remove filters via keyboard", () => { + it.skip("should be able to add and remove filters via keyboard", () => { cy.openSpotlightDialog().within(() => { cy.wait(1000); // wait for the dialog to settle, otherwise our keypresses might race with an update @@ -237,7 +237,7 @@ describe("Spotlight", () => { }); }); - it("should find joined rooms", () => { + it("kerry sshould find joined rooms", () => { cy.openSpotlightDialog() .within(() => { cy.spotlightSearch().clear().type(room1Name); diff --git a/cypress/plugins/index.ts b/cypress/plugins/index.ts index 412057cf544..ca604a1b4b3 100644 --- a/cypress/plugins/index.ts +++ b/cypress/plugins/index.ts @@ -17,6 +17,8 @@ limitations under the License. /// import installLogsPrinter from "cypress-terminal-report/src/installLogsPrinter"; +const registerCypressGrep = require('@cypress/grep/src/plugin') + import PluginEvents = Cypress.PluginEvents; import PluginConfigOptions = Cypress.PluginConfigOptions; import { synapseDocker } from "./synapsedocker"; @@ -32,6 +34,7 @@ import { mailhogDocker } from "./mailhog"; * @type {Cypress.PluginConfig} */ export default function (on: PluginEvents, config: PluginConfigOptions) { + registerCypressGrep(config); docker(on, config); synapseDocker(on, config); dendriteDocker(on, config); diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index 11eae401f9e..591fa97bb90 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -43,6 +43,8 @@ import "./axe"; import "./mailhog"; import "./promise"; + + installLogsCollector({ // specify the types of logs to collect (and report to the node console at the end of the test) collectTypes: [ diff --git a/package.json b/package.json index d6f63eed0c3..3378f8c84ba 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "lint:types": "tsc --noEmit --jsx react && tsc --noEmit --jsx react -p cypress", "lint:style": "stylelint \"res/css/**/*.pcss\"", "test": "jest", - "test:cypress": "cypress run", + "test:cypress": "cypress run --env grepTags=\"core\"", "test:cypress:open": "cypress open", "coverage": "yarn test --coverage" }, @@ -142,6 +142,7 @@ "@babel/register": "^7.12.10", "@babel/traverse": "^7.12.12", "@casualbot/jest-sonar-reporter": "^2.2.5", + "@cypress/grep": "^4.0.0", "@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz", "@peculiar/webcrypto": "^1.4.3", "@percy/cli": "^1.11.0", diff --git a/yarn.lock b/yarn.lock index 36fdf79b8b7..658ffcf6ae5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -442,6 +442,11 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.10.tgz#e37634f9a12a1716136c44624ef54283cabd3f55" integrity sha512-lNbdGsQb9ekfsnjFGhEiF4hfFqGgfOP3H3d27re3n+CGhNuTSUEQdfWk556sTLNTloczcdM5TYF2LhzmDQKyvQ== +"@babel/parser@^7.21.2": + version "7.22.14" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.14.tgz#c7de58e8de106e88efca42ce17f0033209dfd245" + integrity sha512-1KucTHgOvaw/LzCVrEOAyXkr9rQlp0A1HiHRYnSUE9dmb8PvPW7o5sscg+5169r54n3vGlbx6GevTE/Iw/P3AQ== + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.22.5.tgz#87245a21cd69a73b0b81bcda98d443d6df08f05e" @@ -575,7 +580,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-jsx@^7.22.5": +"@babel/plugin-syntax-jsx@^7.18.6", "@babel/plugin-syntax-jsx@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.22.5.tgz#a6b68e84fb76e759fc3b93e901876ffabbe1d918" integrity sha512-gvyP4hZrgrs/wWMaocvxZ44Hw0b3W8Pe+cMxc8V1ULQ07oh8VNbIRaoD1LRZVTvD+0nieDKjfgKg89sD7rrKrg== @@ -1372,6 +1377,15 @@ resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-3.0.0.tgz#798622546b63847e82389e473fd67f2707d82247" integrity sha512-hBI9tfBtuPIi885ZsZ32IMEU/5nlZH/KOVYJCOh7gyMxaVLGmLedYqFN6Ui1LXkI8JlC8IsuC0rF0btcRZKd5g== +"@cypress/grep@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@cypress/grep/-/grep-4.0.0.tgz#d219259c62704d86651deceb0bd2d2e80ec5b559" + integrity sha512-5+X1P+GJmLp2IgX/OjoktJxFrezy4pYGI2wmi+574OTZ99yhNTesjKhMm0UJeEMAv9MjfihagroKbjdKNp/+og== + dependencies: + debug "^4.3.4" + find-test-names "^1.19.0" + globby "^11.0.4" + "@cypress/request@^2.88.11": version "2.88.12" resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.12.tgz#ba4911431738494a85e93fb04498cb38bc55d590" @@ -3105,7 +3119,7 @@ acorn-jsx@^5.3.2: resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -acorn-walk@^8.0.2, acorn-walk@^8.1.1: +acorn-walk@^8.0.2, acorn-walk@^8.1.1, acorn-walk@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== @@ -4342,7 +4356,7 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -5460,6 +5474,18 @@ find-cache-dir@^2.0.0: make-dir "^2.0.0" pkg-dir "^3.0.0" +find-test-names@^1.19.0: + version "1.28.13" + resolved "https://registry.yarnpkg.com/find-test-names/-/find-test-names-1.28.13.tgz#871d5585d1f618ed772ffe544ea475ab4657ca83" + integrity sha512-hVatCLbiZmvBwqYNGTkVNbeJwK/8pvkXKQGji+23GzW8fVFHcEaRID77eQYItLKGwa1Tmu0AK2LjcUtuid57FQ== + dependencies: + "@babel/parser" "^7.21.2" + "@babel/plugin-syntax-jsx" "^7.18.6" + acorn-walk "^8.2.0" + debug "^4.3.3" + globby "^11.0.4" + simple-bin-help "^1.8.0" + find-up@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" @@ -5796,7 +5822,7 @@ globalthis@^1.0.3: dependencies: define-properties "^1.1.3" -globby@^11.1.0: +globby@^11.0.4, globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== @@ -9066,6 +9092,11 @@ signal-exit@^4.0.1: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.0.2.tgz#ff55bb1d9ff2114c13b400688fa544ac63c36967" integrity sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q== +simple-bin-help@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/simple-bin-help/-/simple-bin-help-1.8.0.tgz#21bb82c6bccd9fa8678f9c0fadf2956b54e2160a" + integrity sha512-0LxHn+P1lF5r2WwVB/za3hLRIsYoLaNq1CXqjbrs3ZvLuvlWnRKrUjEWzV7umZL7hpQ7xULiQMV+0iXdRa5iFg== + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" From 80cecd36954aa0951de9d9bdb1ffcdb2bbd946ce Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Mon, 4 Sep 2023 16:42:57 +1200 Subject: [PATCH 2/4] types, remove debug --- .eslintrc.js | 2 ++ .github/workflows/cypress.yaml | 2 +- cypress/e2e/composer/composer.spec.ts | 2 +- cypress/e2e/crypto/crypto.spec.ts | 2 +- cypress/e2e/login/login.spec.ts | 2 +- cypress/plugins/index.ts | 3 +-- cypress/support/e2e.ts | 2 -- cypress/tsconfig.json | 2 +- package.json | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 4434aecfdfe..7083e83cf7a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -265,6 +265,8 @@ module.exports = { "jest/valid-expect": "off", "jest/valid-expect-in-promise": "off", "jest/no-done-callback": "off", + // covered by types, cypress plugins add extra options arguments + "jest/valid-describe-callback": "off", }, }, ], diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 7b979ea5c9b..3d07442c17d 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -198,7 +198,7 @@ jobs: COMMIT_INFO_EMAIL: ${{ needs.prepare.outputs.commit_email }} CYPRESS_PULL_REQUEST_ID: ${{ needs.prepare.outputs.pr_id }} CYPRESS_PULL_REQUEST_URL: https://github.com/${{ github.repository }}/pull/${{ needs.prepare.outputs.pr_id }} - + CYPRESS_grepTags: smoke # pass the Percy token as an environment variable diff --git a/cypress/e2e/composer/composer.spec.ts b/cypress/e2e/composer/composer.spec.ts index 8756a9ef191..de260323d06 100644 --- a/cypress/e2e/composer/composer.spec.ts +++ b/cypress/e2e/composer/composer.spec.ts @@ -40,7 +40,7 @@ describe("Composer", () => { cy.createRoom({ name: "Composing Room" }).then((roomId) => cy.viewRoomById(roomId)); }); - it("sends a message when you click send or press Enter", { tags: ["smoke"]}, () => { + it("sends a message when you click send or press Enter", { tags: ["smoke"] }, () => { // Type a message cy.findByRole("textbox", { name: "Send a messageā€¦" }).type("my message 0"); // It has not been sent yet diff --git a/cypress/e2e/crypto/crypto.spec.ts b/cypress/e2e/crypto/crypto.spec.ts index d29e18c13cc..4edb39996de 100644 --- a/cypress/e2e/crypto/crypto.spec.ts +++ b/cypress/e2e/crypto/crypto.spec.ts @@ -127,7 +127,7 @@ const verify = function (this: CryptoTestContext) { }); }; -describe("Cryptography", { tags: ["smoke"]}, function () { +describe("Cryptography", { tags: ["smoke"] }, function () { let aliceCredentials: UserCredentials; beforeEach(function () { diff --git a/cypress/e2e/login/login.spec.ts b/cypress/e2e/login/login.spec.ts index dab734e4232..9453d5a5f0d 100644 --- a/cypress/e2e/login/login.spec.ts +++ b/cypress/e2e/login/login.spec.ts @@ -19,7 +19,7 @@ limitations under the License. import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { doTokenRegistration } from "./utils"; -describe("Login", { tags: ["smoke"]}, () => { +describe("Login", { tags: ["smoke"] }, () => { let homeserver: HomeserverInstance; afterEach(() => { diff --git a/cypress/plugins/index.ts b/cypress/plugins/index.ts index ca604a1b4b3..e34bba3b4ae 100644 --- a/cypress/plugins/index.ts +++ b/cypress/plugins/index.ts @@ -16,8 +16,7 @@ limitations under the License. /// import installLogsPrinter from "cypress-terminal-report/src/installLogsPrinter"; - -const registerCypressGrep = require('@cypress/grep/src/plugin') +import registerCypressGrep from "@cypress/grep/src/plugin"; import PluginEvents = Cypress.PluginEvents; import PluginConfigOptions = Cypress.PluginConfigOptions; diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index 591fa97bb90..11eae401f9e 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -43,8 +43,6 @@ import "./axe"; import "./mailhog"; import "./promise"; - - installLogsCollector({ // specify the types of logs to collect (and report to the node console at the end of the test) collectTypes: [ diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index bfff3775a4f..12c9a12f18c 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -3,7 +3,7 @@ "target": "es2016", "jsx": "react", "lib": ["es2020", "dom", "dom.iterable"], - "types": ["cypress", "cypress-axe", "@percy/cypress", "@testing-library/cypress"], + "types": ["cypress", "cypress-axe", "@percy/cypress", "@testing-library/cypress", "@cypress/grep"], "resolveJsonModule": true, "esModuleInterop": true, "moduleResolution": "node", diff --git a/package.json b/package.json index 3378f8c84ba..1b975bf3422 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "lint:types": "tsc --noEmit --jsx react && tsc --noEmit --jsx react -p cypress", "lint:style": "stylelint \"res/css/**/*.pcss\"", "test": "jest", - "test:cypress": "cypress run --env grepTags=\"core\"", + "test:cypress": "cypress run --env", "test:cypress:open": "cypress open", "coverage": "yarn test --coverage" }, From 4f155613a37ebae5398fd94acaf36dab1b1e77b8 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Mon, 4 Sep 2023 16:44:12 +1200 Subject: [PATCH 3/4] remove debug --- cypress/e2e/spotlight/spotlight.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/spotlight/spotlight.spec.ts b/cypress/e2e/spotlight/spotlight.spec.ts index 491f9a70fb9..d7ce14eff9e 100644 --- a/cypress/e2e/spotlight/spotlight.spec.ts +++ b/cypress/e2e/spotlight/spotlight.spec.ts @@ -214,7 +214,7 @@ describe("Spotlight", () => { cy.stopHomeserver(homeserver); }); - it.skip("should be able to add and remove filters via keyboard", () => { + it("should be able to add and remove filters via keyboard", () => { cy.openSpotlightDialog().within(() => { cy.wait(1000); // wait for the dialog to settle, otherwise our keypresses might race with an update @@ -237,7 +237,7 @@ describe("Spotlight", () => { }); }); - it("kerry sshould find joined rooms", () => { + it("should find joined rooms", () => { cy.openSpotlightDialog() .within(() => { cy.spotlightSearch().clear().type(room1Name); From 3bcdc9bb8f53a76689f742710a98063c0792652b Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Mon, 4 Sep 2023 16:44:58 +1200 Subject: [PATCH 4/4] tidy --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b975bf3422..1323d23e51f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "lint:types": "tsc --noEmit --jsx react && tsc --noEmit --jsx react -p cypress", "lint:style": "stylelint \"res/css/**/*.pcss\"", "test": "jest", - "test:cypress": "cypress run --env", + "test:cypress": "cypress run", "test:cypress:open": "cypress open", "coverage": "yarn test --coverage" },