Skip to content

Commit

Permalink
Adding interaction tests for gantt callbacks with arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Jan 1, 2020
1 parent a162692 commit 33916cf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
38 changes: 30 additions & 8 deletions cypress/integration/other/interaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,48 @@ describe('Interaction', () => {
expect(location.href).to.eq('http://localhost:9000/webpackUsage.html');
});
});
it('should handle a click on a task with a bound function', () => {
it('should handle a click on a task with a bound function without args', () => {
const url = 'http://localhost:9000/click_security_loose.html';
cy.viewport(1440, 1024);
cy.visit(url);
cy.get('body')
.find('rect#cl2')
.click({ force: true });

cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant');
cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant cl2');
});
it('should handle a click on a task with a bound function', () => {
it('should handle a click on a task with a bound function with args', () => {
const url = 'http://localhost:9000/click_security_loose.html';
cy.viewport(1440, 1024);
cy.visit(url);
cy.get('body')
.find('rect#cl3')
.click({ force: true });

cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant test1 test2 test3');
});

it('should handle a click on a task with a bound function without args', () => {
const url = 'http://localhost:9000/click_security_loose.html';
cy.viewport(1440, 1024);
cy.visit(url);
cy.get('body')
.find('text#cl2-text')
.click({ force: true });

cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant');
cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant cl2');
});
it('should handle a click on a task with a bound function with args ', () => {
const url = 'http://localhost:9000/click_security_loose.html';
cy.viewport(1440, 1024);
cy.visit(url);
cy.get('body')
.find('text#cl3-text')
.click({ force: true });

cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant test1 test2 test3');
});

});

describe('Interaction - security level tight', () => {
Expand Down Expand Up @@ -170,7 +192,7 @@ describe('Interaction', () => {
.find('rect#cl2')
.click({ force: true });

cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant');
cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant cl2');
});
it('should handle a click on a task with a bound function', () => {
const url = 'http://localhost:9000/click_security_strict.html';
Expand All @@ -180,7 +202,7 @@ describe('Interaction', () => {
.find('text#cl2-text')
.click({ force: true });

cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant');
cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant cl2');
});
});

Expand Down Expand Up @@ -226,7 +248,7 @@ describe('Interaction', () => {
.find('rect#cl2')
.click({ force: true });

cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant');
cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant cl2');
});
it('should handle a click on a task with a bound function', () => {
const url = 'http://localhost:9000/click_security_strict.html';
Expand All @@ -236,7 +258,7 @@ describe('Interaction', () => {
.find('text#cl2-text')
.click({ force: true });

cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant');
cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant cl2');
});
});
});
9 changes: 7 additions & 2 deletions cypress/platform/click_security_loose.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
section Clickable
Visit mermaidjs :active, cl1, 2014-01-07,2014-01-10
Calling a Callback (look at the console log) :cl2, after cl1, 3d
Calling a Callback with args :cl3, after cl1, 3d

click cl1 href "http://localhost:9000/webpackUsage.html"
click cl2 call clickByGantt("test", test, test)
click cl2 call clickByGantt()
click cl3 call clickByGantt("test1", test2, test3)

section Last section
Describe gantt syntax :after doc1, 3d
Expand All @@ -69,11 +71,14 @@

document.getElementsByTagName('body')[0].appendChild(div)
}
function clickByGantt(elemName) {
function clickByGantt(arg1, arg2, arg3) {
const div = document.createElement('div')
div.className = 'created-by-gant-click'
div.style = 'padding: 20px; background: green; color: white;'
div.innerText = 'Clicked By Gant'
if (arg1) div.innerText += ' ' + arg1;
if (arg2) div.innerText += ' ' + arg2;
if (arg3) div.innerText += ' ' + arg3;

document.getElementsByTagName('body')[0].appendChild(div)
}
Expand Down
9 changes: 7 additions & 2 deletions cypress/platform/click_security_strict.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
section Clickable
Visit mermaidjs :active, cl1, 2014-01-07,2014-01-10
Calling a Callback (look at the console log) :cl2, after cl1, 3d
Calling a Callback with args :cl3, after cl1, 3d

click cl1 href "http://localhost:9000/webpackUsage.html"
click cl2 call clickByGantt("test", test, test)
click cl2 call clickByGantt()
click cl3 call clickByGantt("test1", test2, test3)

section Last section
Describe gantt syntax :after doc1, 3d
Expand All @@ -69,11 +71,14 @@

document.getElementsByTagName('body')[0].appendChild(div)
}
function clickByGantt(elemName) {
function clickByGantt(arg1, arg2, arg3) {
const div = document.createElement('div')
div.className = 'created-by-gant-click'
div.style = 'padding: 20px; background: green; color: white;'
div.innerText = 'Clicked By Gant'
if (arg1) div.innerText += ' ' + arg1;
if (arg2) div.innerText += ' ' + arg2;
if (arg3) div.innerText += ' ' + arg3;

document.getElementsByTagName('body')[0].appendChild(div)
}
Expand Down

0 comments on commit 33916cf

Please sign in to comment.