{"id":20038660,"url":"https://github.com/defra/cdp-portal-tests","last_synced_at":"2025-07-10T05:37:40.910Z","repository":{"id":208444811,"uuid":"721653762","full_name":"DEFRA/cdp-portal-tests","owner":"DEFRA","description":"Git repository for service cdp-portal-tests","archived":false,"fork":false,"pushed_at":"2024-11-06T12:06:42.000Z","size":1906,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-06T12:26:53.069Z","etag":null,"topics":["cdp","journey","test","test-suite"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DEFRA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-21T13:58:27.000Z","updated_at":"2024-11-06T12:06:44.000Z","dependencies_parsed_at":"2023-12-22T19:23:45.035Z","dependency_job_id":"ccfbc27e-0f15-4290-b1a9-14b685561eda","html_url":"https://github.com/DEFRA/cdp-portal-tests","commit_stats":null,"previous_names":["defra/cdp-portal-tests"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-portal-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-portal-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-portal-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fcdp-portal-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DEFRA","download_url":"https://codeload.github.com/DEFRA/cdp-portal-tests/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224431329,"owners_count":17310095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdp","journey","test","test-suite"],"created_at":"2024-11-13T10:31:44.280Z","updated_at":"2024-11-13T10:31:44.781Z","avatar_url":"https://github.com/DEFRA.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cdp-portal-tests\n\nCdp Portal test suite\n\n[![Integration Tests](https://github.com/DEFRA/cdp-portal-frontend/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/DEFRA/cdp-portal-frontend/actions/workflows/integration-tests.yml)\n\n- [Requirements](#requirements)\n  - [Node.js](#nodejs)\n- [Local development](#local-development)\n  - [Setup](#setup)\n- [Test suite requirements](#test-suite-requirements)\n  - [Running portal using cdp-local-environment](#running-portal-using-cdp-local-environment)\n  - [Running portal using cdp-portal-stubs](#running-portal-using-cdp-portal-stubs)\n  - [Running the test suite](#running-the-test-suite)\n  - [Debugging](#debugging)\n    - [WebdriverIO Plugin](#webdriverio-plugin)\n    - [Setup in IntelliJ/Webstorm](#setup-in-intellijwebstorm)\n    - [Debug environment variable](#debug-environment-variable)\n    - [WebdriverIO debug command](#webdriverio-debug-command)\n- [Best practices](#best-practices)\n  - [Finding elements in tests](#finding-elements-in-tests)\n  - [Components](#components)\n  - [Page objects](#page-objects)\n  - [Spec files](#spec-files)\n- [Licence](#licence)\n  - [About the licence](#about-the-licence)\n\n## Requirements\n\n### Node.js\n\nPlease install [Node.js](http://nodejs.org/) `\u003e= v20` and [npm](https://nodejs.org/) `\u003e= v9`. You will find it\neasier to use the Node Version Manager [nvm](https://github.com/creationix/nvm)\n\nTo use the correct version of Node.js for this application, via nvm:\n\n```bash\ncd cdp-portal-tests\nnvm use\n```\n\n## Local development\n\n### Setup\n\nInstall application dependencies:\n\n```bash\nnpm install\n```\n\n## Test suite requirements\n\n- mongodb\n- redis\n- localstack\n- [cdp-portal-stubs](https://github.com/defra/cdp-portal-stubs)\n- cdp portal running and pointed at stubs/local services\n\n### Running portal using cdp-local-environment\n\n\u003e Note there is currently a bug on macs where this does not work\n\nThe easiest way of setting this up:\n\n- clone [cdp-local-environment](https://github.com/defra/cdp-local-environment)\n- start the portal profile\n\n```bash\n$ docker compose --profile portal up\n```\n\n### Running portal using cdp-portal-stubs\n\nYou can also set up your local suite of Portal apps via [cdp-portal-stubs](https://github.com/defra/cdp-portal-stubs)\n\n- clone [cdp-portal-stubs](https://github.com/defra/cdp-portal-stubs)\n- start all the applications listed in the [README.md](https://github.com/defra/cdp-portal-stubs#setup)\n\n### Running the test suite\n\nTo run the suite headless:\n\n```bash\n$ npm test\n```\n\nTo run the test suite with a browser:\n\n\u003e This makes it much easier to debug\n\n```bash\nnpm run test:local\n```\n\nTo run a specific test with a browser:\n\n```bash\nnpm run test:local -- --spec ./test/specs/TESTFILE.js\n```\n\n### Debugging\n\n#### WebdriverIO Plugin\n\nIn IntelliJ and Webstorm use the [WebdriverIO Plugin](https://plugins.jetbrains.com/plugin/16147-webdriverio). This\nprovides full run, debug and breakpoint capabilities in your WebDriverIO tests.\n\n#### Setup in IntelliJ/Webstorm\n\n1. Add a `WebdriverIO` configuration template\n1. `Run -\u003e Edit configurations`\n1. `Edit configuration templates -\u003e WebdriverIO`\n1. Add the following values to the `WebdriverIO` configuration template:\n   ![WebDriverIO configuration template](docs/webdriverio-plugin/webdriverio-configuration-template.png?raw=true)\n1. Add an `All tests configuration`\n1. `Run -\u003e Edit configurations`\n1. `Add new configuration -\u003e WebdriverIO`\n1. `Add the values shown in the following image`:\n   ![WebDriverIO all tests configuration](docs/webdriverio-plugin/all-tests.png?raw=true)\n1. You can now run and debug your tests in IntelliJ/Webstorm:\n   ![WebDriverIO with test controls](docs/webdriverio-plugin/with-test-controls.png?raw=true)\n\n#### Debug environment variable\n\nYou can also set the following env:\n\n\u003e This provides debug config in the [wdio.local.conf.js](./wdio.local.conf.js) file\n\n```bash\nDEBUG=true\n```\n\nOr use the npm script:\n\n\u003e This script automatically sets the debug environment variable\n\n```bash\nnpm run test-local:debug\n```\n\n#### WebdriverIO debug command\n\nUse the following command in code:\n\n```javascript\nbrowser.debug()\n```\n\n## Best practices\n\n- Keep these tests organised, clean and maintainable as this repository is likely to grow in size with the\n  `cdp-portal-frontend`\n- Test the `cdp-portal-frontend` as a user would use it\n- Test the important flows, not too many, just enough to give you confidence. User Journey tests are expensive\n- Have a read through [WebDriverIO best practices](https://webdriver.io/docs/bestpractices/) for more information\n\n### Finding elements in tests\n\nWhen writing tests, pages and components change. To avoid complex, brittle selectors. Or selectors coupled to CSS\nclasses or JavaScript hooks, you should use `[data-testid=\"\u003cname\u003e\"]` attributes.\nUsing test data attributes allows you to find elements via an explicit testing hook, which rarely changes. This is a\nmore robust way to find elements in tests and avoids having to unnecessarily update tests.\n\nFor example:\n\n1. Finding an element traversing the DOM using CSS styling classes\n\n   \u003e Find the second button in the grid on the right of the page inside a div with the classes `container` and `grid`\n\n2. Finding an element using CSS styling classes\n\n   \u003e Find the button with the class `app-button` and `app-button--secondary`\n\n3. Finding an element by data attribute and text content\n   \u003e Find the button with the data testid attribute `[data-testid=\"create-microservice-submit\"]` and the text `Save`\n\nAs you can see the last option is much more robust. It avoids using CSS classes that change. It avoids referencing\nand traversing the `DOM`, which can be brittle. It avoids having to update tests when nothing has really changed tests\nwise.\n\n### Components\n\nThe [component helpers](test/components) are based on components or groups of elements in the `cdp-portal-frontend`.\nThese helpers provide simple methods to test flows and components.\n\n### Page objects\n\nThe [page objects](test/page-objects) are based on the pages/domain objects found in the `cdp-portal-frontend`. All\npage objects extend from the [Page](test/page-objects/page.js) class which provides common methods for all pages.\n\n### Spec files\n\nThe [specs](test/specs) are the flows/features found in the `cdp-portal-frontend` that we are testing. This is where\nthe tests and expectations can be found.\n\n## Licence\n\nTHIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:\n\n\u003chttp://www.nationalarchives.gov.uk/doc/open-government-licence/version/3\u003e\n\nThe following attribution statement MUST be cited in your products and applications when using this information.\n\n\u003e Contains public sector information licensed under the Open Government licence v3\n\n### About the licence\n\nThe Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable\ninformation providers in the public sector to license the use and re-use of their information under a common open\nlicence.\n\nIt is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fcdp-portal-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefra%2Fcdp-portal-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fcdp-portal-tests/lists"}