diff --git a/package.json b/package.json index e4e4a3bd4e..8185d0bbb0 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "@rollup/plugin-json": "^4.0.2", "babel-eslint": "^10.0.3", "eslint": "^6.8.0", + "eslint-plugin-cypress": "^2.11.1", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-svelte3": "^2.7.3", "lerna": "3.14.1", @@ -31,4 +32,4 @@ "@material/icon-button": "4.0.0", "date-fns": "^2.10.0" } -} \ No newline at end of file +} diff --git a/packages/builder/cypress/plugins/index.js b/packages/builder/cypress/plugins/index.js deleted file mode 100644 index aa9918d215..0000000000 --- a/packages/builder/cypress/plugins/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/// -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/** - * @type {Cypress.PluginConfig} - */ -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config -} diff --git a/packages/builder/cypress/setup.js b/packages/builder/cypress/setup.js index b737f3ef2e..aca5ed627f 100644 --- a/packages/builder/cypress/setup.js +++ b/packages/builder/cypress/setup.js @@ -3,8 +3,8 @@ // 2. Initialises using `.budibase-cypress` // 3. Runs the server using said folder -const rimraf = require("rimraf"); -const homedir = require('os').homedir() + '/.budibase-cypress'; +const rimraf = require("rimraf") +const homedir = require("os").homedir() + "/.budibase-cypress" const { execSync } = require("child_process") rimraf.sync(homedir) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 8e8c31d798..ed19ba8233 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -25,76 +25,81 @@ // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) Cypress.Commands.add("createApp", (name, description) => { - cy.get('.banner-button') - .click() - .get('input[name="name"]') - .type(name).should('have.value', name) + cy.get(".banner-button") + .click() + .get('input[name="name"]') + .type(name) + .should("have.value", name) - cy.get('textarea[name="description"]') - .type(description).should('have.value', description) + cy.get('textarea[name="description"]') + .type(description) + .should("have.value", description) - cy.contains('Save').click() + cy.contains("Save").click() }) Cypress.Commands.add("createModel", (modelName, firstField, secondField) => { - // Enter model name - cy.get('[data-cy=Name]').click() - .type(modelName) + // Enter model name + cy.get("[data-cy=Name]") + .click() + .type(modelName) - // Add 'name' field - cy.get('[data-cy=add-new-model-field]').click() - cy.get('[data-cy=Name]').click() - .type(firstField) - cy.contains('Save').click() + // Add 'name' field + cy.get("[data-cy=add-new-model-field]").click() + cy.get("[data-cy=Name]") + .click() + .type(firstField) + cy.contains("Save").click() + // Add 'age' field + cy.get("[data-cy=add-new-model-field]").click() - // Add 'age' field - cy.get('[data-cy=add-new-model-field]').click() + cy.get("[data-cy=Name]") + .click() + .type(secondField) + cy.get("select").select("number") + cy.contains("Save").click() + cy.contains(secondField).should("exist") - cy.get('[data-cy=Name]').click() - .type(secondField) - cy.get('select').select('number') - cy.contains('Save').click() - cy.contains(secondField).should('exist') - - // Save model - cy.contains('Save').click() + // Save model + cy.contains("Save").click() }) Cypress.Commands.add("addRecord", (firstField, secondField) => { - cy.contains('Create new record') - .click() + cy.contains("Create new record").click() - cy.get('[data-cy=name-input]').click().type(firstField) - cy.get('[data-cy=age-input]').click().type(secondField) + cy.get("[data-cy=name-input]") + .click() + .type(firstField) + cy.get("[data-cy=age-input]") + .click() + .type(secondField) - // Save - cy.contains('Save').click() + // Save + cy.contains("Save").click() }) Cypress.Commands.add("createUser", (username, password, level) => { - // Create User - cy.get('.nav-group-header > .ri-add-line') - .click() + // Create User + cy.get(".nav-group-header > .ri-add-line").click() - cy.get('[data-cy=username]').type(username) - cy.get('[data-cy=password]').type(password) - cy.get('[data-cy=accessLevel]').select(level) + cy.get("[data-cy=username]").type(username) + cy.get("[data-cy=password]").type(password) + cy.get("[data-cy=accessLevel]").select(level) - // Save - cy.contains('Save').click() + // Save + cy.contains("Save").click() }) -Cypress.Commands.add("addHeadlineComponent", (text) => { - cy.get('.switcher > :nth-child(2)').click() +Cypress.Commands.add("addHeadlineComponent", text => { + cy.get(".switcher > :nth-child(2)").click() - cy.get('[data-cy=Text]').click() - cy.get('[data-cy=Headline]').click() - cy.get('.tabs > :nth-child(2)').click() - cy.get('input[type="text"]') - .type(text) - cy.contains('Design').click() + cy.get("[data-cy=Text]").click() + cy.get("[data-cy=Headline]").click() + cy.get(".tabs > :nth-child(2)").click() + cy.get('input[type="text"]').type(text) + cy.contains("Design").click() }) -Cypress.Commands.add("addButtonComponent", (text) => { - cy.get('.switcher > :nth-child(2)').click() +Cypress.Commands.add("addButtonComponent", () => { + cy.get(".switcher > :nth-child(2)").click() - cy.get('[data-cy=Button]').click() -}) \ No newline at end of file + cy.get("[data-cy=Button]").click() +}) diff --git a/packages/builder/cypress/support/index.js b/packages/builder/cypress/support/index.js index d68db96df2..a80764cb2c 100644 --- a/packages/builder/cypress/support/index.js +++ b/packages/builder/cypress/support/index.js @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import "./commands" // Alternatively you can use CommonJS syntax: // require('./commands') diff --git a/packages/builder/package.json b/packages/builder/package.json index 56ee5135e3..49331426b4 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -41,6 +41,11 @@ "/node_modules/(?!svelte).+\\.js$" ] }, + "eslintConfig": { + "extends": [ + "plugin:cypress/recommended" + ] + }, "dependencies": { "@beyonk/svelte-notifications": "^2.0.3", "@budibase/bbui": "^1.1.1", diff --git a/yarn.lock b/yarn.lock index bb8ac784f1..cd956d394d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1980,6 +1980,13 @@ escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +eslint-plugin-cypress@^2.11.1: + version "2.11.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-cypress/-/eslint-plugin-cypress-2.11.1.tgz#a945e2774b88211e2c706a059d431e262b5c2862" + integrity sha512-MxMYoReSO5+IZMGgpBZHHSx64zYPSPTpXDwsgW7ChlJTF/sA+obqRbHplxD6sBStE+g4Mi0LCLkG4t9liu//mQ== + dependencies: + globals "^11.12.0" + eslint-plugin-prettier@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz#432e5a667666ab84ce72f945c72f77d996a5c9ba" @@ -2526,7 +2533,7 @@ glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^11.1.0: +globals@^11.1.0, globals@^11.12.0: version "11.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==