Skip to content

Commit

Permalink
#359 progress, done until 'Can highlight by seleting or searching'
Browse files Browse the repository at this point in the history
  • Loading branch information
canbax committed Jun 3, 2021
1 parent 2b71510 commit 24a7ca1
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 9 deletions.
1 change: 1 addition & 0 deletions cypress/downloads/Visuall_User_Profile.vall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
1 change: 1 addition & 0 deletions cypress/downloads/visuall.json

Large diffs are not rendered by default.

Binary file added cypress/downloads/visuall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions cypress/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export function navbarAction(dropdownBtn, actionBtn) {
cy.get('button.btn.btn-light.dropdown-toggle').contains(dropdownBtn).click();
cy.get('button.dropdown-item').contains(actionBtn).click();

cy.wait(3000);

if (dropdownBtn == 'Data' && actionBtn == 'Sample Data') {
cy.wait(3000);
cy.window().then((win) => {
expect(win.cy.nodes().length > 0).to.eq(true);
});
Expand Down Expand Up @@ -45,4 +44,21 @@ export function openTab(s) {
export function click2options() {
cy.get('span.va-heading3').contains('Options').click();
cy.wait(250);
}

/**
* @param {string} algoName
* @param {boolean} shouldResultCompounds
*/
export function groupBy(algoName, shouldResultCompounds) {
cy.get('label').contains(algoName).click();
cy.get('input[value="Execute"]:visible').click();

cy.window().then((win) => {
if (shouldResultCompounds) {
expect(win.cy.$(':parent').length > 0).to.eq(true);
} else {
expect(win.cy.$(':parent').length == 0).to.eq(true);
}
});
}
2 changes: 1 addition & 1 deletion cypress/integration/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ context('Global properties about Visuall', () => {
cy.get('div#prop-tab.collapse.show').should('be.visible');
});

it('TC2: Can show object properties by selecting', () => {
it('TC2: Should maintain settings when "Store user profile" is checked (true by default)', () => {
cy.get('a.nav-link').contains('Settings').click();
cy.get('label').contains('Emphasize on hover').siblings('input[type="checkbox"]').first().should('not.to.be.checked');
cy.get('label').contains('Emphasize on hover').siblings('input[type="checkbox"]').first().check();
Expand Down
9 changes: 4 additions & 5 deletions cypress/integration/filterByType.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { open, navbarAction, openSubTab } from '../helper';
import { open, navbarAction } from '../helper';

context('Global properties about Visuall', () => {
context('Filter By Node/Edge Type', () => {

beforeEach(open);

Expand All @@ -11,7 +11,7 @@ context('Global properties about Visuall', () => {
cy.window().then((win) => {
expect(win.cy.$('node:visible').filter('.Person').length == 0).to.eq(true);
});

// show 'Person' node type
cy.get('a.filter-node-class').contains('Person').click();
cy.window().then((win) => {
Expand All @@ -30,6 +30,5 @@ context('Global properties about Visuall', () => {
expect(win.cy.$('edge:visible').filter('.ACTOR').length > 0).to.eq(true);
});
});



});
2 changes: 1 addition & 1 deletion cypress/integration/graphTheoreticProperty.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { open, navbarAction, openSubTab } from '../helper';

context('Global properties about Visuall', () => {
context('Calculate Theoretic Property', () => {

beforeEach(open);

Expand Down
17 changes: 17 additions & 0 deletions cypress/integration/groupNodes.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { open, navbarAction, openSubTab, groupBy } from '../helper';

context('Group Nodes', () => {

beforeEach(open);

it('TC1: Can group with Louvain using compounds', () => {
navbarAction('Data', 'Sample Data');
openSubTab('Group Nodes');

groupBy('By the Louvain modularity algorithm', true);
groupBy('None', false);
groupBy('By the Markov clustering algorithm', true);
groupBy('None', false);
});

});
215 changes: 215 additions & 0 deletions cypress/integration/navbar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import { open, navbarAction, openSubTab, openTab, groupBy } from '../helper';

context('Navbar buttons', () => {

beforeEach(open);

/**
* @param {boolean} isSaveSettings
* @param {boolean} isSaveFilteringRules
* @param {boolean} isSaveTimebarMetrics
*/
function click2saveUserProfile(isSaveSettings, isSaveFilteringRules, isSaveTimebarMetrics) {
if (!isSaveSettings) {
cy.get('#save-profile-cb0').click();
}
if (!isSaveFilteringRules) {
cy.get('#save-profile-cb1').click();
}
if (!isSaveTimebarMetrics) {
cy.get('#save-profile-cb2').click();
}
cy.get('button.btn.btn-primary.va-text').contains('OK').click();
}

it('TC1: should have at least 7 buttons on navbar', () => {
cy.get('button.dropdown-toggle').its('length').should('eq', 7);
});

it('TC2: Can save as JSON and PNG', () => {
navbarAction('Data', 'Sample Data');
navbarAction('File', 'Save');

cy.window().then((win) => {
win.cy.$().select();
navbarAction('File', 'Save Selected Objects');

navbarAction('File', 'Save as PNG...');
cy.get('button#save-png-btn1').click();
navbarAction('File', 'Save as PNG...');
win.cy.zoom(3);
cy.get('button#save-png-btn2').click();
});
});

it('TC3: Can save user profile', () => {
for (let i = 0; i < 2; i++) {
for (let j = 0; j < 2; j++) {
for (let k = 0; k < 2; k++) {
navbarAction('File', 'Save User Profile...');
click2saveUserProfile(i == 0, j == 0, k == 0);
}
}
}
});

it('TC4: Can add/remove group manually, delete selected, use history to go back and forth', () => {
navbarAction('Data', 'Sample Data');

cy.window().then((win) => {
win.cy.$().select();
});

navbarAction('Edit', 'Add Group for Selected');
cy.window().then((win) => {
expect(win.cy.$(':parent').length).to.eq(1);
win.cy.$().unselect();
win.cy.$(':parent').select();
});
navbarAction('Edit', 'Remove Group for Selected');
cy.window().then((win) => {
expect(win.cy.$(':parent').length).to.eq(0);
});
openTab('Map');
openSubTab('Group Nodes');
groupBy('By the Louvain modularity algorithm', true);
cy.window().then((win) => {
expect(win.cy.$(':parent').length > 2).to.eq(true);
});
navbarAction('Edit', 'Remove All Groups');

cy.window().then((win) => {
expect(win.cy.$(':parent').length == 0).to.eq(true);
});

// delete selected
let cntBefore = -1;
cy.window().then((win) => {
cntBefore = win.cy.$().length;
win.cy.$().slice(0, 10).select();
});
navbarAction('Edit', 'Delete Selected');
cy.window().then((win) => {
const cntAfter = win.cy.$().length;
expect(cntAfter <= cntBefore + 10).to.eq(true);
});
});

it('TC5: Use history to go back and forth', () => {
navbarAction('Data', 'Sample Data');
let cnt0 = 0;
openSubTab('Query by Rule');
cy.window().then((win) => {
cnt0 = win.cy.$().length;
});
cy.get('img[alt="Add Rule"]:visible').click();
cy.get('button').contains('Condition').click();
cy.get('img[title="Add/Update"]:visible').click();
cy.get('input.cb-is-load-graph').check();
cy.get('input[value="Execute"]:visible').click();
cy.wait(3000);
let cnt1 = -1;
cy.window().then((win) => {
cnt1 = win.cy.$().length;
expect(cnt1 - cnt0 >= 5).to.eq(true);
});

navbarAction('Edit', 'Query History');
cy.get('button.list-group-item').eq(0).click();
let cnt2 = -1;
cy.window().then((win) => {
cnt2 = win.cy.$().length;
expect(cnt2 == cnt0).to.eq(true);
});

cy.get('button.list-group-item').eq(1).click();
let cnt3 = -1;
cy.window().then((win) => {
cnt3 = win.cy.$().length;
expect(cnt3 == cnt1).to.eq(true);
});
});

it('TC6: Hide and/or show elements', () => {
navbarAction('Data', 'Sample Data');
let cnt0 = 0;
cy.window().then((win) => {
cnt0 = win.cy.$(':visible').length;
win.cy.$().slice(0, 10).select();
});

navbarAction('View', 'Hide Selected');
cy.window().then((win) => {
const cnt1 = win.cy.$(':visible').length;
expect(cnt1 < cnt0).to.eq(true);
});

navbarAction('View', 'Show All');
let cnt2 = 0;
cy.window().then((win) => {
cnt2 = win.cy.$(':visible').length;
// some collapsed edges might be expanded. So cnt2 can be greater.
expect(cnt2 >= cnt0).to.eq(true);
});
});

it('TC7: Expand/collapse nodes and edges', () => {
navbarAction('Data', 'Sample Data');
openSubTab('Group Nodes');
groupBy('By the Louvain modularity algorithm', true);
let compoundCount = -1;
cy.window().then((win) => {
compoundCount = win.cy.$(':parent').length;
expect(compoundCount > 2).to.eq(true);
});

navbarAction('View', 'Collapse All Nodes');
cy.window().then((win) => {
const collapsedCount = win.cy.$('.cy-expand-collapse-collapsed-node').length;
expect(collapsedCount == compoundCount).to.eq(true);
});

navbarAction('View', 'Expand All Nodes');
let compoundEdgeCnt = -1;
cy.window().then((win) => {
const compoundCount2 = win.cy.$(':parent').length;
expect(compoundCount2 == compoundCount).to.eq(true);
compoundEdgeCnt = win.cy.$('.cy-expand-collapse-collapsed-edge').length;
expect(compoundEdgeCnt > 0).to.eq(true);
});

navbarAction('View', 'Expand All Edges');
cy.window().then((win) => {
const compoundEdgeCnt2 = win.cy.$('.cy-expand-collapse-collapsed-edge').length;
expect(compoundEdgeCnt2 == 0).to.eq(true);
});

navbarAction('View', 'Collapse All Edges');
cy.window().then((win) => {
const compoundEdgeCnt3 = win.cy.$('.cy-expand-collapse-collapsed-edge').length;
expect(compoundEdgeCnt == compoundEdgeCnt3).to.eq(true);
});
});

it('TC8: Can highlight by seleting or searching', () => {
navbarAction('Data', 'Sample Data');

let sumClassCnt = -1;
cy.window().then((win) => {
sumClassCnt = win.cy.$().map(x => x.classes().length).reduce((s, x) => s + x, 0);
});

navbarAction('Highlight', 'Search...');
const inpId = 'highlight-search-inp';
cy.focused().should('have.attr', 'id').and('equal', inpId);

cy.get('#' + inpId).type('a');
cy.get('body').type('{enter}');

cy.window().then((win) => {
const sumClassCnt2 = win.cy.$().map(x => x.classes().length).reduce((s, x) => s + x, 0);
expect(sumClassCnt2 > sumClassCnt).to.eq(true);
});
});

});

0 comments on commit 24a7ca1

Please sign in to comment.