Skip to content

Commit

Permalink
add basic e2e cypress test support
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarprudnikov committed Apr 15, 2024
1 parent ddc7af6 commit 3edf412
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
CYPRESS_CRASH_REPORTS: 0
CYPRESS_COMMERCIAL_RECOMMENDATIONS: 0
steps:
- uses: actions/checkout@v3
- name: Set up Go
Expand All @@ -12,3 +15,9 @@ jobs:
- run: go version
- run: go build -v ./...
- run: go test -v ./...
- name: Cypress run
uses: cypress-io/github-action@v6
with:
working-directory: examples/start
start: SERVER_ENV=test go run .
wait-on: 'http://localhost:3000'
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ sequenceDiagram
- Run the server in an Azure function environment locally: `./scripts/run.sh`
- Compile and deploy to Azure: `./scripts/azure.fn.deploy.sh`
- Create required Azure infrastructure: `./scripts/azure.infra.create.sh`
- Run functional e2e tests:
- first, start the local server `SERVER_ENV=test go run .`
- then run cypress through `npx cypress open` (you'll need node installed)

## Architecture

Expand Down
7 changes: 7 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
fixturesFolder: false,
e2e: {
supportFile: false,
baseUrl: 'http://localhost:8080',
},
}
15 changes: 15 additions & 0 deletions cypress/e2e/auth.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('template spec', () => {
it('creates account', () => {
cy.visit('/accounts/new')
cy.contains('Craete your account').should('be.visible')

const random = Math.random().toString().substr(2, 9)

cy.get('#username').type('joe-'+random)
cy.get('#password').type('pass')
cy.get('#password2').type('pass')
cy.get('.btn-primary').click()

cy.contains('Account created').should('be.visible')
})
})
4 changes: 4 additions & 0 deletions cypress/e2e/homepage.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
it('loads the homepage', () => {
cy.visit('/')
cy.contains('create self destructing secret messages').should('be.visible')
})
2 changes: 1 addition & 1 deletion web/account.created.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="container">
{{template "nav.tmpl" .}}

<h1>Account ceated</h1>
<h1>Account created</h1>
<p>Your username: {{ .data.Username }}</p>
<p>Created at: {{ .data.Created }}</p>

Expand Down

0 comments on commit 3edf412

Please sign in to comment.