From cbf8132b32a110e02ebf85596cefbb9cd49f50c7 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Thu, 2 Feb 2023 23:56:33 +0300 Subject: [PATCH] e2e: add base tests --- cypress/e2e/contacts.cy.ts | 36 ++++++++++++++++ cypress/e2e/dashboard.cy.ts | 8 ++++ cypress/e2e/example.cy.ts | 8 ---- cypress/support/pages.ts | 5 +++ flake.nix | 43 +++++++++++++++---- package-lock.json | 2 +- package.json | 2 +- .../ContactsTable/AudienceContactsTable.vue | 1 + .../lists/ListsSelect/AudienceListsSelect.vue | 2 +- src/shared/uikit/BaseSelect.vue | 3 +- src/shared/uikit/BaseTable.vue | 39 ++++++++++------- 11 files changed, 112 insertions(+), 37 deletions(-) create mode 100644 cypress/e2e/contacts.cy.ts create mode 100644 cypress/e2e/dashboard.cy.ts delete mode 100644 cypress/e2e/example.cy.ts create mode 100644 cypress/support/pages.ts diff --git a/cypress/e2e/contacts.cy.ts b/cypress/e2e/contacts.cy.ts new file mode 100644 index 0000000..65e3259 --- /dev/null +++ b/cypress/e2e/contacts.cy.ts @@ -0,0 +1,36 @@ +// https://docs.cypress.io/api/introduction/api.html + +import { Page } from "../support/pages"; + +describe("Contacts", () => { + beforeEach(() => { + cy.visit(Page.Contacts); + }); + + it("should open contacts page", () => { + cy.contains("h1", "Контакты"); + }); + + it("should load contacts table", () => { + cy.get("[cy-test=contacts-table-col-email]") + .should("have.length.gte", 20) + .first() + .should("have.text", "brendon.cremin91@gmail.com"); + }); + + it("should load lists select", () => { + cy.get("[cy-test=lists-select]") + .should("have.value", "") + .within(() => cy.get("option").should("have.length.gte", 20)); + }); + + it("should load contacts of selected list", () => { + cy.get("[cy-test=lists-select]") + .should("have.value", "") + .select("c407a7bd-7930-43bc-8241-2aafd058ed39"); + + cy.get("[cy-test=contacts-table-col-email]") + .first() + .should("have.text", "camryn90@yahoo.com"); + }); +}); diff --git a/cypress/e2e/dashboard.cy.ts b/cypress/e2e/dashboard.cy.ts new file mode 100644 index 0000000..883eefb --- /dev/null +++ b/cypress/e2e/dashboard.cy.ts @@ -0,0 +1,8 @@ +import { Page } from "../support/pages"; + +describe("Dashboard", () => { + it("should redirect to contacts page", () => { + cy.visit(Page.Dashboard); + cy.location("pathname").should("eq", Page.Contacts); + }); +}); diff --git a/cypress/e2e/example.cy.ts b/cypress/e2e/example.cy.ts deleted file mode 100644 index 3130c00..0000000 --- a/cypress/e2e/example.cy.ts +++ /dev/null @@ -1,8 +0,0 @@ -// https://docs.cypress.io/api/introduction/api.html - -describe("My First Test", () => { - it("visits the app root url", () => { - cy.visit("/"); - cy.contains("h1", "You did it!"); - }); -}); diff --git a/cypress/support/pages.ts b/cypress/support/pages.ts new file mode 100644 index 0000000..71c5b61 --- /dev/null +++ b/cypress/support/pages.ts @@ -0,0 +1,5 @@ +export enum Page { + Dashboard = "/", + Contacts = "/contacts", + CreateContact = "/contacts/new", +} diff --git a/flake.nix b/flake.nix index 5ead1ec..d2a6558 100644 --- a/flake.nix +++ b/flake.nix @@ -7,17 +7,42 @@ outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { inherit system; }; + cypressOverlay = final: prev: { + cypress = prev.cypress.overrideAttrs (oldAttrs: rec { + version = "12.3.0"; + + src = prev.fetchzip { + url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip"; + sha256 = "sha256-RhPH/MBF8lqXeFEm2sd73Z55jgcl45VsmRWtAhckrP0="; + }; + }); + }; + + pkgs = import nixpkgs { + inherit system; + overlays = [ cypressOverlay ]; + }; in { - devShells.default = pkgs.mkShell { - packages = with pkgs; [ - nodejs-18_x - nodePackages.vue-cli - nodePackages.vls # vue - nodePackages.typescript-language-server # typescript - nodePackages.vscode-langservers-extracted # html, css, json, eslint - ]; + devShells = rec { + code = pkgs.mkShell { + packages = with pkgs; [ + nodejs-18_x + nodePackages.vue-cli + nodePackages.vls # vue + nodePackages.typescript-language-server # typescript + nodePackages.vscode-langservers-extracted # html, css, json, eslint + ]; + }; + e2e = pkgs.mkShell { + shellHook = '' + export CYPRESS_INSTALL_BINARY=0; + export CYPRESS_RUN_BINARY="${pkgs.cypress}/bin/Cypress"; + ''; + }; + default = pkgs.mkShell { + inputsFrom = [ code e2e ]; + }; }; }); } diff --git a/package-lock.json b/package-lock.json index 5bedfd0..6b0181e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "@vue/eslint-config-typescript": "^11.0.0", "@vue/test-utils": "^2.2.6", "@vue/tsconfig": "^0.1.3", - "cypress": "^12.0.2", + "cypress": "^12.3.0", "eslint": "^8.22.0", "eslint-plugin-cypress": "^2.12.1", "eslint-plugin-vue": "^9.3.0", diff --git a/package.json b/package.json index e0e5378..8e37e41 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@vue/eslint-config-typescript": "^11.0.0", "@vue/test-utils": "^2.2.6", "@vue/tsconfig": "^0.1.3", - "cypress": "^12.0.2", + "cypress": "^12.3.0", "eslint": "^8.22.0", "eslint-plugin-cypress": "^2.12.1", "eslint-plugin-vue": "^9.3.0", diff --git a/src/app/contacts/ContactsTable/AudienceContactsTable.vue b/src/app/contacts/ContactsTable/AudienceContactsTable.vue index 5f572cc..779eef5 100644 --- a/src/app/contacts/ContactsTable/AudienceContactsTable.vue +++ b/src/app/contacts/ContactsTable/AudienceContactsTable.vue @@ -28,6 +28,7 @@ watch(