diff --git a/package-lock.json b/package-lock.json index 648d44610b4..f6ce3c6b955 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@sentry/node": "^7.91.0", "@sentry/react": "^7.91.0", "@sentry/tracing": "^7.91.0", - "autoprefixer": "^10.4.16", + "autoprefixer": "^10.4.17", "axios": "^1.6.0", "basic-auth": "^2.0.1", "body-parser": "^1.20.2", @@ -30,7 +30,7 @@ "constate": "^3.3.0", "cookie-parser": "^1.4.6", "core-js": "^3.35.0", - "css-loader": "^6.8.1", + "css-loader": "^6.9.1", "csurf": "^1.11.0", "date-fns": "^2.30.0", "del-cli": "^5.0.0", @@ -61,7 +61,7 @@ "nunjucks-markdown": "^2.0.1", "pluralize": "^8.0.0", "postcss-cli": "^11.0.0", - "postcss-loader": "^7.3.4", + "postcss-loader": "^8.0.0", "prop-types": "^15.8.1", "pure-uuid": "^1.8.1", "qs": "^6.11.2", @@ -104,8 +104,8 @@ "@babel/preset-env": "^7.23.7", "@babel/preset-react": "^7.23.3", "@babel/preset-typescript": "^7.23.3", - "@babel/runtime": "^7.23.2", - "@cypress/code-coverage": "^3.12.17", + "@babel/runtime": "^7.23.9", + "@cypress/code-coverage": "^3.12.19", "@faker-js/faker": "^8.3.1", "@storybook/addon-a11y": "^7.6.7", "@storybook/addon-essentials": "^7.6.7", @@ -133,7 +133,7 @@ "git-directory-deploy": "^1.5.1", "html": "^1.0.0", "http-server": "^14.1.1", - "image-minimizer-webpack-plugin": "^3.8.3", + "image-minimizer-webpack-plugin": "^4.0.0", "imagemin": "^8.0.1", "imagemin-gifsicle": "^7.0.0", "imagemin-jpegtran": "^7.0.0", @@ -142,7 +142,7 @@ "js-beautify": "^1.14.11", "jsdom": "^20.0.3", "jsdom-global": "^3.0.2", - "json-schema-faker": "^0.5.4", + "json-schema-faker": "^0.5.5", "lint-staged": "^15.2.0", "mocha": "^10.2.0", "mocha-junit-reporter": "^2.2.1", @@ -2135,9 +2135,9 @@ "dev": true }, "node_modules/@babel/runtime": { - "version": "7.23.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.5.tgz", - "integrity": "sha512-NdUTHcPe4C99WxPub+K9l9tK5/lV4UXIoaHSYgzco9BCyjKAAwzdBI+wWtYqHt7LJdbo74ZjRPJgzVweq1sz0w==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.9.tgz", + "integrity": "sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw==", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -2228,9 +2228,9 @@ } }, "node_modules/@cypress/code-coverage": { - "version": "3.12.17", - "resolved": "https://registry.npmjs.org/@cypress/code-coverage/-/code-coverage-3.12.17.tgz", - "integrity": "sha512-HtGUZ50f/QxJxMq2kjsHzmMxB3TreAzt8NAidz+ht2mrFQEJ0+Kz+AhhGa47Smb2eywcygWgoKXhe7DFCsk1FQ==", + "version": "3.12.19", + "resolved": "https://registry.npmjs.org/@cypress/code-coverage/-/code-coverage-3.12.19.tgz", + "integrity": "sha512-RNpgESArIwX2PG7k0KEb941eSYSBEGF1WB5NPeWrVJMX6KeAxj3Ki5aeYlFeV+wxoAJ+7gcF4s5xV18BQLCpjQ==", "dev": true, "dependencies": { "@cypress/webpack-preprocessor": "^6.0.0", @@ -9405,9 +9405,9 @@ } }, "node_modules/autoprefixer": { - "version": "10.4.16", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.16.tgz", - "integrity": "sha512-7vd3UC6xKp0HLfua5IjZlcXvGAGy7cBAXTg2lyQ/8WpNhd6SiZ8Be+xm3FyBSYJx5GKcpRCzBh7RH4/0dnY+uQ==", + "version": "10.4.17", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.17.tgz", + "integrity": "sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg==", "funding": [ { "type": "opencollective", @@ -9423,9 +9423,9 @@ } ], "dependencies": { - "browserslist": "^4.21.10", - "caniuse-lite": "^1.0.30001538", - "fraction.js": "^4.3.6", + "browserslist": "^4.22.2", + "caniuse-lite": "^1.0.30001578", + "fraction.js": "^4.3.7", "normalize-range": "^0.1.2", "picocolors": "^1.0.0", "postcss-value-parser": "^4.2.0" @@ -10908,9 +10908,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001565", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001565.tgz", - "integrity": "sha512-xrE//a3O7TP0vaJ8ikzkD2c2NgcVUvsEe2IvFTntV4Yd1Z9FVzh+gW+enX96L0psrbaFMcVcH2l90xNuGDWc8w==", + "version": "1.0.30001579", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz", + "integrity": "sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==", "funding": [ { "type": "opencollective", @@ -11892,18 +11892,18 @@ } }, "node_modules/css-loader": { - "version": "6.8.1", - "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.8.1.tgz", - "integrity": "sha512-xDAXtEVGlD0gJ07iclwWVkLoZOpEvAWaSyf6W18S2pOC//K8+qUDIx8IIT3D+HjnmkJPQeesOPv5aiUaJsCM2g==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.9.1.tgz", + "integrity": "sha512-OzABOh0+26JKFdMzlK6PY1u5Zx8+Ck7CVRlcGNZoY9qwJjdfu2VWFuprTIpPW+Av5TZTVViYWcFQaEEQURLknQ==", "dependencies": { "icss-utils": "^5.1.0", - "postcss": "^8.4.21", + "postcss": "^8.4.33", "postcss-modules-extract-imports": "^3.0.0", - "postcss-modules-local-by-default": "^4.0.3", - "postcss-modules-scope": "^3.0.0", + "postcss-modules-local-by-default": "^4.0.4", + "postcss-modules-scope": "^3.1.1", "postcss-modules-values": "^4.0.0", "postcss-value-parser": "^4.2.0", - "semver": "^7.3.8" + "semver": "^7.5.4" }, "engines": { "node": ">= 12.13.0" @@ -13719,6 +13719,14 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "engines": { + "node": ">=6" + } + }, "node_modules/envinfo": { "version": "7.11.0", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.0.tgz", @@ -17571,16 +17579,16 @@ "dev": true }, "node_modules/image-minimizer-webpack-plugin": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/image-minimizer-webpack-plugin/-/image-minimizer-webpack-plugin-3.8.3.tgz", - "integrity": "sha512-Ex0cjNJc2FUSuwN7WHNyxkIZINP0M9lrN+uWJznMcsehiM5Z7ELwk+SEkSGEookK1GUd2wf+09jy1PEH5a5XmQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/image-minimizer-webpack-plugin/-/image-minimizer-webpack-plugin-4.0.0.tgz", + "integrity": "sha512-gBpAw9E1LxqlQ0/y72xHq3/3qWKh7xeIvhmNJOQEhj1hJPz2m/eQxREyuRkSIWJyN8ee8ZkwGnnNHe05jSmQrg==", "dev": true, "dependencies": { "schema-utils": "^4.2.0", - "serialize-javascript": "^6.0.1" + "serialize-javascript": "^6.0.2" }, "engines": { - "node": ">= 12.13.0" + "node": ">= 18.12.0" }, "funding": { "type": "opencollective", @@ -19670,9 +19678,9 @@ "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" }, "node_modules/json-schema-faker": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/json-schema-faker/-/json-schema-faker-0.5.4.tgz", - "integrity": "sha512-DdRRnRNSxkQVXEsUUXzAtvBpsROZHvM59/LQcV6+3gQVMvaeMsqfNKN3ivRwaiahTW7pvxa+LJfOaPP+nhFo4g==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/json-schema-faker/-/json-schema-faker-0.5.5.tgz", + "integrity": "sha512-MlnBqcsM1t8jdHs00ltae0rlSwWI2nrd1IfnAF+UcHsqKFrlAhrbDFVKiA8C0E860PuspKoV4oImJdvtF7aqwg==", "dev": true, "dependencies": { "json-schema-ref-parser": "^6.1.0", @@ -24839,9 +24847,9 @@ } }, "node_modules/postcss": { - "version": "8.4.31", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", - "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "version": "8.4.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", + "integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", "funding": [ { "type": "opencollective", @@ -24857,7 +24865,7 @@ } ], "dependencies": { - "nanoid": "^3.3.6", + "nanoid": "^3.3.7", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, @@ -25037,16 +25045,16 @@ } }, "node_modules/postcss-loader": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-7.3.4.tgz", - "integrity": "sha512-iW5WTTBSC5BfsBJ9daFMPVrLT36MrNiC6fqOZTTaHjBNX6Pfd5p+hSBqe/fEeNd7pc13QiAyGt7VdGMw4eRC4A==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-8.0.0.tgz", + "integrity": "sha512-+RiNlmYd1aXYv6QSBOAu6n9eJYy0ydyXTfjljAJ3vFU6MMo2M552zTVcBpBH+R5aAeKaYVG1K9UEyAVsLL1Qjg==", "dependencies": { - "cosmiconfig": "^8.3.5", + "cosmiconfig": "^9.0.0", "jiti": "^1.20.0", "semver": "^7.5.4" }, "engines": { - "node": ">= 14.15.0" + "node": ">= 18.12.0" }, "funding": { "type": "opencollective", @@ -25058,14 +25066,14 @@ } }, "node_modules/postcss-loader/node_modules/cosmiconfig": { - "version": "8.3.6", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz", - "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz", + "integrity": "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==", "dependencies": { + "env-paths": "^2.2.1", "import-fresh": "^3.3.0", "js-yaml": "^4.1.0", - "parse-json": "^5.2.0", - "path-type": "^4.0.0" + "parse-json": "^5.2.0" }, "engines": { "node": ">=14" @@ -25094,9 +25102,9 @@ } }, "node_modules/postcss-modules-local-by-default": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.3.tgz", - "integrity": "sha512-2/u2zraspoACtrbFRnTijMiQtb4GW4BvatjaG/bCjYQo8kLTdevCUlwuBHx2sCnSyrI3x3qj4ZK1j5LQBgzmwA==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.4.tgz", + "integrity": "sha512-L4QzMnOdVwRm1Qb8m4x8jsZzKAaPAgrUF1r/hjDR2Xj7R+8Zsf97jAlSQzWtKx5YNiNGN8QxmPFIc/sh+RQl+Q==", "dependencies": { "icss-utils": "^5.0.0", "postcss-selector-parser": "^6.0.2", @@ -25110,9 +25118,9 @@ } }, "node_modules/postcss-modules-scope": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz", - "integrity": "sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.1.1.tgz", + "integrity": "sha512-uZgqzdTleelWjzJY+Fhti6F3C9iF1JR/dODLs/JDefozYcKTBCdD8BIl6nNPbTbcLnGrk56hzwZC2DaGNvYjzA==", "dependencies": { "postcss-selector-parser": "^6.0.4" }, @@ -25157,9 +25165,9 @@ } }, "node_modules/postcss-selector-parser": { - "version": "6.0.13", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.13.tgz", - "integrity": "sha512-EaV1Gl4mUEV4ddhDnv/xtj7sxwrwxdetHdWUGnT4VJQf+4d05v6lHYZr8N573k5Z0BViss7BDhfWtKS3+sfAqQ==", + "version": "6.0.15", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.15.tgz", + "integrity": "sha512-rEYkQOMUCEMhsKbK66tbEU9QVIxbhN18YiniAwA7XQYTVBqrBy+P2p5JcdqsHgKM2zWylp8d7J6eszocfds5Sw==", "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -27973,9 +27981,9 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/serialize-javascript": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", - "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "dependencies": { "randombytes": "^2.1.0" } diff --git a/package.json b/package.json index 9e199c571c8..4d05377deaa 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "@sentry/node": "^7.91.0", "@sentry/react": "^7.91.0", "@sentry/tracing": "^7.91.0", - "autoprefixer": "^10.4.16", + "autoprefixer": "^10.4.17", "axios": "^1.6.0", "basic-auth": "^2.0.1", "body-parser": "^1.20.2", @@ -91,7 +91,7 @@ "constate": "^3.3.0", "cookie-parser": "^1.4.6", "core-js": "^3.35.0", - "css-loader": "^6.8.1", + "css-loader": "^6.9.1", "csurf": "^1.11.0", "date-fns": "^2.30.0", "del-cli": "^5.0.0", @@ -122,7 +122,7 @@ "nunjucks-markdown": "^2.0.1", "pluralize": "^8.0.0", "postcss-cli": "^11.0.0", - "postcss-loader": "^7.3.4", + "postcss-loader": "^8.0.0", "prop-types": "^15.8.1", "pure-uuid": "^1.8.1", "qs": "^6.11.2", @@ -165,8 +165,8 @@ "@babel/preset-env": "^7.23.7", "@babel/preset-react": "^7.23.3", "@babel/preset-typescript": "^7.23.3", - "@babel/runtime": "^7.23.2", - "@cypress/code-coverage": "^3.12.17", + "@babel/runtime": "^7.23.9", + "@cypress/code-coverage": "^3.12.19", "@faker-js/faker": "^8.3.1", "@storybook/addon-a11y": "^7.6.7", "@storybook/addon-essentials": "^7.6.7", @@ -194,7 +194,7 @@ "git-directory-deploy": "^1.5.1", "html": "^1.0.0", "http-server": "^14.1.1", - "image-minimizer-webpack-plugin": "^3.8.3", + "image-minimizer-webpack-plugin": "^4.0.0", "imagemin": "^8.0.1", "imagemin-gifsicle": "^7.0.0", "imagemin-jpegtran": "^7.0.0", @@ -203,7 +203,7 @@ "js-beautify": "^1.14.11", "jsdom": "^20.0.3", "jsdom-global": "^3.0.2", - "json-schema-faker": "^0.5.4", + "json-schema-faker": "^0.5.5", "lint-staged": "^15.2.0", "mocha": "^10.2.0", "mocha-junit-reporter": "^2.2.1", diff --git a/src/client/modules/ExportWins/Form/transformers.js b/src/client/modules/ExportWins/Form/transformers.js index b692bf0e24c..b93fa3843f7 100644 --- a/src/client/modules/ExportWins/Form/transformers.js +++ b/src/client/modules/ExportWins/Form/transformers.js @@ -174,7 +174,9 @@ export const transformFormValuesForAPI = (values) => ({ lead_officer: values.lead_officer.value, team_type: values.team_type.value, hq_team: values.hq_team.value, - team_members: values.team_members.map((member) => member.value), + team_members: values.team_members + ? values.team_members.map((member) => member.value) + : [], // Credit for this win advisers: transformContributingOfficersToAdvisers(values), // Customer details diff --git a/test/functional/cypress/specs/export-win/add-export-win-spec.js b/test/functional/cypress/specs/export-win/add-export-win-spec.js index fa5fb89a335..6abe4843f97 100644 --- a/test/functional/cypress/specs/export-win/add-export-win-spec.js +++ b/test/functional/cypress/specs/export-win/add-export-win-spec.js @@ -1,9 +1,6 @@ import { getTwelveMonthsAgo } from '../../../../../src/client/modules/ExportWins/Form/utils' import { clickContinueButton } from '../../support/actions' import { companyFaker } from '../../fakers/companies' -import { advisersListFaker } from '../../fakers/advisers' -import { teamTypeListFaker } from '../../fakers/team-type' -import { hqTeamListFaker } from '../../fakers/hq-team' import urls from '../../../../../src/lib/urls' import { assertUrl, @@ -18,40 +15,121 @@ import { assertFieldRadiosWithLegend, } from '../../support/assertions' +const company = companyFaker() + +const twelveMonthsAgo = getTwelveMonthsAgo() +const month = twelveMonthsAgo.getMonth() + 1 +const year = twelveMonthsAgo.getFullYear() + +const officerDetailsStep = `?step=officer_details&company=${company.id}` +const creditForThisWinStep = `?step=credit_for_this_win&company=${company.id}` +const customerDetailsStep = `?step=customer_details&company=${company.id}` +const winDetailsStep = `?step=win_details&company=${company.id}` +const supportProvidedStep = `?step=support_provided&company=${company.id}` + +const formFields = { + officerDetails: { + heading: '[data-test="step-heading"]', + leadOfficer: '[data-test="field-lead_officer"]', + teamType: '[data-test="field-team_type"]', + hqTeam: '[data-test="field-hq_team"]', + teamMembers: '[data-test="field-team_members"]', + teamMembersHintText: '[data-test="hint-text"]', + }, + creditForThisWin: { + heading: '[data-test="step-heading"]', + hint: '[data-test="hint"]', + hintText: '[data-test="hint-text"]', + radiosBtns: '[data-test="field-credit_for_win"]', + radiosBtnYes: '[data-test="credit-for-win-yes"]', + radiosBtnNo: '[data-test="credit-for-win-no"]', + addAnother: '[data-test="field-addAnother"]', + contributingOfficer: '[data-test="field-contributing_officer_0"]', + teamType: '[data-test="field-team_type_0"]', + hqTeam: '[data-test="field-hq_team_0"]', + }, + customerDetails: { + heading: '[data-test="step-heading"]', + contacts: '[data-test="field-company_contacts"]', + addContactLink: '[data-test="add-a-new-contact-link"]', + details: '[data-test="contact-information-details"]', + location: '[data-test="field-customer_location"]', + potential: '[data-test="field-business_potential"]', + experience: '[data-test="field-export_experience"]', + }, + winDetails: { + heading: '[data-test="step-heading"]', + hint: '[data-test="hint"]', + country: '[data-test="field-country"]', + date: '[data-test="field-date"]', + dateMonth: '[data-test="date-month"]', + dateYear: '[data-test="date-year"]', + description: '[data-test="field-description"]', + nameOfCustomer: '[data-test="field-name_of_customer"]', + confidential: '[data-test="field-name_of_customer_confidential"]', + businessType: '[data-test="field-business_type"]', + winType: '[data-test="field-win_type"]', + goodsVsServices: '[data-test="field-goods_vs_services"]', + nameOfExport: '[data-test="field-name_of_export"]', + sector: '[data-test="field-sector"]', + exportWinCheckbox: '[data-test="checkbox-export_win"]', + businessSuccessCheckbox: '[data-test="checkbox-business_success_win"]', + odiCheckbox: '[data-test="checkbox-odi_win"]', + winTypeValuesExport: '[data-test="win-type-values-export_win"]', + winTypeValuesBusSupp: '[data-test="win-type-values-business_success_win"]', + winTypeValuesODI: '[data-test="win-type-values-odi_win"]', + totalExportValue: '[data-test="total-export-value"]', + }, + supportProvided: { + heading: '[data-test="step-heading"]', + hint: '[data-test="hint"]', + hvc: '[data-test="field-hvc"]', + typeOfSupport: '[data-test="field-type_of_support"]', + associatedProgramme: '[data-test="field-associated_programme"]', + personallyConfirmed: '[data-test="field-is_personally_confirmed"]', + lineManagerConfirmed: '[data-test="field-is_line_manager_confirmed"]', + }, +} + const clickContinueAndAssertUrl = (url) => { clickContinueButton() assertUrl(url) } describe('Adding an export win', () => { - const company = companyFaker() - - // Form steps and query params - const officerDetails = `?step=officer_details&company=${company.id}` - const creditForThisWin = `?step=credit_for_this_win&company=${company.id}` - const customerDetails = `?step=customer_details&company=${company.id}` - const winDetails = `?step=win_details&company=${company.id}` - const supportProvided = `?step=support_provided&company=${company.id}` - const checkBeforeSending = `?step=check_before_sending&company=${company.id}` - beforeEach(() => { cy.intercept('GET', `/api-proxy/v4/company/${company.id}`, company) cy.intercept('/api-proxy/adviser/?*', { - results: [...advisersListFaker(2), { id: '1', name: 'David Meyer' }], - }) - cy.intercept('GET', `/api-proxy/v4/metadata/team-type`, [ - ...teamTypeListFaker(2), - { id: '1', name: 'Investment (ITFG or IG)' }, + results: [ + { id: '100', name: 'David Meyer' }, + { id: '101', name: 'John Smith' }, + ], + }) + cy.intercept('GET', '/api-proxy/v4/metadata/team-type', [ + { id: '200', name: 'Investment (ITFG or IG)' }, + { id: '201', name: 'Trade (TD or ST)' }, ]) cy.intercept('GET', '/api-proxy/v4/metadata/hq-team-region-or-post?*', [ - ...hqTeamListFaker(2), - { id: '1', name: 'DIT Education' }, + { id: '300', name: 'DIT Education' }, + { id: '301', name: 'Healthcare UK' }, + ]) + cy.intercept('GET', '/api-proxy/v4/metadata/hvc', [ + { id: '400', name: 'Australia Consumer Goods & Retail: E004' }, + ]) + cy.intercept('GET', '/api-proxy/v4/metadata/support-type', [ + { + id: '500', + name: 'Market entry advice and support – DIT/FCO in UK', + }, + ]) + cy.intercept('GET', '/api-proxy/v4/metadata/associated-programme', [ + { id: '600', name: 'Afterburner' }, ]) }) context('Page headers', () => { it('should render both the header and subheader', () => { - cy.visit(`${urls.companies.exportWins.create()}${officerDetails}`) + cy.visit(`${urls.companies.exportWins.create()}${officerDetailsStep}`) assertLocalHeader('Add export win') cy.get('[data-test="subheading"]').should( 'have.text', @@ -61,20 +139,18 @@ describe('Adding an export win', () => { }) context('Officer details', () => { + const { officerDetails } = formFields + beforeEach(() => - cy.visit(`${urls.companies.exportWins.create()}${officerDetails}`) + cy.visit(`${urls.companies.exportWins.create()}${officerDetailsStep}`) ) it('should render an officer details heading', () => { - cy.get('[data-test="step-heading"]').should( - 'have.text', - 'Officer details' - ) + cy.get(officerDetails.heading).should('have.text', 'Officer details') }) it('should render Lead Officer name label and a Typeahead', () => { - const leadOfficer = '[data-test="field-lead_officer"]' - cy.get(leadOfficer).then((element) => { + cy.get(officerDetails.leadOfficer).then((element) => { assertFieldTypeahead({ element, label: 'Lead officer name', @@ -83,22 +159,20 @@ describe('Adding an export win', () => { }) it('should render both Team Type and HQ Team', () => { - const teamType = '[data-test="field-team_type"]' - const hqTeam = '[data-test="field-hq_team"]' // The HQ Team field is not visible until a team has been selected - cy.get(hqTeam).should('not.exist') - cy.get(teamType).then((element) => { + cy.get(officerDetails.hqTeam).should('not.exist') + cy.get(officerDetails.teamType).then((element) => { assertFieldTypeahead({ element, label: 'Team type', }) }) - cy.get(teamType).find('input').as('teamTypeInput') + cy.get(officerDetails.teamType).find('input').as('teamTypeInput') cy.get('@teamTypeInput').type('Inv') cy.get('@teamTypeInput').type('{downarrow}{enter}{esc}') // Now the user has selected a team the HQ Team field is visible - cy.get(hqTeam).should('exist') - cy.get(hqTeam).then((element) => { + cy.get(officerDetails.hqTeam).should('exist') + cy.get(officerDetails.hqTeam).then((element) => { assertFieldTypeahead({ element, label: 'HQ team, region or post', @@ -107,28 +181,33 @@ describe('Adding an export win', () => { }) it('should render a Team Members Typeahead and hint text', () => { - cy.get('[data-test="field-team_members"]').then((element) => { + cy.get(officerDetails.teamMembers).then((element) => { assertFieldTypeahead({ element, label: 'Team members (optional)', }) }) - cy.get('[data-test="hint-text"]').should( + cy.get(officerDetails.teamMembersHintText).should( 'have.text', 'You can add up to 5 team members. They will be notified when this win is updated.' ) }) it('should display validation error messages on mandatory fields', () => { - const teamType = '[data-test="field-team_type"]' - const leadOfficer = '[data-test="field-lead_officer"]' - const hqTeam = '[data-test="field-hq_team"]' clickContinueButton() assertErrorSummary(['Enter a lead officer', 'Select a team type']) - assertFieldError(cy.get(leadOfficer), 'Enter a lead officer', false) - assertFieldError(cy.get(teamType), 'Select a team type', false) + assertFieldError( + cy.get(officerDetails.leadOfficer), + 'Enter a lead officer', + false + ) + assertFieldError( + cy.get(officerDetails.teamType), + 'Select a team type', + false + ) // Select a team to reveal the HQ Team field - cy.get(teamType).find('input').as('teamTypeInput') + cy.get(officerDetails.teamType).find('input').as('teamTypeInput') cy.get('@teamTypeInput').type('Inv') cy.get('@teamTypeInput').type('{downarrow}{enter}{esc}') clickContinueButton() @@ -136,77 +215,73 @@ describe('Adding an export win', () => { 'Enter a lead officer', 'Select HQ team, region or post', ]) - assertFieldError(cy.get(hqTeam), 'Select HQ team, region or post', false) - }) - - it('should complete this step and continue to "Credit for this win"', () => { - const leadOfficer = '[data-test="field-lead_officer"]' - const teamType = '[data-test="field-team_type"]' - const hqTeam = '[data-test="field-hq_team"]' - cy.get(leadOfficer).selectTypeaheadOption('David') - cy.get(teamType).selectTypeaheadOption('Investment (ITFG or IG)') - cy.get(hqTeam).selectTypeaheadOption('DIT Education') - clickContinueAndAssertUrl(creditForThisWin) + assertFieldError( + cy.get(officerDetails.hqTeam), + 'Select HQ team, region or post', + false + ) }) }) context('Credit for this win', () => { + const { creditForThisWin } = formFields + beforeEach(() => - cy.visit(`${urls.companies.exportWins.create()}${creditForThisWin}`) + cy.visit(`${urls.companies.exportWins.create()}${creditForThisWinStep}`) ) it('should render a step heading', () => { - cy.get('[data-test="step-heading"]').should( + cy.get(creditForThisWin.heading).should( 'have.text', 'Credit for this win' ) }) it('should render a hint', () => { - cy.get('[data-test="hint"]').should( + cy.get(creditForThisWin.hint).should( 'have.text', 'Other teams that helped with this win should be added so they can be credited, this will not reduce your credit for this win.' ) }) it('should render two unselected radio buttons', () => { - cy.get('[data-test="field-credit_for_win"]').then((element) => { + cy.get(creditForThisWin.radiosBtns).then((element) => { assertFieldRadiosWithLegend({ element, legend: 'Did any other teams help with this win?', optionsCount: 2, }) }) - cy.get('[data-test="credit-for-win-yes"]') + cy.get(creditForThisWin.radiosBtnYes) .should('not.be.checked') .parent() .should('have.text', 'Yes') - cy.get('[data-test="credit-for-win-no"]') + cy.get(creditForThisWin.radiosBtnNo) .should('not.be.checked') .parent() .should('have.text', 'No') }) it('should go to the next step when selecting "No" and then "Continue"', () => { - cy.get('[data-test="credit-for-win-no"]').check() - clickContinueAndAssertUrl(customerDetails) + cy.get(creditForThisWin.radiosBtnNo).check() + clickContinueAndAssertUrl(customerDetailsStep) }) it('should render a legend and hint text', () => { - cy.get('[data-test="credit-for-win-yes"]').check() - cy.get('[data-test="field-addAnother"]') + cy.get(creditForThisWin.radiosBtnYes).check() + cy.get(creditForThisWin.addAnother) .find('legend') .eq(0) .should('have.text', 'Contributing advisers') - cy.get('[data-test="hint-text"]').should( + cy.get(creditForThisWin.hintText).should( 'have.text', 'Up to 5 advisers can be added.' ) }) it('should render a Typeahead for the contributing officer', () => { - cy.get('[data-test="credit-for-win-yes"]').check() - cy.get('[data-test="field-contributing_officer_0"]').then((element) => { + cy.get(creditForThisWin.radiosBtnYes).check() + cy.get(creditForThisWin.contributingOfficer).then((element) => { assertFieldTypeahead({ element, label: 'Contributing officer', @@ -215,8 +290,8 @@ describe('Adding an export win', () => { }) it('should render a Typeahead for the team type', () => { - cy.get('[data-test="credit-for-win-yes"]').check() - cy.get('[data-test="field-team_type_0"]').then((element) => { + cy.get(creditForThisWin.radiosBtnYes).check() + cy.get(creditForThisWin.teamType).then((element) => { assertFieldTypeahead({ element, label: 'Team type', @@ -225,8 +300,8 @@ describe('Adding an export win', () => { }) it('should render an "Add another" button', () => { - cy.get('[data-test="credit-for-win-yes"]').check() - cy.get('[data-test="add-another"]').should('exist') + cy.get(creditForThisWin.radiosBtnYes).check() + cy.get(creditForThisWin.addAnother).should('exist') }) it('should display validation error messages on mandatory fields', () => { @@ -234,28 +309,26 @@ describe('Adding an export win', () => { // Assert Yes and No radio buttons assertErrorSummary(['Select Yes or No']) assertFieldError( - cy.get('[data-test="field-credit_for_win"]'), + cy.get(creditForThisWin.radiosBtns), 'Select Yes or No', true ) - cy.get('[data-test="credit-for-win-yes"]').check() + cy.get(creditForThisWin.radiosBtnYes).check() clickContinueButton() // Assert Contributing officer and Team type assertErrorSummary(['Enter a contributing officer', 'Enter a team type']) assertFieldError( - cy.get('[data-test="field-contributing_officer_0"]'), + cy.get(creditForThisWin.contributingOfficer), 'Enter a contributing officer', false ) assertFieldError( - cy.get('[data-test="field-team_type_0"]'), + cy.get(creditForThisWin.teamType), 'Enter a team type', false ) // Select a team type to render the HQ team, region or post field - cy.get('[data-test="field-team_type_0"]') - .find('input') - .as('teamTypeInput') + cy.get(creditForThisWin.teamType).find('input').as('teamTypeInput') cy.get('@teamTypeInput').type('Inv') cy.get('@teamTypeInput').type('{downarrow}{enter}{esc}') clickContinueButton() @@ -265,48 +338,31 @@ describe('Adding an export win', () => { 'Enter a HQ team, region or post', ]) assertFieldError( - cy.get('[data-test="field-hq_team_0"]'), + cy.get(creditForThisWin.hqTeam), 'Enter a HQ team, region or post', false ) }) - - it('should complete this step and continue to "Customer details"', () => { - const contributingOfficer = '[data-test="field-contributing_officer_0"]' - const teamType = '[data-test="field-team_type_0"]' - const hqTeam = '[data-test="field-hq_team_0"]' - cy.get('[data-test="credit-for-win-yes"]').check() - cy.get(contributingOfficer).selectTypeaheadOption('David') - cy.get(teamType).selectTypeaheadOption('Investment (ITFG or IG)') - cy.get(hqTeam).selectTypeaheadOption('DIT Education') - clickContinueAndAssertUrl(customerDetails) - }) }) context('Customer details', () => { - const contacts = '[data-test="field-company_contacts"]' - const location = '[data-test="field-customer_location"]' - const potential = '[data-test="field-business_potential"]' - const experience = '[data-test="field-export_experience"]' + const { customerDetails } = formFields beforeEach(() => - cy.visit(`${urls.companies.exportWins.create()}${customerDetails}`) + cy.visit(`${urls.companies.exportWins.create()}${customerDetailsStep}`) ) it('should render a step heading', () => { - cy.get('[data-test="step-heading"]').should( - 'have.text', - 'Customer details' - ) + cy.get(customerDetails.heading).should('have.text', 'Customer details') }) it('should show a contact link and details', () => { - cy.get('[data-test="add-a-new-contact-link"]').should('be.visible') - cy.get('[data-test="contact-information-details"]').should('be.visible') + cy.get(customerDetails.addContactLink).should('be.visible') + cy.get(customerDetails.details).should('be.visible') }) it('should render Company contacts label and a Typeahead', () => { - cy.get(contacts).then((element) => { + cy.get(customerDetails.contacts).then((element) => { assertFieldTypeahead({ element, label: 'Company contacts', @@ -316,7 +372,7 @@ describe('Adding an export win', () => { }) it('should render HQ location label and a Typeahead', () => { - cy.get(location).then((element) => { + cy.get(customerDetails.location).then((element) => { assertFieldTypeahead({ element, label: 'HQ location', @@ -325,7 +381,7 @@ describe('Adding an export win', () => { }) it('should render Export potential label and a Typeahead', () => { - cy.get(potential).then((element) => { + cy.get(customerDetails.potential).then((element) => { assertFieldTypeahead({ element, label: 'Export potential', @@ -334,7 +390,7 @@ describe('Adding an export win', () => { }) it('should render Export potential label and a Typeahead', () => { - cy.get(experience).then((element) => { + cy.get(customerDetails.experience).then((element) => { assertFieldTypeahead({ element, label: 'Export experience', @@ -351,58 +407,49 @@ describe('Adding an export win', () => { 'Select export potential', 'Select export experience', ]) - assertFieldError(cy.get(contacts), 'Select a contact', true) - assertFieldError(cy.get(location), 'Select HQ location', false) - assertFieldError(cy.get(potential), 'Select export potential', false) - assertFieldError(cy.get(experience), 'Select export experience', true) - }) - - it('should complete this step and continue to "Win details"', () => { - cy.get(contacts).selectTypeaheadOption('Joseph Woof') - cy.get(location).selectTypeaheadOption('Scotland') - cy.get(potential).selectTypeaheadOption( - 'The company is a Medium Sized Business' + assertFieldError( + cy.get(customerDetails.contacts), + 'Select a contact', + true + ) + assertFieldError( + cy.get(customerDetails.location), + 'Select HQ location', + false + ) + assertFieldError( + cy.get(customerDetails.potential), + 'Select export potential', + false + ) + assertFieldError( + cy.get(customerDetails.experience), + 'Select export experience', + true ) - cy.get(experience).selectTypeaheadOption('Never exported') - clickContinueAndAssertUrl(winDetails) }) }) context('Win details', () => { - // Helpers - const twelveMonthsAgo = getTwelveMonthsAgo() - const month = twelveMonthsAgo.getMonth() + 1 - const year = twelveMonthsAgo.getFullYear() - - // Fields - const country = '[data-test="field-country"]' - const date = '[data-test="field-date"]' - const description = '[data-test="field-description"]' - const nameOfCustomer = '[data-test="field-name_of_customer"]' - const confidential = '[data-test="field-name_of_customer_confidential"]' - const businessType = '[data-test="field-business_type"]' - const winType = '[data-test="field-win_type"]' - const goodsVsServices = '[data-test="field-goods_vs_services"]' - const nameOfExport = '[data-test="field-name_of_export"]' - const sector = '[data-test="field-sector"]' + const { winDetails } = formFields beforeEach(() => - cy.visit(`${urls.companies.exportWins.create()}${winDetails}`) + cy.visit(`${urls.companies.exportWins.create()}${winDetailsStep}`) ) it('should render a step heading', () => { - cy.get('[data-test="step-heading"]').should('have.text', 'Win details') + cy.get(winDetails.heading).should('have.text', 'Win details') }) it('should render a hint', () => { - cy.get('[data-test="hint"]').should( + cy.get(winDetails.hint).should( 'have.text', 'The customer will be asked to confirm this information.' ) }) it('should render Destination country label and a Typeahead', () => { - cy.get(country).then((element) => { + cy.get(winDetails.country).then((element) => { assertFieldTypeahead({ element, label: 'Destination country', @@ -411,7 +458,7 @@ describe('Adding an export win', () => { }) it('should render the Win date', () => { - cy.get(date).then((element) => { + cy.get(winDetails.date).then((element) => { // Both Month and Year labels are tested within the assertion assertFieldDateShort({ element, @@ -422,7 +469,7 @@ describe('Adding an export win', () => { }) it('should render Summary of the support given', () => { - cy.get(description).then((element) => { + cy.get(winDetails.description).then((element) => { assertFieldTextarea({ element, label: 'Summary of the support given', @@ -433,7 +480,7 @@ describe('Adding an export win', () => { }) it('should renderer Overseas customer', () => { - cy.get(nameOfCustomer).then((element) => { + cy.get(winDetails.nameOfCustomer).then((element) => { assertFieldInput({ element, label: 'Overseas customer', @@ -444,7 +491,7 @@ describe('Adding an export win', () => { it('should render a Confidential checkbox', () => { assertFieldCheckboxes({ - element: confidential, + element: winDetails.confidential, hint: 'Check this box if your customer has asked for this not to be public (optional).', options: [ { @@ -456,7 +503,7 @@ describe('Adding an export win', () => { }) it('should renderer a type of business deal', () => { - cy.get(businessType).then((element) => { + cy.get(winDetails.businessType).then((element) => { assertFieldInput({ element, label: 'Type of business deal', @@ -468,7 +515,7 @@ describe('Adding an export win', () => { it('should render Type of win ', () => { assertFieldCheckboxes({ - element: winType, + element: winDetails.winType, legend: 'Type of win', options: [ { @@ -488,108 +535,83 @@ describe('Adding an export win', () => { }) it('should render the WinTypeValues component for each win type', () => { - const exportWinCheckbox = '[data-test="checkbox-export_win"]' - const exportWinTypeValues = '[data-test="win-type-values-export_win"]' - const businessSuccessCheckbox = - '[data-test="checkbox-business_success_win"]' - const businessSuccessTypeValues = - '[data-test="win-type-values-business_success_win"]' - const odiCheckbox = '[data-test="checkbox-odi_win"]' - const odiWinTypeValues = '[data-test="win-type-values-odi_win"]' - - cy.get(winType).as('winType') + cy.get(winDetails.winType).as('winType') // Export win cy.get('@winType') - .find(exportWinTypeValues) + .find(winDetails.winTypeValuesExport) .should('not.exist') .get('@winType') - .find(exportWinCheckbox) + .find(winDetails.exportWinCheckbox) .check() .next() - .get(exportWinTypeValues) + .get(winDetails.winTypeValuesExport) .should('exist') // Business type cy.get('@winType') - .find(businessSuccessTypeValues) + .find(winDetails.winTypeValuesBusSupp) .should('not.exist') .get('@winType') - .find(businessSuccessCheckbox) + .find(winDetails.businessSuccessCheckbox) .check() .next() - .get(businessSuccessTypeValues) + .get(winDetails.winTypeValuesBusSupp) .should('exist') // ODI cy.get('@winType') - .find(odiWinTypeValues) + .find(winDetails.winTypeValuesODI) .should('not.exist') .get('@winType') - .find(odiCheckbox) + .find(winDetails.odiCheckbox) .check() .next() - .get(odiWinTypeValues) + .get(winDetails.winTypeValuesODI) .should('exist') }) it('should render the total export value across all 3 win types', () => { - cy.get(winType).as('winType') + cy.get(winDetails.winType).as('winType') - // Check the Export checkbox to render the input fields - cy.get('@winType').find('[data-test="checkbox-export_win"]').check() + // Check all 3 win types to render 15 (3 x 5) inputs + cy.get('@winType').find(winDetails.exportWinCheckbox).check() + cy.get('@winType').find(winDetails.businessSuccessCheckbox).check() + cy.get('@winType').find(winDetails.odiCheckbox).check() - const exportWinFields = [ - '[data-test="export-win-0-input"]', - '[data-test="export-win-1-input"]', - '[data-test="export-win-2-input"]', - '[data-test="export-win-3-input"]', - '[data-test="export-win-4-input"]', - ] - exportWinFields.forEach((dataTest) => - cy.get('@winType').find(dataTest).type('1000000') - ) + const inputs = [...Array(5).keys()] - // Check the Business success checkbox to render the input fields - cy.get('@winType') - .find('[data-test="checkbox-business_success_win"]') - .check() - - const businessSuccessFields = [ - '[data-test="business-success-win-0-input"]', - '[data-test="business-success-win-1-input"]', - '[data-test="business-success-win-2-input"]', - '[data-test="business-success-win-3-input"]', - '[data-test="business-success-win-4-input"]', - ] - businessSuccessFields.forEach((dataTest) => - cy.get('@winType').find(dataTest).type('1000000') + inputs.forEach((index) => + cy + .get('@winType') + .find(`[data-test="export-win-${index}-input"]`) + .type('1000000') ) - // Check the ODI checkbox to render the input fields - cy.get('@winType').find('[data-test="checkbox-odi_win"]').check() + inputs.forEach((index) => + cy + .get('@winType') + .find(`[data-test="business-success-win-${index}-input"]`) + .type('2000000') + ) - const odiFields = [ - '[data-test="odi-win-0-input"]', - '[data-test="odi-win-1-input"]', - '[data-test="odi-win-2-input"]', - '[data-test="odi-win-3-input"]', - '[data-test="odi-win-4-input"]', - ] - odiFields.forEach((dataTest) => - cy.get('@winType').find(dataTest).type('1000000') + inputs.forEach((index) => + cy + .get('@winType') + .find(`[data-test="odi-win-${index}-input"]`) + .type('3000000') ) // Assert the total export value - cy.get('[data-test="total-export-value"]').should( + cy.get(winDetails.totalExportValue).should( 'have.text', - 'Total export value: £15,000,000' + 'Total export value: £30,000,000' ) }) it('should render Goods and Services', () => { assertFieldCheckboxes({ - element: goodsVsServices, + element: winDetails.goodsVsServices, legend: 'What does the value relate to?', hint: 'Select goods or services', options: [ @@ -606,7 +628,7 @@ describe('Adding an export win', () => { }) it('should renderer name of goods or services', () => { - cy.get(nameOfExport).then((element) => { + cy.get(winDetails.nameOfExport).then((element) => { assertFieldInput({ element, label: 'Name of goods or services', @@ -617,7 +639,7 @@ describe('Adding an export win', () => { }) it('should render a sector label and typeahead', () => { - cy.get(sector).then((element) => { + cy.get(winDetails.sector).then((element) => { assertFieldTypeahead({ element, label: 'Sector', @@ -638,80 +660,62 @@ describe('Adding an export win', () => { 'Enter the name of goods or services', 'Enter a sector', ]) - assertFieldError(cy.get(country), 'Choose a destination country', false) - assertFieldError(cy.get(date), 'Enter the win date', true) - assertFieldError(cy.get(description), 'Enter a summary', true) assertFieldError( - cy.get(nameOfCustomer), + cy.get(winDetails.country), + 'Choose a destination country', + false + ) + assertFieldError(cy.get(winDetails.date), 'Enter the win date', true) + assertFieldError(cy.get(winDetails.description), 'Enter a summary', true) + assertFieldError( + cy.get(winDetails.nameOfCustomer), 'Enter the name of the overseas customer', false ) assertFieldError( - cy.get(businessType), + cy.get(winDetails.businessType), 'Enter the type of business deal', true ) - assertFieldError(cy.get(winType), 'Choose at least one type of win', true) + assertFieldError( + cy.get(winDetails.winType), + 'Choose at least one type of win', + true + ) // We can't use assertFieldError here as it picks up the wrong span - cy.get(goodsVsServices).should('contain', 'Select at least one option') + cy.get(winDetails.goodsVsServices).should( + 'contain', + 'Select at least one option' + ) assertFieldError( - cy.get(nameOfExport), + cy.get(winDetails.nameOfExport), 'Enter the name of goods or services', true ) - assertFieldError(cy.get(sector), 'Enter a sector', false) - }) - - it('should complete this step and continue to "Support provided"', () => { - cy.get(country).selectTypeaheadOption('United states') - cy.get(date).as('winDate') - cy.get('@winDate').find('[data-test="date-month"]').type(month) - cy.get('@winDate').find('[data-test="date-year"]').type(year) - cy.get(description).find('textarea').type('Foo bar baz') - cy.get(nameOfCustomer).find('input').type('David French') - cy.get(confidential).find('input[type="checkbox"]').check() - cy.get(businessType).find('input').type('Contract') - cy.get(winType).find('[data-test="checkbox-export_win"]').check() - cy.get(goodsVsServices).find('input[type="checkbox"]').eq(0).check() // Goods - cy.get(nameOfExport).find('input').type('Biscuits') - cy.get(sector).selectTypeaheadOption('Advanced Engineering') - clickContinueAndAssertUrl(supportProvided) + assertFieldError(cy.get(winDetails.sector), 'Enter a sector', false) }) }) context('Support provided', () => { - const hvc = '[data-test="field-hvc"]' - const typeOfSupport = '[data-test="field-type_of_support"]' - const associatedProgramme = '[data-test="field-associated_programme"]' - const personallyConfirmed = '[data-test="field-is_personally_confirmed"]' - const lineManagerConfirmed = '[data-test="field-is_line_manager_confirmed"]' - - beforeEach(() => { - cy.intercept('/api-proxy/v4/metadata/hvc', [ - { id: '1', name: 'Australia Consumer Goods & Retail: E004' }, - ]) - cy.intercept('/api-proxy/v4/metadata/support-type', [ - { id: '1', name: 'Market entry advice and support – DIT/FCO in UK' }, - ]) - cy.intercept('/api-proxy/v4/metadata/associated-programme', [ - { id: '1', name: 'Afterburner' }, - ]) - cy.visit(`${urls.companies.exportWins.create()}${supportProvided}`) + const { supportProvided } = formFields + + before(() => { + cy.visit(`${urls.companies.exportWins.create()}${supportProvidedStep}`) }) it('should render a step heading', () => { - cy.get('[data-test="step-heading"]').should('have.text', 'Support given') + cy.get(supportProvided.heading).should('have.text', 'Support given') }) it('should render a hint', () => { - cy.get('[data-test="hint"]').should( + cy.get(supportProvided.hint).should( 'have.text', 'Did any of these help the customer achieve this win?' ) }) it('should render a typeahead for high value campaign', () => { - cy.get(hvc).then((element) => { + cy.get(supportProvided.hvc).then((element) => { assertFieldTypeahead({ element, label: 'High Value Campaign (HVC) code (optional)', @@ -721,7 +725,7 @@ describe('Adding an export win', () => { }) it('should render a support given typeahead', () => { - cy.get(typeOfSupport).then((element) => { + cy.get(supportProvided.typeOfSupport).then((element) => { assertFieldTypeahead({ element, label: 'What type of support was given?', @@ -731,7 +735,7 @@ describe('Adding an export win', () => { }) it('should render an associated programme typeahead', () => { - cy.get(associatedProgramme).then((element) => { + cy.get(supportProvided.associatedProgramme).then((element) => { assertFieldTypeahead({ element, label: @@ -743,7 +747,7 @@ describe('Adding an export win', () => { it('should render personally confirmed checkbox', () => { assertFieldCheckboxes({ - element: personallyConfirmed, + element: supportProvided.personallyConfirmed, options: [ { label: 'I confirm that this information is complete and accurate.', @@ -755,7 +759,7 @@ describe('Adding an export win', () => { it('should render a manager confirmed checkbox', () => { assertFieldCheckboxes({ - element: lineManagerConfirmed, + element: supportProvided.lineManagerConfirmed, options: [ { label: @@ -775,32 +779,23 @@ describe('Adding an export win', () => { 'Confirm your line manager has agreed that this win should be recorded', ]) assertFieldError( - cy.get(typeOfSupport), + cy.get(supportProvided.typeOfSupport), 'Select at least one type of support', true ) assertFieldError( - cy.get(associatedProgramme), + cy.get(supportProvided.associatedProgramme), 'Select at least one type of DBT campaign or event', true ) - cy.get(personallyConfirmed).should( + cy.get(supportProvided.personallyConfirmed).should( 'contain', 'Confirm that this information is complete and accurate' ) - cy.get(lineManagerConfirmed).should( + cy.get(supportProvided.lineManagerConfirmed).should( 'contain', 'Confirm your line manager has agreed that this win should be recorded' ) }) - - it('should complete this step and continue to "Check before sending"', () => { - cy.get(hvc).selectTypeaheadOption('Aus') - cy.get(typeOfSupport).selectTypeaheadOption('Mar') - cy.get(associatedProgramme).selectTypeaheadOption('Aft') - cy.get(personallyConfirmed).find('[data-test="checkbox-yes"]').check() - cy.get(lineManagerConfirmed).find('[data-test="checkbox-yes"]').check() - clickContinueAndAssertUrl(checkBeforeSending) - }) }) }) diff --git a/test/sandbox/package-lock.json b/test/sandbox/package-lock.json index a83a26a409d..f0eec170a44 100644 --- a/test/sandbox/package-lock.json +++ b/test/sandbox/package-lock.json @@ -11,14 +11,14 @@ "express": "^4.17.1", "ini": "^4.1.1", "lodash": "^4.17.21", - "nodemon": "^3.0.2" + "nodemon": "^3.0.3" }, "devDependencies": { - "@babel/core": "^7.22.20", - "@babel/eslint-parser": "^7.22.15", + "@babel/eslint-parser": "^7.23.9", + "@babel/core": "^7.23.9", "@babel/plugin-syntax-import-assertions": "^7.22.5", - "@babel/runtime": "^7.23.8", - "@faker-js/faker": "^8.3.1", + "@faker-js/faker": "^8.4.0", + "@babel/runtime": "^7.23.9", "eslint": "^8.50.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.28.1", @@ -74,9 +74,9 @@ } }, "node_modules/@babel/core": { - "version": "7.23.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.7.tgz", - "integrity": "sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.9.tgz", + "integrity": "sha512-5q0175NOjddqpvvzU+kDiSOAk4PfdO6FvwCWoQ6RO7rTzEe8vlo+4HVfcnAREhD4npMs0e9uZypjTwzZPCf/cw==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", @@ -84,11 +84,11 @@ "@babel/generator": "^7.23.6", "@babel/helper-compilation-targets": "^7.23.6", "@babel/helper-module-transforms": "^7.23.3", - "@babel/helpers": "^7.23.7", - "@babel/parser": "^7.23.6", - "@babel/template": "^7.22.15", - "@babel/traverse": "^7.23.7", - "@babel/types": "^7.23.6", + "@babel/helpers": "^7.23.9", + "@babel/parser": "^7.23.9", + "@babel/template": "^7.23.9", + "@babel/traverse": "^7.23.9", + "@babel/types": "^7.23.9", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -127,9 +127,9 @@ "dev": true }, "node_modules/@babel/eslint-parser": { - "version": "7.23.3", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.23.3.tgz", - "integrity": "sha512-9bTuNlyx7oSstodm1cR1bECj4fkiknsDa1YniISkJemMY3DGhJNYBECbe6QD/q54mp2J8VO66jW3/7uP//iFCw==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.23.9.tgz", + "integrity": "sha512-xPndlO7qxiJbn0ATvfXQBjCS7qApc9xmKHArgI/FTEFxXas5dnjC/VqM37lfZun9dclRYcn+YQAr6uDFy0bB2g==", "dev": true, "dependencies": { "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", @@ -316,14 +316,14 @@ } }, "node_modules/@babel/helpers": { - "version": "7.23.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.7.tgz", - "integrity": "sha512-6AMnjCoC8wjqBzDHkuqpa7jAKwvMo4dC+lr/TFBz+ucfulO1XMpDnwWPGBNwClOKZ8h6xn5N81W/R5OrcKtCbQ==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.9.tgz", + "integrity": "sha512-87ICKgU5t5SzOT7sBMfCOZQ2rHjRU+Pcb9BoILMYz600W6DkVRLFBPwQ18gwUVvggqXivaUakpnxWQGbpywbBQ==", "dev": true, "dependencies": { - "@babel/template": "^7.22.15", - "@babel/traverse": "^7.23.7", - "@babel/types": "^7.23.6" + "@babel/template": "^7.23.9", + "@babel/traverse": "^7.23.9", + "@babel/types": "^7.23.9" }, "engines": { "node": ">=6.9.0" @@ -344,9 +344,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.23.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.6.tgz", - "integrity": "sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.9.tgz", + "integrity": "sha512-9tcKgqKbs3xGJ+NtKF2ndOBBLVwPjl1SHxPQkd36r3Dlirw3xWUeGaTbqr7uGZcTaxkVNwc+03SVP7aCdWrTlA==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -371,9 +371,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.23.8", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.8.tgz", - "integrity": "sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.9.tgz", + "integrity": "sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw==", "dev": true, "dependencies": { "regenerator-runtime": "^0.14.0" @@ -383,23 +383,23 @@ } }, "node_modules/@babel/template": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", - "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.23.9.tgz", + "integrity": "sha512-+xrD2BWLpvHKNmX2QbpdpsBaWnRxahMwJjO+KZk2JOElj5nSmKezyS1B4u+QbHMTX69t4ukm6hh9lsYQ7GHCKA==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.13", - "@babel/parser": "^7.22.15", - "@babel/types": "^7.22.15" + "@babel/code-frame": "^7.23.5", + "@babel/parser": "^7.23.9", + "@babel/types": "^7.23.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.23.7", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.7.tgz", - "integrity": "sha512-tY3mM8rH9jM0YHFGyfC0/xf+SB5eKUu7HPj7/k3fpi9dAlsMc5YbQvDi0Sh2QTPXqMhyaAtzAr807TIyfQrmyg==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.9.tgz", + "integrity": "sha512-I/4UJ9vs90OkBtY6iiiTORVMyIhJ4kAVmsKo9KFc8UOxMeUfi2hvtIBsET5u9GizXE6/GFSuKCTNfgCswuEjRg==", "dev": true, "dependencies": { "@babel/code-frame": "^7.23.5", @@ -408,8 +408,8 @@ "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.23.6", - "@babel/types": "^7.23.6", + "@babel/parser": "^7.23.9", + "@babel/types": "^7.23.9", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -441,9 +441,9 @@ "dev": true }, "node_modules/@babel/types": { - "version": "7.23.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.6.tgz", - "integrity": "sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.9.tgz", + "integrity": "sha512-dQjSq/7HaSjRM43FFGnv5keM2HsxpmyV1PfaSVm0nzzjwwTmjOe6J4bC8e3+pTEIgHaHj+1ZlLThRJ2auc/w1Q==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.23.4", @@ -561,9 +561,9 @@ } }, "node_modules/@faker-js/faker": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.3.1.tgz", - "integrity": "sha512-FdgpFxY6V6rLZE9mmIBb9hM0xpfvQOSNOLnzolzKwsE1DH+gC7lEKV1p1IbR0lAYyvYd5a4u3qWJzowUkw1bIw==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.4.0.tgz", + "integrity": "sha512-htW87352wzUCdX1jyUQocUcmAaFqcR/w082EC8iP/gtkF0K+aKcBp0hR5Arb7dzR8tQ1TrhE9DNa5EbJELm84w==", "dev": true, "funding": [ { @@ -3028,9 +3028,9 @@ "dev": true }, "node_modules/nodemon": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.2.tgz", - "integrity": "sha512-9qIN2LNTrEzpOPBaWHTm4Asy1LxXLSickZStAQ4IZe7zsoIpD/A7LWxhZV3t4Zu352uBcqVnRsDXSMR2Sc3lTA==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.3.tgz", + "integrity": "sha512-7jH/NXbFPxVaMwmBCC2B9F/V6X1VkEdNgx3iu9jji8WxWcvhMWkmhNWhI5077zknOnZnBzba9hZP6bCPJLSReQ==", "dependencies": { "chokidar": "^3.5.2", "debug": "^4", diff --git a/test/sandbox/package.json b/test/sandbox/package.json index 46aea233983..8a9066b5f65 100644 --- a/test/sandbox/package.json +++ b/test/sandbox/package.json @@ -8,14 +8,14 @@ "express": "^4.17.1", "ini": "^4.1.1", "lodash": "^4.17.21", - "nodemon": "^3.0.2" + "nodemon": "^3.0.3" }, "devDependencies": { - "@babel/core": "^7.22.20", - "@babel/eslint-parser": "^7.22.15", + "@babel/eslint-parser": "^7.23.9", + "@babel/core": "^7.23.9", "@babel/plugin-syntax-import-assertions": "^7.22.5", - "@babel/runtime": "^7.23.8", - "@faker-js/faker": "^8.3.1", + "@faker-js/faker": "^8.4.0", + "@babel/runtime": "^7.23.9", "eslint": "^8.50.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.28.1",