From e63ba70b85324ef6ed4610db176e82065e1fa041 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 26 Mar 2024 11:28:00 -0700 Subject: [PATCH 1/8] Install Prettier 3.2.5 in test/cy --- test/cy/package-lock.json | 16 ++++++++++++++++ test/cy/package.json | 1 + 2 files changed, 17 insertions(+) diff --git a/test/cy/package-lock.json b/test/cy/package-lock.json index e9efa1fca..d9ff8cbdf 100644 --- a/test/cy/package-lock.json +++ b/test/cy/package-lock.json @@ -8,6 +8,7 @@ "cypress": "^13.3.0", "eslint": "^8.51.0", "eslint-plugin-cypress": "^2.15.1", + "prettier": "3.2.5", "start-server-and-test": "^2.0.3" } }, @@ -2326,6 +2327,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", diff --git a/test/cy/package.json b/test/cy/package.json index a06d65b08..7b677d05f 100644 --- a/test/cy/package.json +++ b/test/cy/package.json @@ -19,6 +19,7 @@ "cypress": "^13.3.0", "eslint": "^8.51.0", "eslint-plugin-cypress": "^2.15.1", + "prettier": "3.2.5", "start-server-and-test": "^2.0.3" } } From 4d5237aa9f0ff8e086c57642def68d99a95bef89 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 26 Mar 2024 11:28:48 -0700 Subject: [PATCH 2/8] Create Prettier config file in test/cy --- test/cy/.prettierrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/cy/.prettierrc diff --git a/test/cy/.prettierrc b/test/cy/.prettierrc new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/test/cy/.prettierrc @@ -0,0 +1 @@ +{} From c74edd4402405449cdf7838e64bf53fab9e51698 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 26 Mar 2024 11:29:22 -0700 Subject: [PATCH 3/8] Install eslint-config-prettier in test/cy --- test/cy/package-lock.json | 13 +++++++++++++ test/cy/package.json | 1 + 2 files changed, 14 insertions(+) diff --git a/test/cy/package-lock.json b/test/cy/package-lock.json index d9ff8cbdf..ffa87a51e 100644 --- a/test/cy/package-lock.json +++ b/test/cy/package-lock.json @@ -7,6 +7,7 @@ "devDependencies": { "cypress": "^13.3.0", "eslint": "^8.51.0", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-cypress": "^2.15.1", "prettier": "3.2.5", "start-server-and-test": "^2.0.3" @@ -1029,6 +1030,18 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-plugin-cypress": { "version": "2.15.1", "resolved": "https://registry.npmjs.org/eslint-plugin-cypress/-/eslint-plugin-cypress-2.15.1.tgz", diff --git a/test/cy/package.json b/test/cy/package.json index 7b677d05f..ae0216742 100644 --- a/test/cy/package.json +++ b/test/cy/package.json @@ -18,6 +18,7 @@ "devDependencies": { "cypress": "^13.3.0", "eslint": "^8.51.0", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-cypress": "^2.15.1", "prettier": "3.2.5", "start-server-and-test": "^2.0.3" From 9a38c3808f523da9c4afd164a69ec2e56a6f1110 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 26 Mar 2024 11:29:59 -0700 Subject: [PATCH 4/8] Extend eslintrc with prettier in test/cy --- test/cy/.eslintrc.cjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/cy/.eslintrc.cjs b/test/cy/.eslintrc.cjs index 6e27995f3..dd1468127 100644 --- a/test/cy/.eslintrc.cjs +++ b/test/cy/.eslintrc.cjs @@ -1,5 +1,8 @@ module.exports = { - extends: ['plugin:cypress/recommended'], + extends: [ + 'plugin:cypress/recommended', + 'prettier' + ], plugins: ['cypress'], env: { 'cypress/globals': true, From 577709838d1edcd0c84af4ea88c1c530fd3ae1b5 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 26 Mar 2024 11:30:48 -0700 Subject: [PATCH 5/8] Add format and check-format npm script in test/cy --- test/cy/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cy/package.json b/test/cy/package.json index ae0216742..f60e6850e 100644 --- a/test/cy/package.json +++ b/test/cy/package.json @@ -3,6 +3,8 @@ "scripts": { "lint": "eslint --ext .js,.ts,.cjs .", "fix": "eslint --ext .js,.ts,.cjs . --fix", + "format": "prettier . --write", + "check-format": "prettier . --check", "init": "just ../../run init ./test/sample-content/fastapi-simple", "start": "just ../../run ui --listen 127.0.0.1:9000 ./test/sample-content/fastapi-simple", "test": "start-server-and-test --expect 200 start http-get://127.0.0.1:9000 run", From bd78458dc9e7a636ac23ca01180879696b9bbc01 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 26 Mar 2024 11:33:06 -0700 Subject: [PATCH 6/8] Add format just commands in test/cy --- test/cy/justfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/cy/justfile b/test/cy/justfile index b269eadb5..948216cdf 100644 --- a/test/cy/justfile +++ b/test/cy/justfile @@ -46,6 +46,20 @@ lint: npm run lint +format: + #!/usr/bin/env bash + set -eou pipefail + {{ _with_debug }} + + npm run format + +check-format: + #!/usr/bin/env bash + set -eou pipefail + {{ _with_debug }} + + npm run check-format + # Install dependencies install: #!/usr/bin/env bash From 7737c79da4a62bc96b0291003a85f82fea782f93 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 26 Mar 2024 11:35:33 -0700 Subject: [PATCH 7/8] Add test/cy check-format to lint github workflow --- .github/workflows/lint.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 43fdfbbe6..e8cf878e1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -20,3 +20,7 @@ jobs: - run: just web install - run: just web lint - run: just web check-format + + - run: just test/cy install + - run: just test/cy lint + - run: just test/cy check-format From ef175784326c26588bf59c348bd497f19d4200a3 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 26 Mar 2024 11:39:09 -0700 Subject: [PATCH 8/8] Format test/cy with Prettier --- test/cy/.eslintrc.cjs | 15 +++--- test/cy/cypress.config.js | 2 +- test/cy/cypress/e2e/contract/deploy.cy.js | 65 ++++++++++++----------- test/cy/cypress/e2e/ui/home.cy.js | 55 +++++++++---------- test/cy/cypress/support/commands.js | 13 ++--- test/cy/cypress/support/e2e.js | 4 +- 6 files changed, 75 insertions(+), 79 deletions(-) diff --git a/test/cy/.eslintrc.cjs b/test/cy/.eslintrc.cjs index dd1468127..4ac87d8f5 100644 --- a/test/cy/.eslintrc.cjs +++ b/test/cy/.eslintrc.cjs @@ -1,10 +1,7 @@ module.exports = { - extends: [ - 'plugin:cypress/recommended', - 'prettier' - ], - plugins: ['cypress'], - env: { - 'cypress/globals': true, - } - }; + extends: ["plugin:cypress/recommended", "prettier"], + plugins: ["cypress"], + env: { + "cypress/globals": true, + }, +}; diff --git a/test/cy/cypress.config.js b/test/cy/cypress.config.js index 32bcd3fff..73c888b9b 100644 --- a/test/cy/cypress.config.js +++ b/test/cy/cypress.config.js @@ -8,6 +8,6 @@ module.exports = defineConfig({ }, viewportHeight: 1080, viewportWidth: 1920, - video: true + video: true, }, }); diff --git a/test/cy/cypress/e2e/contract/deploy.cy.js b/test/cy/cypress/e2e/contract/deploy.cy.js index b328ca475..a02f0d622 100644 --- a/test/cy/cypress/e2e/contract/deploy.cy.js +++ b/test/cy/cypress/e2e/contract/deploy.cy.js @@ -1,50 +1,55 @@ -describe('Publish', () => { - it('publish content and check app type', () => { +describe("Publish", () => { + it("publish content and check app type", () => { cy.visit({ - url: '/', - qs: { token: Cypress.env('token') } + url: "/", + qs: { token: Cypress.env("token") }, }); // Add a New Deployment button - cy.get('div[data-automation="add-new-deployment"]') - .click(); + cy.get('div[data-automation="add-new-deployment"]').click(); // Continue to Deploy // ensure accounts are loaded to stall before clicking - cy.get('label[data-automation="account"]') - .should('exist'); - cy.get('button[data-automation="continue-deployment"]') - .click(); + cy.get('label[data-automation="account"]').should("exist"); + cy.get('button[data-automation="continue-deployment"]').click(); // Deploy - cy.get('button[data-automation="deploy"]') - .click(); + cy.get('button[data-automation="deploy"]').click(); // Wait for Deployment Success message - cy.get('div[data-automation="deploy-message"]', { timeout: 30000 }) - .contains("Deploy was successful!"); + cy.get('div[data-automation="deploy-message"]', { + timeout: 30000, + }).contains("Deploy was successful!"); // Get the link from the deployment logs - cy.get('a[href="#/progress') - .click(); + cy.get('a[href="#/progress').click(); cy.get('div[class="space-between-sm"]') - .find('p').last().invoke('text').then((guid) => { - Cypress.env('DEPLOYED_APP_URL', '/__api__/v1/content/' + guid); - cy.log("MY GUID " + Cypress.env('DEPLOYED_APP_URL')); - cy.log("MY URL " + Cypress.env('CYPRESS_CONNECT_ADDRESS') + Cypress.env('DEPLOYED_APP_URL')) + .find("p") + .last() + .invoke("text") + .then((guid) => { + Cypress.env("DEPLOYED_APP_URL", "/__api__/v1/content/" + guid); + cy.log("MY GUID " + Cypress.env("DEPLOYED_APP_URL")); + cy.log( + "MY URL " + + Cypress.env("CYPRESS_CONNECT_ADDRESS") + + Cypress.env("DEPLOYED_APP_URL"), + ); // Use API to check the content on Connect cy.request({ - method: 'GET', - url: Cypress.env('CYPRESS_CONNECT_ADDRESS') + Cypress.env('DEPLOYED_APP_URL'), - 'auth': { - 'bearer': Cypress.env('CONNECT_API_KEY') - }, - }).then((response) => { - expect(response.status).to.equal(200); - // app mode should be correct - expect(response.body).to.have.property('app_mode', 'python-fastapi') + method: "GET", + url: + Cypress.env("CYPRESS_CONNECT_ADDRESS") + + Cypress.env("DEPLOYED_APP_URL"), + auth: { + bearer: Cypress.env("CONNECT_API_KEY"), + }, + }).then((response) => { + expect(response.status).to.equal(200); + // app mode should be correct + expect(response.body).to.have.property("app_mode", "python-fastapi"); + }); }); - }); }); }); diff --git a/test/cy/cypress/e2e/ui/home.cy.js b/test/cy/cypress/e2e/ui/home.cy.js index e191d1aed..92f6dfc93 100644 --- a/test/cy/cypress/e2e/ui/home.cy.js +++ b/test/cy/cypress/e2e/ui/home.cy.js @@ -1,43 +1,40 @@ -describe('Landing', () => { +describe("Landing", () => { beforeEach(() => { cy.visit({ - url: '/', + url: "/", }); }); - it('.should() - assert that is correct', () => { - cy.title().should('include', 'Posit Publisher'); + it(".should() - assert that <title> is correct", () => { + cy.title().should("include", "Posit Publisher"); }); - - it('dark mode works', () => { + + it("dark mode works", () => { // expand dark mode menu cy.expandDarkMenu(); - cy.get('body').should('have.css', 'background-color', 'rgb(250, 250, 250)'); + cy.get("body").should("have.css", "background-color", "rgb(250, 250, 250)"); // set dark mode on - cy.get('div[data-automation="dark-on"]') - .click(); - cy.get('body').should('have.css', 'background-color', 'rgb(18, 18, 18)'); + cy.get('div[data-automation="dark-on"]').click(); + cy.get("body").should("have.css", "background-color", "rgb(18, 18, 18)"); cy.expandDarkMenu(); // set dark mode off - cy.get('div[data-automation="dark-off"]') - .click(); - cy.get('body').should('have.css', 'background-color', 'rgb(250, 250, 250)'); + cy.get('div[data-automation="dark-off"]').click(); + cy.get("body").should("have.css", "background-color", "rgb(250, 250, 250)"); cy.expandDarkMenu(); // set dark mode auto - cy.get('div[data-automation="dark-auto"]') - .click(); - cy.get('body').should('have.css', 'background-color', 'rgb(250, 250, 250)'); + cy.get('div[data-automation="dark-auto"]').click(); + cy.get("body").should("have.css", "background-color", "rgb(250, 250, 250)"); }); -// disabling configuration file test temporarily - // it('configuration file is displayed', () => { - // cy.get('div[data-automation="config-card"]') - // .find('h3[class="card-title truncate"]') - // .contains("default"); - // }); - + // disabling configuration file test temporarily + // it('configuration file is displayed', () => { + // cy.get('div[data-automation="config-card"]') + // .find('h3[class="card-title truncate"]') + // .contains("default"); + // }); + // cy.get('div[data-automation="config-card"]') // .find('p') // .should('contain', '.posit') @@ -45,10 +42,10 @@ describe('Landing', () => { // .and('contain', 'default.toml'); // }); -it('files are displayed', () => { - cy.get('div[data-automation="file-tree"]') - .should('contain', 'fastapi-simple') - .and('contain', 'requirements.txt') - .and('contain', 'simple.py'); + it("files are displayed", () => { + cy.get('div[data-automation="file-tree"]') + .should("contain", "fastapi-simple") + .and("contain", "requirements.txt") + .and("contain", "simple.py"); }); -}); \ No newline at end of file +}); diff --git a/test/cy/cypress/support/commands.js b/test/cy/cypress/support/commands.js index 4f82c58e7..e9ad10644 100644 --- a/test/cy/cypress/support/commands.js +++ b/test/cy/cypress/support/commands.js @@ -24,11 +24,8 @@ // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -Cypress.Commands.add('expandDarkMenu', () => { - cy.get('button[data-automation="menu-button"]') - .click(); - cy.get('div[data-automation="dark-mode-submenu"]') - .click(); - cy.get('div[data-automation="dark-on"]') - .should('be.visible'); -}); \ No newline at end of file +Cypress.Commands.add("expandDarkMenu", () => { + cy.get('button[data-automation="menu-button"]').click(); + cy.get('div[data-automation="dark-mode-submenu"]').click(); + cy.get('div[data-automation="dark-on"]').should("be.visible"); +}); diff --git a/test/cy/cypress/support/e2e.js b/test/cy/cypress/support/e2e.js index 0e7290a13..3a2522438 100644 --- a/test/cy/cypress/support/e2e.js +++ b/test/cy/cypress/support/e2e.js @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import "./commands"; // Alternatively you can use CommonJS syntax: -// require('./commands') \ No newline at end of file +// require('./commands')