-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to match features in CHA accp. test project (#17)
We recently added the project [SROC Charging Module API tests](https://github.com/DEFRA/sroc-charging-module-api-tests) to our suite of tools. It is also Cypress based and will be used to test the [Charging Module API](https://github.com/DEFRA/sroc-charging-module-api) going forward. We started with this project as a base and then made the necessary amendments to allow us to test an API. Along the way, we also made a few other improvements. This change is about bringing those improvements back into this project and keeping the 2 consistent to make it easier to switch between them. The keys changes are - use `*.env` files for all customer configuration and store them in an `/environments` folder - add the ability to generate a test report to make it easier to share results with other stakeholders - adding CI support to the project
- Loading branch information
1 parent
6b86212
commit 25a7ce3
Showing
27 changed files
with
10,184 additions
and
1,367 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: CI | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
# You must use a Linux environment when using service containers or container jobs | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Downloads a copy of the code in your repository before running CI tests | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Check for 'temporary' tags i.e. tags often used when working on a feature/scenario but which we don't want | ||
# appearing in the final commit to main | ||
# | ||
# Reworking of https://stackoverflow.com/a/21788642/6117745 | ||
- name: Temporary tag check | ||
run: | | ||
! grep -r --include="*.feature" "@wip\|@focus" cypress/integration/ | ||
# Our projects use .nvmrc files to specify the node version to use. We can read and then output it as the result | ||
# this step. Subsequent steps can then access the value | ||
- name: Read Node version | ||
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" | ||
# Give the step an ID to make it easier to refer to | ||
id: nvm | ||
|
||
# Gets the version to use by referring to the previous step | ||
- name: Install Node | ||
uses: actions/[email protected] | ||
with: | ||
node-version: "${{ steps.nvm.outputs.NVMRC }}" | ||
|
||
# Speeds up workflows by reading the node modules from cache. Obviously you need to run it at least once, and the | ||
# cache will be updated should the package-lock.json file change | ||
- name: Cache Node modules | ||
uses: actions/cache@v2 | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
path: ~/.npm | ||
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.OS }}-node- | ||
${{ runner.OS }}- | ||
# Performs a clean installation of all dependencies in the `package.json` file | ||
# For more information, see https://docs.npmjs.com/cli/ci.html | ||
- name: Install dependencies | ||
run: npm ci | ||
|
||
# Run linting first. No point running the tests if there is a linting issue | ||
- name: Run lint check | ||
run: | | ||
npm run lint | ||
# We don't have unit tests in this project. We also can't access the service as its hidden behind a VPN. Instead | ||
# we run a special CI test to confirm we haven't broken being able to run the project | ||
- name: Run unit tests | ||
run: | | ||
npm run cy:run:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
}, | ||
"testFiles": "**/*.feature", | ||
"video": false, | ||
"baseUrl": "http://localhost:3000", | ||
"users": { | ||
"system": { | ||
"email": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@ci | ||
Feature: Continuous integration check of the project | ||
As a contributor to this project | ||
I want to know a change I made hasn't broken it (though it may have failing tests) | ||
So that we have a reliable base on which to build our acceptance tests | ||
|
||
Scenario: Check project will run | ||
Given a cucumber that is 30 cm long | ||
When I cut it in halves | ||
Then I have two cucumbers | ||
And both are 15 cm long |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps' | ||
|
||
Given('a cucumber that is {int} cm long', (length) => { | ||
cy.wrap({ color: 'green', size: length }).as('cucumber') | ||
}) | ||
|
||
When('I cut it in halves', () => { | ||
cy.get('@cucumber').then((cucumber) => { | ||
cy.wrap( | ||
[{ color: 'green', size: cucumber.size / 2 }, { color: 'green', size: cucumber.size / 2 }] | ||
).as('choppedCucumbers') | ||
}) | ||
}) | ||
|
||
Then('I have two cucumbers', () => { | ||
cy.get('@choppedCucumbers').then((choppedCucumbers) => { | ||
expect(choppedCucumbers).to.have.lengthOf(2) | ||
}) | ||
}) | ||
|
||
And('both are {int} cm long', (length) => { | ||
cy.get('@choppedCucumbers').then((choppedCucumbers) => { | ||
choppedCucumbers.forEach((cucumber) => { | ||
expect(cucumber.size).to.equal(length) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { Then } from 'cypress-cucumber-preprocessor/steps' | ||
|
||
Then(`I see {string} in the main heading`, (title) => { | ||
Then('I see {string} in the main heading', (title) => { | ||
cy.get('h1').contains(title) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { Before, When, Then, And } from 'cypress-cucumber-preprocessor/steps' | ||
import { When, Then, And } from 'cypress-cucumber-preprocessor/steps' | ||
import ExportDataPage from '../../pages/export_data_page' | ||
import TransactionsPage from '../../pages/transactions_page' | ||
|
||
When('I select the {string} regime', (regime) => { | ||
TransactionsPage.regimeMenu().click() | ||
TransactionsPage.regimeMenuItem(regime).click() | ||
}) | ||
TransactionsPage.regimeMenu().click() | ||
TransactionsPage.regimeMenuItem(regime).click() | ||
}) | ||
|
||
And('I proceed to view file download details', () => { | ||
TransactionsPage.transactionMenu().click() | ||
TransactionsPage.downloadTransactionDataMenuItem().click() | ||
}) | ||
TransactionsPage.transactionMenu().click() | ||
TransactionsPage.downloadTransactionDataMenuItem().click() | ||
}) | ||
|
||
Then('I can view the Data Protection Notice', () => { | ||
ExportDataPage.dataProtectionNotice().should('be.visible') | ||
}) | ||
}) | ||
|
||
And('I can download transaction data', () => { | ||
ExportDataPage.downloadBtn().should('have.attr', 'href', '/regimes/pas/data_export/download') | ||
//DownloadTransactionFilePage.downloadBtn().click() | ||
}) | ||
// DownloadTransactionFilePage.downloadBtn().click() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
class AnnualBillingFileDetailsPage { | ||
|
||
static mainHeading () { | ||
return cy.get('h1') | ||
} | ||
static mainHeading () { | ||
return cy.get('h1') | ||
} | ||
|
||
static errorsHeading () { | ||
return cy.get('h2') | ||
} | ||
|
||
static fileDetailsPanel () { | ||
return cy.get('.panel') | ||
} | ||
static errorsHeading () { | ||
return cy.get('h2') | ||
} | ||
|
||
static backBtn () { | ||
return cy.get('.btn.btn-secondary') | ||
} | ||
|
||
static fileDetailsPanel () { | ||
return cy.get('.panel') | ||
} | ||
|
||
export default AnnualBillingFileDetailsPage | ||
|
||
static backBtn () { | ||
return cy.get('.btn.btn-secondary') | ||
} | ||
} | ||
|
||
export default AnnualBillingFileDetailsPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
class AnnualBillingPage { | ||
|
||
static mainHeading () { | ||
return cy.get('h1') | ||
} | ||
|
||
static dataFilesTable () { | ||
return cy.get('.table') | ||
} | ||
static mainHeading () { | ||
return cy.get('h1') | ||
} | ||
|
||
static dataFilesTable () { | ||
return cy.get('.table') | ||
} | ||
|
||
static fileNameLink () { | ||
return cy.get('.table > tbody > tr > td > [href="/regimes/wml/annual_billing_data_files/48"]') | ||
} | ||
|
||
static fileNameLink () { | ||
return cy.get('.table > tbody > tr > td > [href="/regimes/wml/annual_billing_data_files/48"]') | ||
} | ||
export default AnnualBillingPage | ||
} | ||
|
||
export default AnnualBillingPage |
Oops, something went wrong.