-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move e2e tests and add db truncating before each test
- Loading branch information
Gunnar Busch
committed
Feb 19, 2021
1 parent
843e90d
commit 93b9d16
Showing
18 changed files
with
2,509 additions
and
111 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
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,8 @@ | ||
{ | ||
"plugins": [ | ||
"cypress" | ||
], | ||
"extends": [ | ||
"plugin:cypress/recommended" | ||
] | ||
} |
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,11 @@ | ||
{ | ||
"baseUrl": "http://localhost:9000", | ||
"fixturesFolder": false, | ||
"db": { | ||
"user": "smui", | ||
"host": "localhost", | ||
"database": "smui", | ||
"password": "smui", | ||
"port": 5432 | ||
} | ||
} |
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,35 @@ | ||
import { truncateTable } from '../src/sql'; | ||
|
||
context('SMUI app', () => { | ||
beforeEach(() => { | ||
truncateTable('search_input'); | ||
cy.visit('/'); | ||
}); | ||
|
||
it('should have a page headline', () => { | ||
cy.get('.navbar-brand').should('have.text', 'SMUI demo installation'); | ||
}); | ||
|
||
it('should create a new rule item and sort it in rules list', () => { | ||
cy.get('[data-test=rules-search-input]').type('testRuleB{enter}'); | ||
cy.get('.list-item-term').should(terms => { | ||
expect(terms).to.have.length(1); | ||
expect(terms.eq(0).text()).to.contain('testRuleB'); | ||
}); | ||
|
||
cy.get('[data-test=rules-search-input]').type('testRuleC{enter}'); | ||
cy.get('.list-item-term').should(terms => { | ||
expect(terms).to.have.length(2); | ||
expect(terms.eq(0).text()).to.contain('testRuleB'); | ||
expect(terms.eq(1).text()).to.contain('testRuleC'); | ||
}); | ||
|
||
cy.get('[data-test=rules-search-input]').type('testRuleA{enter}'); | ||
cy.get('.list-item-term').should(terms => { | ||
expect(terms).to.have.length(3); | ||
expect(terms.eq(0).text()).to.contain('testRuleA'); | ||
expect(terms.eq(1).text()).to.contain('testRuleB'); | ||
expect(terms.eq(2).text()).to.contain('testRuleC'); | ||
}); | ||
}); | ||
}); |
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 @@ | ||
const pg = require('pg'); | ||
const cypressConfig = require("../../cypress.json"); | ||
|
||
module.exports = (on, _) => { | ||
on('task', { | ||
query({ sql, values }) { | ||
const pool = new pg.Pool(cypressConfig.db); | ||
try { | ||
return pool.query(sql, values); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
}); | ||
}; |
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,7 @@ | ||
const truncateTable = tableName => { | ||
cy.task('query', { | ||
sql: `truncate table ${tableName}` | ||
}); | ||
}; | ||
|
||
export { truncateTable }; |
Empty file.
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,17 @@ | ||
{ | ||
"name": "smui-integration-tests", | ||
"description": "SMUI Integration Tests", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"pg": "^8.5.1" | ||
}, | ||
"devDependencies": { | ||
"@cypress/eslint-plugin-dev": "^5.0.2", | ||
"cypress": "^6.4.0", | ||
"cypress-wait-until": "^1.7.1", | ||
"eslint": "6.0.1", | ||
"eslint-plugin-cypress": "^2.11.2", | ||
"eslint-plugin-json-format": "2.0.1", | ||
"eslint-plugin-mocha": "5.0.0" | ||
} | ||
} |
Oops, something went wrong.