Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
F2P-47: eslint update to include cypress.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3op2 committed Mar 30, 2022
1 parent 9446ecf commit 03c45a9
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 81 deletions.
5 changes: 1 addition & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
node_modules
build
package.json
cypress
**/*.test.js
**/*.spec.js
package.json
22 changes: 20 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"plugin:react/recommended",
"prettier"
],
"plugins": ["react", "prettier", "react-hooks"],
"plugins": ["react", "prettier", "react-hooks", "cypress"],
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
Expand Down Expand Up @@ -40,5 +40,23 @@
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"no-unused-vars": ["error", { "ignoreRestSiblings": true }]
}
},
"overrides": [
{
"files": ["**/*.{spec,test}.js"],
"rules": {
"prettier/prettier": "warn",
"no-unused-vars": ["error", { "ignoreRestSiblings": true }],
"cypress/no-assigning-return-values": "error",
"cypress/no-unnecessary-waiting": "error",
"cypress/assertion-before-screenshot": "warn",
"cypress/no-force": "warn",
"cypress/no-async-tests": "error",
"cypress/no-pause": "error"
},
"env": {
"cypress/globals": true
}
}
]
}
37 changes: 7 additions & 30 deletions .github/workflows/react-lint-testing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TestLinting
name: Branch

on:
push:
Expand All @@ -10,46 +10,23 @@ on:
type: boolean

jobs:
test:
build:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x

- name: Install dependencies
run: |
npm ci
run: npm ci
- name: Run lint
run: |
npm run lint
run: npm run lint
- name: Run component tests
run: npm t
- name: Print tag if present
run: |
echo "Tags: $TAGS"
env:
TAGS: ${{ github.event.inputs.tags }}

check-version:
name: 'Check version'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- run: git fetch --depth=1 --tags origin
- name: Install yq
run: sudo snap install yq
- name: Check Build Version
id: get_version
run: ./scripts/check-version.sh
shell: bash
- name: Error if version is not increased
shell: bash
run: |
exit $([[ "${{steps.get_version.outputs.IS_NEW_VERSION}}" = "true" ]] && echo 0 || echo 1)
TAGS: ${{ github.event.inputs.tags }}
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ jobs:
- name: Lint
run: npm run lint

integration:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies
run: npm ci
- name: Run cypress integration tests
uses: cypress-io/github-action@v2
with:
browser: chrome
record: false
headless: true
build: npm run build
start: npm start
wait-on: 'http://localhost:3000'
env:
CYPRESS_TEST_USERNAME: ${{ secrets.AUTH0_USERNAME }}
CYPRESS_TEST_PASSWORD: ${{ secrets.AUTH0_PASSWORD }}

check-version:
name: 'Check version'
runs-on: ubuntu-latest
Expand Down
59 changes: 14 additions & 45 deletions cypress/integration/connects-to-agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,72 +13,41 @@ function mockAgentEndpoints(url) {
},
{ fixture: 'agent-status.json'}
).as('agentStatus')
cy.intercept(
{
method: 'GET',
url: `${url}/connections?`,
},
{ results: []}
).as('agentConnections')
cy.intercept(
{
method: 'GET',
url: `${url}/credentials?`,
},
{ results: []}
).as('agentCredentials')
cy.intercept(
{
method: 'GET',
url: `${url}/resent-proof-2.0/records?`,
},
{ results: []}
).as('agentRecords')
}

describe('Integration tests for Holder persona', () => {
describe('Integration tests for Issuer UI', () => {
const url = env.ISSUER_ORIGIN
before(() => {
cy.clearCookies()
cy.clearLocalStorage()
cy.visit('/')
})

beforeEach(() => {
mockAgentEndpoints(url)
})
beforeEach(() => mockAgentEndpoints(url))

describe('happy path', () => {
describe('connection to an agent', () => {
beforeEach(() => {
cy.visit('http://localhost:3000')
})

it('renders DOM', () => {
cy.get('#root').should('exist')
cy.visit('/')
})

describe('if agent does not respond', () => {
it('renders a modal along with the error message', () => {
cy.intercept('GET', `${url}/status?`, { forceNetworkError: true }).as('agentStatusErr')
cy.get('[data-cy=switch-to-custom-endpoint]').click()
cy.wait('@agentStatusErr').should('have.property', 'error')
// assert for modal etc
// cy.get('[data-cy=modal-server-error]')
// .should('exist')
// .contains(networkErrorMessage)
})
})

describe('connection to agent', () => {
beforeEach(() => {
cy.get('[data-cy=switch-to-custom-endpoint]').click()
})

it('retrieves agent \'s status from \`/status?\` endpoint', () => {
cy.wait('@agentStatus').then(({ response }) => {
assert.equal(response.statusCode, 200)
})
it('renders DOM', () => {
cy.get('[data-cy=switch-to-custom-endpoint]').click()
cy.get('#root').should('exist')
})

it('retrieves agent\'s status from \'/status?\' endpoint', () => {
cy.get('[data-cy=switch-to-custom-endpoint]').click()
cy.wait('@agentStatus').then(({ response }) => {
assert.equal(response.statusCode, 200)
})
})
})
})
})
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"cypress": "^9.5.2",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
Expand Down

0 comments on commit 03c45a9

Please sign in to comment.