-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf6a09c
commit 7d601cb
Showing
17 changed files
with
265 additions
and
70 deletions.
There are no files selected for viewing
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,43 @@ | ||
version: '2' | ||
services: | ||
server: | ||
build: ../ | ||
command: dev_server | ||
depends_on: | ||
- postgres | ||
- redis | ||
ports: | ||
- "5000:5000" | ||
environment: | ||
PYTHONUNBUFFERED: 0 | ||
REDASH_LOG_LEVEL: "INFO" | ||
REDASH_REDIS_URL: "redis://redis:6379/0" | ||
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres" | ||
worker: | ||
build: ../ | ||
command: scheduler | ||
depends_on: | ||
- server | ||
environment: | ||
PYTHONUNBUFFERED: 0 | ||
REDASH_LOG_LEVEL: "INFO" | ||
REDASH_REDIS_URL: "redis://redis:6379/0" | ||
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres" | ||
QUEUES: "queries,scheduled_queries,celery" | ||
WORKERS_COUNT: 2 | ||
cypress: | ||
build: | ||
context: ../ | ||
dockerfile: Dockerfile.cypress | ||
depends_on: | ||
- server | ||
- worker | ||
environment: | ||
CYPRESS_baseUrl: "http://server:5000" | ||
redis: | ||
image: redis:3.0-alpine | ||
restart: unless-stopped | ||
postgres: | ||
image: postgres:9.5.6-alpine | ||
command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF" | ||
restart: unless-stopped |
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 |
---|---|---|
|
@@ -24,3 +24,5 @@ node_modules | |
.sass-cache | ||
npm-debug.log | ||
|
||
cypress/screenshots | ||
cypress/videos |
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,10 @@ | ||
FROM cypress/browsers:chrome67 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN npm install cypress > /dev/null | ||
|
||
COPY cypress /usr/src/app/cypress | ||
COPY cypress.json /usr/src/app/cypress.json | ||
|
||
RUN ./node_modules/.bin/cypress verify |
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
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,3 @@ | ||
{ | ||
"baseUrl": "http://localhost:5000" | ||
} |
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,52 @@ | ||
/* eslint-disable import/no-extraneous-dependencies, no-console */ | ||
const { execSync } = require('child_process'); | ||
const { post } = require('request'); | ||
|
||
function execSetup() { | ||
console.log('Running setup...'); | ||
|
||
const setupData = { | ||
name: 'Example Admin', | ||
email: 'admin@redash.io', | ||
password: 'password', | ||
org_name: 'Redash', | ||
}; | ||
|
||
const baseUrl = process.env.CYPRESS_baseUrl || 'http://localhost:5000'; | ||
|
||
post(baseUrl + '/setup', { formData: setupData }); | ||
} | ||
|
||
function startServer() { | ||
console.log('Starting the server...'); | ||
|
||
execSync('docker-compose -p cypress build --build-arg skip_ds_deps=true', { stdio: 'inherit' }); | ||
execSync('docker-compose -p cypress up -d', { stdio: 'inherit' }); | ||
execSync('docker-compose -p cypress run server create_db', { stdio: 'inherit' }); | ||
} | ||
|
||
function stopServer() { | ||
console.log('Stopping the server...'); | ||
execSync('docker-compose -p cypress down', { stdio: 'inherit' }); | ||
} | ||
|
||
const command = process.argv[2]; | ||
|
||
switch (command) { | ||
case 'start': | ||
startServer(); | ||
execSetup(); | ||
break; | ||
case 'start-ci': | ||
startServer(); | ||
break; | ||
case 'setup': | ||
execSetup(); | ||
break; | ||
case 'stop': | ||
stopServer(); | ||
break; | ||
default: | ||
console.log('Usage: npm run cypress:server start|stop'); | ||
break; | ||
} |
19 changes: 19 additions & 0 deletions
19
cypress/integration/data-source/create_data_source_spec.js
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,19 @@ | ||
describe('Create Data Source', () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
cy.visit('/data_sources'); | ||
}); | ||
|
||
it('creates a new PostgreSQL data source', () => { | ||
cy.contains('New Data Source').click(); | ||
cy.contains('PostgreSQL').click(); | ||
|
||
cy.get('[name=targetName]').type('Redash'); | ||
cy.get('[data-cy=Host]').type('{selectall}localhost'); | ||
cy.get('[data-cy=User]').type('postgres'); | ||
cy.get('[data-cy=Password]').type('postgres'); | ||
cy.get('[data-cy="Database Name"]').type('postgres{enter}'); | ||
|
||
cy.contains('Saved.'); | ||
}); | ||
}); |
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,24 @@ | ||
describe('Login', () => { | ||
beforeEach(() => { | ||
cy.visit('/login'); | ||
}); | ||
|
||
it('greets the user', () => { | ||
cy.contains('h3', 'Login to Redash'); | ||
}); | ||
|
||
it('shows message on failed login', () => { | ||
cy.get('#inputEmail').type('admin@redash.io'); | ||
cy.get('#inputPassword').type('wrongpassword{enter}'); | ||
|
||
cy.get('.alert').should('contain', 'Wrong email or password.'); | ||
}); | ||
|
||
it('navigates to homepage with successful login', () => { | ||
cy.get('#inputEmail').type('admin@redash.io'); | ||
cy.get('#inputPassword').type('password{enter}'); | ||
|
||
cy.title().should('eq', 'Redash'); | ||
cy.contains('Example Admin'); | ||
}); | ||
}); |
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,13 @@ | ||
describe('Logout', () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
cy.visit('/'); | ||
}); | ||
|
||
it('shows login page after logout', () => { | ||
cy.get('[data-cy=dropdown-profile]').click(); | ||
cy.contains('Log out').click(); | ||
|
||
cy.title().should('eq', 'Login to Redash'); | ||
}); | ||
}); |
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 @@ | ||
module.exports = () => {}; |
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,15 @@ | ||
Cypress.Commands.add('login', () => { | ||
const users = { | ||
admin: { | ||
email: 'admin@redash.io', | ||
password: 'password', | ||
}, | ||
}; | ||
|
||
cy.request({ | ||
url: '/login', | ||
method: 'POST', | ||
form: true, | ||
body: users.admin, | ||
}); | ||
}); |
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 @@ | ||
import './commands'; |
Oops, something went wrong.