Skip to content

Commit

Permalink
cypress testing - makefile - sass - dep
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Aug 17, 2018
1 parent 52684c5 commit 65998c5
Show file tree
Hide file tree
Showing 33 changed files with 2,329 additions and 171 deletions.
31 changes: 31 additions & 0 deletions .dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM golang:1.10.3-alpine
LABEL maintainer "Hunter Long (https://github.com/hunterlong)"

# Statup 'test' image for running a full test using the production environment
ENV VERSION=$(VERSION)

RUN apk add --no-cache libstdc++ gcc g++ make git ca-certificates linux-headers wget

RUN wget -q https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && \
chmod +x dep-linux-amd64 && \
mv dep-linux-amd64 /usr/local/bin/dep

WORKDIR $GOPATH/src/github.com/hunterlong/statup

COPY . .

RUN wget -q https://assets.statup.io/sass && \
chmod +x sass && \
mv sass /usr/local/bin/sass

RUN dep ensure && \
go get github.com/GeertJohan/go.rice/rice

RUN cd cmd && go build -ldflags "-X main.VERSION=$VERSION" && mv cmd /usr/local/bin/statup

ENV IS_DOCKER=true

WORKDIR /app
ADD ./Makefile .
EXPOSE 8080
ENTRYPOINT statup
12 changes: 12 additions & 0 deletions .dev/test/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"projectId": "bi8mhr",
"env": {
"DB_HOST": "localhost",
"DB_USER": "root",
"DB_DATABASE": "root",
"DB_PORT": "5432",
"DB_PASS": "password123",
"GO_ENV": "production"
},
"chromeWebSecurity": false
}
5 changes: 5 additions & 0 deletions .dev/test/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
48 changes: 48 additions & 0 deletions .dev/test/cypress/integration/0_setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
context('Setup Process', () => {

// it('should go to setup Statup with Postgres', () => {
// cy.visit('http://localhost:8080')
// cy.get('select[name=db_connection]').select('postgres')
// cy.get('input[name="db_host"]').clear().type(Cypress.env('DB_HOST'))
// cy.get('input[name="db_port"]').clear().type('5432')
// cy.get('input[name="db_user"]').clear().type(Cypress.env('DB_USER'))
// if (Cypress.env('TRAVIS')==="yes") {
// cy.get('input[name="db_password"]').clear()
// } else {
// cy.get('input[name="db_password"]').clear().type(Cypress.env('DB_PASS'))
// }
// cy.get('input[name="db_database"]').clear().type(Cypress.env('DB_DATABASE'))
// cy.get('input[name="project"]').clear().type('Demo Tester')
// cy.get('input[name="description"]').clear().type('This is a test from Crypress!')
// cy.get('input[name="domain"]').clear().type('http://localhost:8080')
// cy.get('input[name="username"]').clear().type('admin')
// cy.get('input[name="email"]').clear().type('[email protected]')
// cy.get('input[name="password"]').clear().type('admin')
// cy.scrollTo('bottom')
// cy.get('#setup_button').click().wait(10000)
// cy.get('.header-title').should('contain', 'Demo Tester')
// cy.get('.header-desc').should('contain', 'This is a test from Crypress!')
// cy.scrollTo('bottom')
// cy.get('.service_li').should('have.length', 5)
// cy.get('.card').should('have.length', 5)
// })

it('should go to setup Statup with SQLite', () => {
cy.visit('http://localhost:8080')
cy.get('select[name=db_connection]').select('sqlite')
cy.get('input[name="project"]').clear().type('Demo Tester')
cy.get('input[name="description"]').clear().type('This is a test from Crypress!')
cy.get('input[name="domain"]').clear().type('http://localhost:8080')
cy.get('input[name="username"]').clear().type('admin')
cy.get('input[name="email"]').clear().type('[email protected]')
cy.get('input[name="password"]').clear().type('admin')
cy.scrollTo('bottom')
cy.get('#setup_button').click().wait(10000)
cy.get('.header-title').should('contain', 'Demo Tester')
cy.get('.header-desc').should('contain', 'This is a test from Crypress!')
cy.scrollTo('bottom')
cy.get('.service_li').should('have.length', 5)
cy.get('.card').should('have.length', 5)
})

})
39 changes: 39 additions & 0 deletions .dev/test/cypress/integration/assets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
context('Asset Tests', () => {

beforeEach(function () {
cy.visit('http://localhost:8080/dashboard')
cy.get('input[name="username"]').type('admin')
cy.get('input[name="password"]').type('admin')
cy.get('form').submit()
})

it('should create local assets', () => {
cy.visit('http://localhost:8080/settings/build')
cy.get('#v-pills-style-tab').click()
cy.wait(500)
cy.get(':nth-child(2) > .CodeMirror-line').should('contain', '$background-color')
})

it('should save assets form', () => {
cy.request({method: 'POST', url: 'http://localhost:8080/settings/css', form: true, body: {
variables: '$tester: #bababa',
theme: '@import \'variables\'; .test-var { color: $tester; }'
}})
})

it('should check css file', () => {
cy.request('http://localhost:8080/css/base.css').its('body').should('contain', '.test-var')
})

it('should delete assets', () => {
cy.visit('http://localhost:8080/settings')
cy.get('#v-pills-style-tab').click()
cy.wait(500)
cy.get('.btn-danger').click()
})

it('should check css file after delete', () => {
cy.request('http://localhost:8080/css/base.css').its('body').should('contain', 'BODY')
})

});
24 changes: 24 additions & 0 deletions .dev/test/cypress/integration/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
context('Dashboard Tests', () => {

beforeEach(function() {
cy.visit('http://localhost:8080/dashboard')
cy.get('input[name="username"]').type('admin')
cy.get('input[name="password"]').type('admin')
cy.get('form').submit()
})

it('should view logs', () => {
cy.visit('http://localhost:8080/settings')
cy.get(':nth-child(5) > .nav-link').click()
cy.wait(10000)
cy.get('#live_logs').should('contain', 'Service')
})

it('should view help', () => {
cy.visit('http://localhost:8080/settings')
cy.get(':nth-child(6) > .nav-link').click()
cy.title().should('eq', 'Statup | Help')
cy.get('.col-12 > :nth-child(1)').should('contain', 'Statup')
})

});
34 changes: 34 additions & 0 deletions .dev/test/cypress/integration/services.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
context('Service Tests', () => {

beforeEach(function () {
cy.visit('http://localhost:8080/dashboard')
cy.get('input[name="username"]').type('admin')
cy.get('input[name="password"]').type('admin')
cy.get('form').submit()
})

it('should view services', () => {
cy.visit('http://localhost:8080/services')
cy.get('tr').should('have.length', 6)
cy.title().should('eq', 'Statup | Services')
})

it('should create services', () => {
cy.visit('http://localhost:8080/services')
cy.get('input[name="name"]').type('Google.com')
cy.get('input[name="domain"]').type('https://google.com')
cy.get('input[name="interval"]').type('30')
cy.get('form').submit()
cy.title().should('eq', 'Statup | Services')
cy.get('tr').should('have.length', 7)
})

it('should delete a service', () => {
cy.visit('http://localhost:8080/services')
cy.get(':nth-child(5) > .text-right > .btn-group > .btn-danger').click()
cy.title().should('eq', 'Statup | Services')
cy.get('tr').should('have.length', 6)
})


});
25 changes: 25 additions & 0 deletions .dev/test/cypress/integration/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
context('Settings Forms', () => {

beforeEach(function() {
cy.visit('http://localhost:8080/dashboard')
cy.get('input[name="username"]').type('admin')
cy.get('input[name="password"]').type('admin')
cy.get('form').submit()
})

it('should edit main settings', () => {
cy.visit('http://localhost:8080/settings')
cy.get('input[name="project"]').clear().type('Project Updated')
cy.get('input[name="description"]').clear().type('This is an awesome page')
cy.get('input[name="domain"]').clear().type('http://0.0.0.0:8080')
cy.get('textarea[name="footer"]').clear().type('This is a custom footer')
cy.get('#v-pills-home > form').submit()
cy.title().should('eq', 'Statup | Settings')
cy.get('input[name="project"]').should('have.value', 'Project Updated')
cy.get('input[name="description"]').should('have.value', 'This is an awesome page')
cy.get('input[name="domain"]').should('have.value', 'http://0.0.0.0:8080')
cy.get('.footer').should('contain', 'This is a custom footer')
})


});
32 changes: 32 additions & 0 deletions .dev/test/cypress/integration/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
context('User Testing', () => {

beforeEach(function () {
cy.visit('http://localhost:8080/dashboard')
cy.get('input[name="username"]').type('admin')
cy.get('input[name="password"]').type('admin')
cy.get('form').submit()
})

it('should view users', () => {
cy.visit('http://localhost:8080/users')
cy.get('tr').should('have.length', 2)
cy.title().should('eq', 'Statup | Users')
})

it('should create a new user', () => {
cy.visit('http://localhost:8080/users')
cy.get('input[name="username"]').type('hunterlong')
cy.get('input[name="email"]').type('[email protected]')
cy.get('input[name="password"]').type('admin')
cy.get('input[name="password_confirm"]').type('admin')
cy.get('form').submit()
cy.get('tr').should('have.length', 3)
})

it('should delete a user', () => {
cy.visit('http://localhost:8080/users')
cy.get('#user_2 > .btn-group > .btn-danger').click()
cy.get('tr').should('have.length', 2)
})

});
17 changes: 17 additions & 0 deletions .dev/test/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions .dev/test/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions .dev/test/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Binary file added .dev/test/cypress/videos/0_setup.js.mp4
Binary file not shown.
Binary file added .dev/test/cypress/videos/assets.js.mp4
Binary file not shown.
Binary file added .dev/test/cypress/videos/dashboard.js.mp4
Binary file not shown.
Binary file added .dev/test/cypress/videos/settings.js.mp4
Binary file not shown.
Loading

0 comments on commit 65998c5

Please sign in to comment.