From c72e66cee560d7133650d242e3c36341c0356d98 Mon Sep 17 00:00:00 2001 From: Al Harris <91494052+alharris-at@users.noreply.github.com> Date: Tue, 7 Dec 2021 08:41:34 -0800 Subject: [PATCH] fix: dont navigate on each test, and remove unnecessary gets from cypress suite (#281) --- package-lock.json | 203 ------------------ packages/codegen-ui-react/package-lock.json | 2 + packages/codegen-ui/package-lock.json | 2 + .../{complex-spec.js => complex-spec.ts} | 10 +- .../{generate-spec.js => generate-spec.ts} | 3 +- ...s-spec.js => generated-components-spec.ts} | 146 ++++--------- .../{iconset-spec.js => iconset-spec.ts} | 0 ...{primitives-spec.js => primitives-spec.ts} | 41 +--- .../{snippet-spec.js => snippet-spec.ts} | 0 packages/test-generator/package-lock.json | 2 + 10 files changed, 55 insertions(+), 354 deletions(-) rename packages/test-generator/integration-test-templates/cypress/integration/{complex-spec.js => complex-spec.ts} (96%) rename packages/test-generator/integration-test-templates/cypress/integration/{generate-spec.js => generate-spec.ts} (95%) rename packages/test-generator/integration-test-templates/cypress/integration/{generated-components-spec.js => generated-components-spec.ts} (62%) rename packages/test-generator/integration-test-templates/cypress/integration/{iconset-spec.js => iconset-spec.ts} (100%) rename packages/test-generator/integration-test-templates/cypress/integration/{primitives-spec.js => primitives-spec.ts} (83%) rename packages/test-generator/integration-test-templates/cypress/integration/{snippet-spec.js => snippet-spec.ts} (100%) diff --git a/package-lock.json b/package-lock.json index 0eebbe742..0ab0e661f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "@types/node": "^15.14.0", "@typescript-eslint/eslint-plugin": "^4.22.0", "@typescript-eslint/parser": "^4.7.0", - "copyfiles": "^2.4.1", "eslint": "^7.24.0", "eslint-config-airbnb-typescript": "^12.3.1", "eslint-config-prettier": "^8.2.0", @@ -4512,66 +4511,6 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, - "node_modules/copyfiles": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/copyfiles/-/copyfiles-2.4.1.tgz", - "integrity": "sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==", - "dev": true, - "license": "MIT", - "dependencies": { - "glob": "^7.0.5", - "minimatch": "^3.0.3", - "mkdirp": "^1.0.4", - "noms": "0.0.0", - "through2": "^2.0.1", - "untildify": "^4.0.0", - "yargs": "^16.1.0" - }, - "bin": { - "copyfiles": "copyfiles", - "copyup": "copyfiles" - } - }, - "node_modules/copyfiles/node_modules/readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/copyfiles/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "node_modules/copyfiles/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/copyfiles/node_modules/through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "dependencies": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -9823,40 +9762,6 @@ "node": ">=4" } }, - "node_modules/noms": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz", - "integrity": "sha1-2o69nzr51nYJGbJ9nNyAkqczKFk=", - "dev": true, - "dependencies": { - "inherits": "^2.0.1", - "readable-stream": "~1.0.31" - } - }, - "node_modules/noms/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "node_modules/noms/node_modules/readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/noms/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "node_modules/nopt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", @@ -12794,15 +12699,6 @@ "node": ">= 10.0.0" } }, - "node_modules/untildify": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", - "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/upath": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", @@ -16962,63 +16858,6 @@ } } }, - "copyfiles": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/copyfiles/-/copyfiles-2.4.1.tgz", - "integrity": "sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==", - "dev": true, - "requires": { - "glob": "^7.0.5", - "minimatch": "^3.0.3", - "mkdirp": "^1.0.4", - "noms": "0.0.0", - "through2": "^2.0.1", - "untildify": "^4.0.0", - "yargs": "^16.1.0" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - } - } - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -21070,42 +20909,6 @@ } } }, - "noms": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz", - "integrity": "sha1-2o69nzr51nYJGbJ9nNyAkqczKFk=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "readable-stream": "~1.0.31" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, "nopt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", @@ -23333,12 +23136,6 @@ "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", "dev": true }, - "untildify": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", - "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", - "dev": true - }, "upath": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", diff --git a/packages/codegen-ui-react/package-lock.json b/packages/codegen-ui-react/package-lock.json index 05f795d3b..73068df28 100644 --- a/packages/codegen-ui-react/package-lock.json +++ b/packages/codegen-ui-react/package-lock.json @@ -25191,6 +25191,7 @@ "dev": true, "peer": true, "requires": { + "@babel/core": "^7.14.0", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel/plugin-proposal-export-default-from": "^7.0.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", @@ -25239,6 +25240,7 @@ "dev": true, "peer": true, "requires": { + "@babel/core": "^7.14.0", "babel-preset-fbjs": "^3.4.0", "hermes-parser": "0.4.7", "metro-babel-transformer": "0.66.2", diff --git a/packages/codegen-ui/package-lock.json b/packages/codegen-ui/package-lock.json index b6c784601..2ef805645 100644 --- a/packages/codegen-ui/package-lock.json +++ b/packages/codegen-ui/package-lock.json @@ -25153,6 +25153,7 @@ "dev": true, "peer": true, "requires": { + "@babel/core": "^7.14.0", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel/plugin-proposal-export-default-from": "^7.0.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", @@ -25201,6 +25202,7 @@ "dev": true, "peer": true, "requires": { + "@babel/core": "^7.14.0", "babel-preset-fbjs": "^3.4.0", "hermes-parser": "0.4.7", "metro-babel-transformer": "0.66.2", diff --git a/packages/test-generator/integration-test-templates/cypress/integration/complex-spec.js b/packages/test-generator/integration-test-templates/cypress/integration/complex-spec.ts similarity index 96% rename from packages/test-generator/integration-test-templates/cypress/integration/complex-spec.js rename to packages/test-generator/integration-test-templates/cypress/integration/complex-spec.ts index a9595fcc5..164d1c47d 100644 --- a/packages/test-generator/integration-test-templates/cypress/integration/complex-spec.js +++ b/packages/test-generator/integration-test-templates/cypress/integration/complex-spec.ts @@ -14,12 +14,11 @@ limitations under the License. */ describe('Complex Components', () => { - it('Successfully opens the app', () => { + before(() => { cy.visit('http://localhost:3000/complex-tests'); }); it('Complex 1', () => { - cy.visit('http://localhost:3000/complex-tests'); cy.get('#complex-test-1').within(() => { cy.get('.amplify-flex') .should( @@ -41,7 +40,6 @@ describe('Complex Components', () => { }); it('Complex 2', () => { - cy.visit('http://localhost:3000/complex-tests'); cy.get('#complex-test-2').within(() => { cy.get('.amplify-flex') .should( @@ -81,7 +79,6 @@ describe('Complex Components', () => { }); it('Complex 3', () => { - cy.visit('http://localhost:3000/complex-tests'); cy.get('#complex-test-3').within(() => { cy.get('.amplify-flex') .should( @@ -127,7 +124,6 @@ describe('Complex Components', () => { }); it('Complex 4', () => { - cy.visit('http://localhost:3000/complex-tests'); cy.get('#complex-test-4').within(() => { cy.get('.amplify-flex') .should( @@ -164,7 +160,6 @@ describe('Complex Components', () => { }); it('Complex 5', () => { - cy.visit('http://localhost:3000/complex-tests'); cy.get('#complex-test-5').within(() => { cy.get('.amplify-flex') .should( @@ -195,7 +190,6 @@ describe('Complex Components', () => { }); it('Complex 6', () => { - cy.visit('http://localhost:3000/complex-tests'); cy.get('#complex-test-6').within(() => { cy.get('.amplify-flex') .should( @@ -239,7 +233,6 @@ describe('Complex Components', () => { }); it('Complex 7', () => { - cy.visit('http://localhost:3000/complex-tests'); cy.get('#complex-test-7').within(() => { cy.get('div') .should('have.attr', 'style', 'height: 192px; padding: 0px; position: relative; width: 401px;') @@ -279,7 +272,6 @@ describe('Complex Components', () => { }); it('Complex 8', () => { - cy.visit('http://localhost:3000/complex-tests'); cy.get('#complex-test-8').within(() => { cy.get('.amplify-flex') .should( diff --git a/packages/test-generator/integration-test-templates/cypress/integration/generate-spec.js b/packages/test-generator/integration-test-templates/cypress/integration/generate-spec.ts similarity index 95% rename from packages/test-generator/integration-test-templates/cypress/integration/generate-spec.js rename to packages/test-generator/integration-test-templates/cypress/integration/generate-spec.ts index 6d31cea01..b55feb78f 100644 --- a/packages/test-generator/integration-test-templates/cypress/integration/generate-spec.js +++ b/packages/test-generator/integration-test-templates/cypress/integration/generate-spec.ts @@ -24,12 +24,11 @@ const EXPECTED_INTERNAL_ERROR_CASES = new Set([]); const TARGET_GENERATORS = ['ES2016_TSX', 'ES2016_JSX', 'ES5_TSX', 'ES5_JSX']; describe('Generate Components', () => { - it('Loads the page', () => { + before(() => { cy.visit('http://localhost:3000/generate-tests'); }); it('Can generate all expected rows successfully', () => { - cy.visit('http://localhost:3000/generate-tests'); cy.get('.generateTest').each(($element) => { const className = $element.attr('id').replace('generateTest', ''); cy.wrap($element).within(() => { diff --git a/packages/test-generator/integration-test-templates/cypress/integration/generated-components-spec.js b/packages/test-generator/integration-test-templates/cypress/integration/generated-components-spec.ts similarity index 62% rename from packages/test-generator/integration-test-templates/cypress/integration/generated-components-spec.js rename to packages/test-generator/integration-test-templates/cypress/integration/generated-components-spec.ts index ae4c067f9..7f18553ad 100644 --- a/packages/test-generator/integration-test-templates/cypress/integration/generated-components-spec.js +++ b/packages/test-generator/integration-test-templates/cypress/integration/generated-components-spec.ts @@ -14,60 +14,48 @@ limitations under the License. */ describe('Generated Components', () => { - describe('Sanity Test', () => { - it('Successfully opens the app', () => { - cy.visit('http://localhost:3000/'); - }); + before(() => { + cy.visit('http://localhost:3000/component-tests'); }); describe('Basic Components', () => { it('Renders Badge component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').contains('Basic Component Badge'); }); it('Renders View component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').contains('Basic Component View'); }); it('Renders Button component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').contains('Basic Component Button'); }); it('Renders Card component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').contains('Basic Component Card'); }); it('Renders Collection component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').find('p:contains("Basic Collection Card Text")').should('have.length', 2); }); it('Renders Divider component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').find('.amplify-divider'); }); it('Renders Flex component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').find('.amplify-flex').contains('Basic Component Flex'); }); it('Renders Image component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').find('img'); }); it('Renders Text component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').contains('Basic Component Text'); }); it('Renders Custom component', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#basic-components').find('.amplify-rating'); }); }); @@ -75,34 +63,28 @@ describe('Generated Components', () => { describe('Generated Components', () => { describe('Concatenated Data', () => { it('Renders Button text as a concatenated, bound element', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#concat-and-conditional').contains('Harry Callahan'); }); it('Renders Button text as a concatenated, bound element, with overrides', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#concat-and-conditional').contains('Norm Gunderson'); }); }); describe('Conditional Data', () => { it('Renders Button with one background when user is logged in', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#concat-and-conditional').get('#conditional1').should('have.css', 'background-color', 'rgb(255, 0, 0)'); + cy.get('#conditional1').should('have.css', 'background-color', 'rgb(255, 0, 0)'); }); it('Renders Button with a different background when user is not logged in', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#concat-and-conditional').get('#conditional2').should('have.css', 'background-color', 'rgb(0, 0, 255)'); + cy.get('#conditional2').should('have.css', 'background-color', 'rgb(0, 0, 255)'); }); it('Renders Button disabled when user is not logged in', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#concat-and-conditional').get('#conditional2').get('[disabled]'); + cy.get('#conditional2').get('[disabled]'); }); it('Renders conditional props for simple property binding', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#ComponentWithBoundPropertyConditional-no-prop [disabled]').should('not.exist'); cy.get('#ComponentWithBoundPropertyConditional-true-prop').get('[disabled]'); cy.get('#ComponentWithBoundPropertyConditional-false-prop [disabled]').should('not.exist'); @@ -112,14 +94,12 @@ describe('Generated Components', () => { describe('Component Variants', () => { it('Renders Button disabled when user is not logged in', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#variants').get('#variant1').should('have.css', 'font-size', '12px'); - cy.get('#variants').get('#variant2').should('have.css', 'font-size', '40px'); - cy.get('#variants').get('#variant3').should('have.css', 'width', '500px'); + cy.get('#variant1').should('have.css', 'font-size', '12px'); + cy.get('#variant2').should('have.css', 'font-size', '40px'); + cy.get('#variant3').should('have.css', 'width', '500px'); }); it('allows for use of both variants and overrides, prioritizing overrides if they collide', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#variantAndOverrideDefault').contains('DefaultText'); cy.get('#variantAndOverrideVariantValue').contains('Hello'); cy.get('#variantAndOverrideOverrideApplied').contains('Overriden Text'); @@ -131,24 +111,21 @@ describe('Generated Components', () => { describe('Data Binding', () => { describe('Simple Property Binding', () => { it('Renders the Bound property', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#data-binding').get('#simplePropIsDisabled').get('[disabled]'); + cy.get('#simplePropIsDisabled').get('[disabled]'); }); }); describe('DataStore Binding Without Predicate', () => { it('Renders with and without overrides', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#data-binding').get('#dataStoreBindingWithoutPredicateNoOverride').contains('Al'); - cy.get('#data-binding').get('#dataStoreBindingWithoutPredicateWithOverride').contains('Override Name'); + cy.get('#dataStoreBindingWithoutPredicateNoOverride').contains('Al'); + cy.get('#dataStoreBindingWithoutPredicateWithOverride').contains('Override Name'); }); }); describe('DataStore Binding With Predicate', () => { it('Renders with and without overrides', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#data-binding').get('#dataStoreBindingWithPredicateNoOverrideNoModel').contains('Buddy'); - cy.get('#data-binding').get('#dataStoreBindingWithPredicateWithOverride').contains('Override Name'); + cy.get('#dataStoreBindingWithPredicateNoOverrideNoModel').contains('Buddy'); + cy.get('#dataStoreBindingWithPredicateWithOverride').contains('Override Name'); }); it('Renders with wired data model', () => { @@ -157,7 +134,6 @@ describe('Generated Components', () => { describe('Auth Binding', () => { it('Renders if user data is not available', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#authBinding [alt="User Image"]'); }); @@ -168,7 +144,6 @@ describe('Generated Components', () => { describe('Multiple Data Bindings', () => { it('Renders data from both bound data models', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#multipleDataBindings').contains('QA - 2200'); }); }); @@ -181,40 +156,34 @@ describe('Generated Components', () => { describe('Collections', () => { it('It renders a list of override values', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#collections').get('#collectionWithBindingAndOverrides button').eq(0).contains('Yankee'); - cy.get('#collections').get('#collectionWithBindingAndOverrides button').eq(1).contains('Feather'); + cy.get('#collectionWithBindingAndOverrides button').eq(0).contains('Yankee'); + cy.get('#collectionWithBindingAndOverrides button').eq(1).contains('Feather'); }); it('It renders data pulled from local datastore', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#collections').get('#collectionWithBindingNoOverrides button').eq(0).contains('Real'); - cy.get('#collections').get('#collectionWithBindingNoOverrides button').eq(1).contains('Another'); - cy.get('#collections').get('#collectionWithBindingNoOverrides button').eq(2).contains('Last'); + cy.get('#collectionWithBindingNoOverrides button').eq(0).contains('Real'); + cy.get('#collectionWithBindingNoOverrides button').eq(1).contains('Another'); + cy.get('#collectionWithBindingNoOverrides button').eq(2).contains('Last'); }); it('It respects sort functionality', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#collections').get('#collectionWithSort button').eq(0).contains('LUser1'); - cy.get('#collections').get('#collectionWithSort button').eq(1).contains('LUser2'); - cy.get('#collections').get('#collectionWithSort button').eq(2).contains('LUser3'); + cy.get('#collectionWithSort button').eq(0).contains('LUser1'); + cy.get('#collectionWithSort button').eq(1).contains('LUser2'); + cy.get('#collectionWithSort button').eq(2).contains('LUser3'); }); it('It renders a list of override values with collectionProperty named items', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#collections').get('#collectionWithBindingItemsNameWithOverrides button').eq(0).contains('Yankee'); - cy.get('#collections').get('#collectionWithBindingItemsNameWithOverrides button').eq(1).contains('Feather'); + cy.get('#collectionWithBindingItemsNameWithOverrides button').eq(0).contains('Yankee'); + cy.get('#collectionWithBindingItemsNameWithOverrides button').eq(1).contains('Feather'); }); it('It renders data pulled from local datastore with collectionProperty named items', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#collections').get('#collectionWithBindingItemsNameNoOverrides button').eq(0).contains('Real'); - cy.get('#collections').get('#collectionWithBindingItemsNameNoOverrides button').eq(1).contains('Another'); - cy.get('#collections').get('#collectionWithBindingItemsNameNoOverrides button').eq(2).contains('Last'); + cy.get('#collectionWithBindingItemsNameNoOverrides button').eq(0).contains('Real'); + cy.get('#collectionWithBindingItemsNameNoOverrides button').eq(1).contains('Another'); + cy.get('#collectionWithBindingItemsNameNoOverrides button').eq(2).contains('Last'); }); it('It renders paginated collections', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#paginatedCollection').contains('Mountain Retreat - $1800'); cy.get('#paginatedCollection').contains('Beachside Cottage - $1000').should('not.exist'); cy.get('[aria-label="Go to page 2"]').click(); @@ -224,8 +193,7 @@ describe('Generated Components', () => { describe('Default Value', () => { it('Renders simple property binding default value', () => { - cy.get('#default-value') - .get('#bound-simple-binding-default') + cy.get('#bound-simple-binding-default') .invoke('text') .then((text) => { expect(text.trim()).equal('Default Binding Property'); @@ -233,8 +201,7 @@ describe('Generated Components', () => { }); it('Overrides simple property binding default value', () => { - cy.get('#default-value') - .get('#bound-simple-binding-override') + cy.get('#bound-simple-binding-override') .invoke('text') .then((text) => { expect(text.trim()).equal('Override Simple Binding'); @@ -242,8 +209,7 @@ describe('Generated Components', () => { }); it('Renders bound default value', () => { - cy.get('#default-value') - .get('#bound-default') + cy.get('#bound-default') .invoke('text') .then((text) => { expect(text.trim()).equal('Bound Default'); @@ -251,8 +217,7 @@ describe('Generated Components', () => { }); it('Overrides bound default value', () => { - cy.get('#default-value') - .get('#bound-override') + cy.get('#bound-override') .invoke('text') .then((text) => { expect(text.trim()).equal('Override Bound'); @@ -260,8 +225,7 @@ describe('Generated Components', () => { }); it('Renders simple default value when simple and bound', () => { - cy.get('#default-value') - .get('#simple-and-bound-default') + cy.get('#simple-and-bound-default') .invoke('text') .then((text) => { expect(text.trim()).equal('Simple Double Default'); @@ -269,8 +233,7 @@ describe('Generated Components', () => { }); it('Overrides simple and bound default value', () => { - cy.get('#default-value') - .get('#simple-and-bound-override') + cy.get('#simple-and-bound-override') .invoke('text') .then((text) => { expect(text.trim()).equal('Override Simple And Bound'); @@ -278,8 +241,7 @@ describe('Generated Components', () => { }); it('Renders collection default value', () => { - cy.get('#default-value') - .get('#collection-default') + cy.get('#collection-default') .find('.amplify-text') .invoke('text') .then((text) => { @@ -288,8 +250,7 @@ describe('Generated Components', () => { }); it('Overrides collection default value', () => { - cy.get('#default-value') - .get('#collection-override') + cy.get('#collection-override') .find('.amplify-text') .invoke('text') .then((text) => { @@ -300,7 +261,6 @@ describe('Generated Components', () => { describe('Parsed Fixed Property Values', () => { it('String Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values') .find('#string-value') .should('have.attr', 'value') @@ -308,27 +268,22 @@ describe('Generated Components', () => { }); it('String Number Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values').find('#string-number-value').should('have.attr', 'value').should('equal', '67548'); }); it('Parsed Number Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values').find('#parsed-number-value').get('.amplify-visually-hidden').contains('0.4'); }); it('String Boolean Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values').find('#string-boolean-value').should('have.attr', 'value').should('equal', 'true'); }); it('Parsed Boolean Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values').find('#parsed-boolean-value').should('be.disabled'); }); it('String JSON Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values') .find('#string-json-value') .should('have.attr', 'value') @@ -336,12 +291,10 @@ describe('Generated Components', () => { }); it('Parsed JSON Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values').find('#parsed-json-value').should('have.attr', 'viewBox', '0 0 24 24'); }); it('String Array Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values') .find('#string-array-value') .should('have.attr', 'value') @@ -349,36 +302,30 @@ describe('Generated Components', () => { }); it('Parsed Array Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values').find('#parsed-array-value').contains('123'); }); it('String Null Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values').find('#string-null-value').should('have.attr', 'value').should('equal', 'null'); }); it('Parsed Null Value', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#parsed-fixed-values').find('#parsed-null-value').should('have.text', ''); }); }); describe('Custom Component', () => { it('Renders custom children', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#custom-component') .find('#custom-children') .find('button') .should('have.attr', 'style', 'color: rgb(255, 0, 0);'); }); it('Renders custom parent', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#custom-component').find('#custom-parent').should('have.css', 'font-family', '"Times New Roman"'); }); it('Renders custom parent and children', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#custom-component') .find('#custom-parent-and-children') .should('have.css', 'font-family', '"Times New Roman"') @@ -389,7 +336,6 @@ describe('Generated Components', () => { describe('Icons', () => { it('Renders IconCloud', () => { - cy.visit('http://localhost:3000/component-tests'); cy.get('#icons').find('svg').find('path').should( 'have.attr', 'd', @@ -398,21 +344,19 @@ describe('Generated Components', () => { ); }); }); -}); -describe('Overrides', () => { - it('renders overrides with the correct indices', () => { - cy.visit('http://localhost:3000/component-tests'); - cy.get('#componentWithNestedOverrides').should('have.css', 'background-color', 'rgb(255, 0, 0)'); - cy.get('#componentWithNestedOverrides #ChildFlex3').should('have.css', 'background-color', 'rgb(0, 128, 0)'); - cy.get('#componentWithNestedOverrides #ChildChildFlex1').should('have.css', 'background-color', 'rgb(0, 0, 255)'); + describe('Overrides', () => { + it('renders overrides with the correct indices', () => { + cy.get('#componentWithNestedOverrides').should('have.css', 'background-color', 'rgb(255, 0, 0)'); + cy.get('#componentWithNestedOverrides #ChildFlex3').should('have.css', 'background-color', 'rgb(0, 128, 0)'); + cy.get('#componentWithNestedOverrides #ChildChildFlex1').should('have.css', 'background-color', 'rgb(0, 0, 255)'); + }); }); -}); -describe('Generated Themes', () => { - it('Successfully decorates the app', () => { - cy.visit('http://localhost:3000/component-tests'); - // amplify-ui theming converts hex color to rgb - cy.get('p.amplify-text').should('have.css', 'color', 'rgb(0, 128, 128)'); + describe('Generated Themes', () => { + it('Successfully decorates the app', () => { + // amplify-ui theming converts hex color to rgb + cy.get('p.amplify-text').should('have.css', 'color', 'rgb(0, 128, 128)'); + }); }); }); diff --git a/packages/test-generator/integration-test-templates/cypress/integration/iconset-spec.js b/packages/test-generator/integration-test-templates/cypress/integration/iconset-spec.ts similarity index 100% rename from packages/test-generator/integration-test-templates/cypress/integration/iconset-spec.js rename to packages/test-generator/integration-test-templates/cypress/integration/iconset-spec.ts diff --git a/packages/test-generator/integration-test-templates/cypress/integration/primitives-spec.js b/packages/test-generator/integration-test-templates/cypress/integration/primitives-spec.ts similarity index 83% rename from packages/test-generator/integration-test-templates/cypress/integration/primitives-spec.js rename to packages/test-generator/integration-test-templates/cypress/integration/primitives-spec.ts index 9fcb7a3ed..5c026d801 100644 --- a/packages/test-generator/integration-test-templates/cypress/integration/primitives-spec.js +++ b/packages/test-generator/integration-test-templates/cypress/integration/primitives-spec.ts @@ -14,15 +14,12 @@ limitations under the License. */ describe('Primitives', () => { - describe('Sanity Test', () => { - it('Successfully opens the app', () => { - cy.visit('http://localhost:3000/primitives-tests'); - }); + before(() => { + cy.visit('http://localhost:3000/primitives-tests'); }); describe('Alert', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#alert') .find('.amplify-alert') .within(() => { @@ -33,14 +30,12 @@ describe('Primitives', () => { describe('Badge', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#badge').find('.amplify-badge').contains('Error Found'); }); }); describe('Button', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#button').within(() => { cy.get('.amplify-button').should('have.text', 'Hello world!'); cy.get('.amplify-button').should('have.attr', 'type', 'button'); @@ -51,7 +46,6 @@ describe('Primitives', () => { describe('ButtonGroup', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#button-group').within(() => { cy.get('.amplify-button').should('have.attr', 'data-variation', 'primary'); }); @@ -60,7 +54,6 @@ describe('Primitives', () => { describe('Card', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#card').within(() => { cy.get('.amplify-card').find('div').should('have.attr', 'style', 'padding: 1rem;'); }); @@ -69,7 +62,6 @@ describe('Primitives', () => { describe('CheckboxField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#checkbox-field').within(() => { cy.get('.amplify-checkboxfield').get('.amplify-checkbox__label').should('have.text', 'Subscribe'); }); @@ -78,21 +70,18 @@ describe('Primitives', () => { describe('Collection', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#collection').find('.amplify-card').eq(0).should('have.text', 'Cozy BungalowLorem ipsum dolor sit amet'); }); }); describe('Divider', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#divider').find('.amplify-divider'); }); }); describe('Expander', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#expander') .find('.amplify-expander') .within(() => { @@ -116,7 +105,6 @@ describe('Primitives', () => { describe('Flex', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#flex').within(() => { cy.get('.amplify-text').eq(0).should('have.text', 'Hello'); cy.get('.amplify-text').eq(1).should('have.text', 'world'); @@ -126,7 +114,6 @@ describe('Primitives', () => { describe('Grid', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#grid') .get('.amplify-grid') .within(() => { @@ -140,14 +127,12 @@ describe('Primitives', () => { describe('Heading', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#heading').find('.amplify-heading').eq(1).should('have.text', 'Hello world!'); }); }); describe('Icon', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#icon') .get('.amplify-icon') .within(() => { @@ -163,14 +148,12 @@ describe('Primitives', () => { describe('Image', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#image').get('.amplify-image').should('have.attr', 'src', '/road-to-milford-new-zealand-800w.jpg'); }); }); describe('Link', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#link').get('.amplify-link').should('have.text', 'My Link'); cy.get('#link').get('.amplify-link').should('have.attr', 'href', '/primitives-tests'); }); @@ -178,14 +161,12 @@ describe('Primitives', () => { describe('Loader', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#loader').get('.amplify-loader').should('have.attr', 'data-size', 'large'); }); }); describe('Pagination', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#pagination') .get('.amplify-pagination') .get('ol') @@ -200,28 +181,24 @@ describe('Primitives', () => { describe('PasswordField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#password-field').find('.amplify-input').should('have.attr', 'autocomplete', 'current-password'); }); }); describe('PhoneNumberField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#phone-number-field').find('.amplify-input').should('have.attr', 'autocomplete', 'tel-national'); }); }); describe('Placeholder', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#placeholder').find('.amplify-placeholder'); }); }); describe('Radio', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#radio') .find('.amplify-radio') .within(() => { @@ -233,7 +210,6 @@ describe('Primitives', () => { describe('RadioGroupField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#radio-group-field') .find('.amplify-radiogroupfield') .within(() => { @@ -249,28 +225,24 @@ describe('Primitives', () => { describe('Rating', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#rating').find('.amplify-visually-hidden').should('have.text', '3.7 out of 5 rating'); }); }); describe('ScrollView', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#scroll-view').find('.amplify-scrollview').should('have.attr', 'style', 'height: 300px; width: 400px;'); }); }); describe('SearchField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#search-field').find('.amplify-input').should('have.attr', 'name', 'q'); }); }); describe('SliderField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#slider-field') .find('.amplify-sliderfield') .within(() => { @@ -290,7 +262,6 @@ describe('Primitives', () => { describe('StepperField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#stepper-field').within(() => { cy.get('.amplify-input').should('have.attr', 'type', 'number'); cy.get('.amplify-input').should('have.attr', 'min', '0'); @@ -302,7 +273,6 @@ describe('Primitives', () => { describe('SwitchField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#switch-field') .find('.amplify-switch__wrapper') .within(() => { @@ -314,7 +284,6 @@ describe('Primitives', () => { describe('Tabs', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#tabs') .find('div') .within(() => { @@ -328,14 +297,12 @@ describe('Primitives', () => { describe('Text', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#text').find('.amplify-text').should('have.text', 'Hello world'); }); }); describe('TextField', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#text-field') .find('.amplify-textfield') .within(() => { @@ -348,7 +315,6 @@ describe('Primitives', () => { describe('ToggleButton', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#toggle-button').within(() => { cy.get('.amplify-togglebutton').should('have.text', 'Press me!'); cy.get('.amplify-togglebutton').should('have.attr', 'aria-pressed', 'false'); @@ -358,7 +324,6 @@ describe('Primitives', () => { describe('ToggleButtonGroup', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#toggle-button-group') .find('.amplify-togglebuttongroup') .within(() => { @@ -376,14 +341,12 @@ describe('Primitives', () => { describe('View', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#view').find('div').should('have.text', 'Nice view! 🏔'); }); }); describe('VisuallyHidden', () => { it('Basic', () => { - cy.visit('http://localhost:3000/primitives-tests'); cy.get('#visually-hidden').find('button').find('.amplify-visually-hidden').should('have.text', 'Donemark'); }); }); diff --git a/packages/test-generator/integration-test-templates/cypress/integration/snippet-spec.js b/packages/test-generator/integration-test-templates/cypress/integration/snippet-spec.ts similarity index 100% rename from packages/test-generator/integration-test-templates/cypress/integration/snippet-spec.js rename to packages/test-generator/integration-test-templates/cypress/integration/snippet-spec.ts diff --git a/packages/test-generator/package-lock.json b/packages/test-generator/package-lock.json index 294372f12..1d744d9a2 100644 --- a/packages/test-generator/package-lock.json +++ b/packages/test-generator/package-lock.json @@ -26687,6 +26687,7 @@ "dev": true, "peer": true, "requires": { + "@babel/core": "^7.14.0", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel/plugin-proposal-export-default-from": "^7.0.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", @@ -26735,6 +26736,7 @@ "dev": true, "peer": true, "requires": { + "@babel/core": "^7.14.0", "babel-preset-fbjs": "^3.4.0", "hermes-parser": "0.4.7", "metro-babel-transformer": "0.66.2",