Skip to content

Commit

Permalink
Cypress tests if widgets are draggable to canvas (ToolJet#626)
Browse files Browse the repository at this point in the history
* Cypress tests to test if widgets are draggable

1. Added tests for all widgets to test if user is able to drag and drop them to canvas.
2. Re-organised Integration test folder according to the Pages.

* Updated package-lock.json file

Updated NPM to 7.20.0 and created this file again.

* Last update- package-lock.json

31 Sep-
Steps followed:
$ rm -rf node_modules/
$ npm cache clean --force
(Revert the changes in your package-lock.json file)
step 3 -> copy and paste the file from develop branch
$ npm i
still generating 21552 lines.
  • Loading branch information
Mohini Dahiya authored Sep 2, 2021
1 parent 274b648 commit 5533527
Show file tree
Hide file tree
Showing 26 changed files with 2,577 additions and 32 deletions.
30 changes: 23 additions & 7 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,27 @@
},
"testFiles": [
"auth.spec.js",
"empty-state-dashboard.spec.js",
"dashboard.spec.js",
"apps-page-operations.spec.js",
"editor-navigation-bar.spec.js",
"editor-datasource-postgres.spec.js"
]

"dashboard/empty-state-dashboard.spec.js",
"dashobard/dashboard.spec.js",
"dashboard/apps-page-operations.spec.js",
"editor/editor-navigation-bar.spec.js",
"editor/editor-datasource-postgres.spec.js",
"editor/widgets/editor-widget-checkbox.spec.js",
"editor/widgets/editor-widget-table.spec.js",
"editor/widgets/editor-widget-button.spec.js",
"editor/widgets/editor-widget-chart.spec.js",
"editor/widgets/editor-widget-modal.spec.js",
"editor/widgets/editor-widget-text-input.spec.js",
"editor/widgets/editor-widget-date-picker.spec.js",
"editor/widgets/editor-widget-toggle-switch.spec.js",
"editor/widgets/editor-widget-text-area.spec.js",
"editor/widgets/editor-widget-text.spec.js",
"editor/widgets/editor-widget-text-editor.spec.js",
"editor/widgets/editor-widget-image.spec.js",
"editor/widgets/editor-widget-container.spec.js",
"editor/widgets/editor-widget-dropdown.spec.js",
"editor/widgets/editor-widget-multiselect.spec.js",
"editor/widgets/editor-widget-map.spec.js",
"editor/widgets/editor-widget-qr-scanner.spec.js"
]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ describe('Empty state of dashboard', () => {
})

it('should show empty screen when there are no apps', () => {

cy.wait(1000)
cy.get('body').then(($title=>
{
Expand Down
31 changes: 31 additions & 0 deletions cypress/integration/editor/widgets/editor-widget-button.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test Button widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop button to canvas', () => {
cy.get('input[placeholder="Search…"]').type('button')

cy.get('.draggable-box')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});
})
31 changes: 31 additions & 0 deletions cypress/integration/editor/widgets/editor-widget-chart.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test chart widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop chart to canvas', () => {
cy.get('input[placeholder="Search…"]').type('chart')

cy.get('.draggable-box')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});
})
40 changes: 40 additions & 0 deletions cypress/integration/editor/widgets/editor-widget-checkbox.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test checkbox widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should drag and drop checkbox to canvas', () => {
cy.get('input[placeholder="Search…"]').type('checkbox')

cy.get('.draggable-box')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});

it('should be able to set checkbox value to true', () => {
cy.get('input[placeholder="Search…"]').type('checkbox')

cy.get('.draggable-box')
.drag('.real-canvas',{force: true, position: 'topLeft' })

cy.get('.form-check-label').click()
});
})
31 changes: 31 additions & 0 deletions cypress/integration/editor/widgets/editor-widget-container.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test Container widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop image to canvas', () => {
cy.get('input[placeholder="Search…"]').type('Container')

cy.get('.draggable-box').eq(0).should('have.text','Container')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test Button widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop data-picker to canvas', () => {
cy.get('input[placeholder="Search…"]').type('date picker')

cy.get('.draggable-box').eq(0).should('have.text','Date Picker')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});
})
31 changes: 31 additions & 0 deletions cypress/integration/editor/widgets/editor-widget-dropdown.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test dropdown widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop dropdown to canvas', () => {
cy.get('input[placeholder="Search…"]').type('dropdown')

cy.get('.draggable-box').eq(0).should('have.text','Dropdown')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});
})
31 changes: 31 additions & 0 deletions cypress/integration/editor/widgets/editor-widget-image.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test Image widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop image to canvas', () => {
cy.get('input[placeholder="Search…"]').type('image')

cy.get('.draggable-box').eq(0).should('have.text','Image')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});
})
31 changes: 31 additions & 0 deletions cypress/integration/editor/widgets/editor-widget-map.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test map widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop map to canvas', () => {
cy.get('input[placeholder="Search…"]').type('map')

cy.get('.draggable-box').eq(0).should('have.text','Map')
.drag('.real-canvas',{force: true, position: 'topLeft'})
});
})
31 changes: 31 additions & 0 deletions cypress/integration/editor/widgets/editor-widget-modal.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test Modal widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop Modal to canvas', () => {
cy.get('input[placeholder="Search…"]').type('modal')

cy.get('.draggable-box')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '@4tw/cypress-drag-drop';
describe('Editor- Test multiselect widget', () => {

beforeEach(() => {

cy.viewport(1536, 960);
//read login data from fixtures
cy.fixture('login-data').then(function (testdata) {
cy.login(testdata.email, testdata.password)
})
cy.wait(1000)
cy.get('body').then(($title => {
//check you are not running tests on empty dashboard state
if ($title.text().includes('You haven\'t created any apps yet.')) {
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
.click()
cy.go('back')
}
cy.wait(2000)
cy.get('.badge').contains('Edit').click()
cy.get('title').should('have.text', 'ToolJet - Dashboard')
}))
})

it('should be able to drag and drop multiselect to canvas', () => {
cy.get('input[placeholder="Search…"]').type('multiselect')

cy.get('.draggable-box').eq(0).should('have.text','Multiselect')
.drag('.real-canvas',{force: true, position: 'topLeft' })
});
})
Loading

0 comments on commit 5533527

Please sign in to comment.