From e047383fe46115bccb064430ae844a0604b7db40 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Thu, 2 Feb 2023 13:16:26 +0000 Subject: [PATCH] Added first cypress e2e tests --- cypress-tests/Dockerfile | 4 ++++ cypress-tests/cypress.config.js | 13 ++++++++++++ cypress-tests/run-cypress-tests.sh | 13 ++++++++++++ cypress-tests/tests/01-login_spec.cy.js | 27 +++++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 cypress-tests/Dockerfile create mode 100644 cypress-tests/cypress.config.js create mode 100644 cypress-tests/run-cypress-tests.sh create mode 100644 cypress-tests/tests/01-login_spec.cy.js diff --git a/cypress-tests/Dockerfile b/cypress-tests/Dockerfile new file mode 100644 index 0000000..886c924 --- /dev/null +++ b/cypress-tests/Dockerfile @@ -0,0 +1,4 @@ +FROM cypress/included:12.4.0 + +COPY cypress.config.js / +COPY ./tests/* /cypress/e2e/ \ No newline at end of file diff --git a/cypress-tests/cypress.config.js b/cypress-tests/cypress.config.js new file mode 100644 index 0000000..e07d671 --- /dev/null +++ b/cypress-tests/cypress.config.js @@ -0,0 +1,13 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + e2e: { + baseUrl: 'http://wrestlingdev-test.wimer.house', + supportFile: false, + video: false, + }, + env: { + CYPRESS_PASSWORD: 'password', + CYPRESS_USERNAME: 'test@test.com', + }, +}) \ No newline at end of file diff --git a/cypress-tests/run-cypress-tests.sh b/cypress-tests/run-cypress-tests.sh new file mode 100644 index 0000000..8e86f74 --- /dev/null +++ b/cypress-tests/run-cypress-tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +#!/bin/bash +project_dir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.." + +cd ${project_dir}/cypress-tests + +# include ruby, mysql, memcached, and cypress in dockerfile to emulate prod? +# then cypress points to localhost within the docker + +docker build -t wrestlingdev-cypress . + +docker run -it --rm wrestlingdev-cypress \ No newline at end of file diff --git a/cypress-tests/tests/01-login_spec.cy.js b/cypress-tests/tests/01-login_spec.cy.js new file mode 100644 index 0000000..9a3efa2 --- /dev/null +++ b/cypress-tests/tests/01-login_spec.cy.js @@ -0,0 +1,27 @@ +describe('Testing Log In', () => { + it('Gets Log In Page and Logs In', () => { + cy.visit('/') + + cy.contains('Log In').click() + + // Should be on a new URL which + // includes '/commands/actions' + cy.url().should('include', '/users/sign_in') + + // Get an input, type into it + cy.get('[id=user_email]').type(Cypress.env('CYPRESS_USERNAME')) + + // Verify that the value has been updated + cy.get('[id=user_email]').should('have.value', Cypress.env('CYPRESS_USERNAME')) + + // Get an input, type into it + cy.get('[id=user_password]').type(Cypress.env('CYPRESS_PASSWORD')) + + // Verify that the value has been updated + cy.get('[id=user_password]').should('have.value', Cypress.env('CYPRESS_PASSWORD')) + + cy.get('input[type=submit]').click() + + cy.contains('Signed in successfully') + }) +}) \ No newline at end of file