brotherton-erpnext/cypress/integration/test_organizational_chart_desktop.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
4.1 KiB
JavaScript
Raw Normal View History

2021-07-14 18:20:54 +00:00
context('Organizational Chart', () => {
before(() => {
cy.login();
2021-07-19 18:04:02 +00:00
cy.visit('/app/website');
2021-07-19 10:56:17 +00:00
cy.awesomebar('Organizational Chart');
2021-08-16 13:57:29 +00:00
cy.wait(500);
cy.url().should('include', '/organizational-chart');
2021-07-19 10:56:17 +00:00
cy.window().its('frappe.csrf_token').then(csrf_token => {
return cy.request({
url: `/api/method/erpnext.tests.ui_test_helpers.create_employee_records`,
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-Frappe-CSRF-Token': csrf_token
},
timeout: 60000
2021-07-20 05:25:05 +00:00
}).then(res => {
expect(res.status).eq(200);
cy.get('.frappe-control[data-fieldname=company] input').focus().as('input');
cy.get('@input')
.clear({ force: true })
.type('Test Org Chart{enter}', { force: true })
.blur({ force: true });
});
2021-07-19 18:04:02 +00:00
});
2021-07-14 18:20:54 +00:00
});
it('renders root nodes and loads children for the first expandable node', () => {
// check rendered root nodes and the node name, title, connections
cy.get('.hierarchy').find('.root-level ul.node-children').children()
.should('have.length', 2)
.first()
.as('first-child');
cy.get('@first-child').get('.node-name').contains('Test Employee 1');
cy.get('@first-child').get('.node-info').find('.node-title').contains('CEO');
cy.get('@first-child').get('.node-info').find('.node-connections').contains('· 2 Connections');
2021-07-19 16:49:28 +00:00
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
2021-07-14 18:20:54 +00:00
// children of 1st root visible
2021-07-19 18:04:02 +00:00
cy.get(`div[data-parent="${employee_records.message[0]}"]`).as('child-node');
2021-07-14 18:20:54 +00:00
cy.get('@child-node')
.should('have.length', 1)
.should('be.visible');
cy.get('@child-node').get('.node-name').contains('Test Employee 3');
// connectors between first root node and immediate child
cy.get(`path[data-parent="${employee_records.message[0]}"]`)
.should('be.visible')
.invoke('attr', 'data-child')
2021-07-15 14:02:15 +00:00
.should('equal', employee_records.message[2]);
2021-07-14 18:20:54 +00:00
});
});
it('hides active nodes children and connectors on expanding sibling node', () => {
2021-07-19 16:49:28 +00:00
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
2021-07-14 18:20:54 +00:00
// click sibling
cy.get(`#${employee_records.message[1]}`)
.click()
.should('have.class', 'active');
// child nodes and connectors hidden
cy.get(`[data-parent="${employee_records.message[0]}"]`).should('not.be.visible');
cy.get(`path[data-parent="${employee_records.message[0]}"]`).should('not.be.visible');
});
});
it('collapses previous level nodes and refreshes connectors on expanding child node', () => {
2021-07-19 16:49:28 +00:00
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
2021-07-14 18:20:54 +00:00
// click child node
cy.get(`#${employee_records.message[3]}`)
.click()
.should('have.class', 'active');
// previous level nodes: parent should be on active-path; other nodes should be collapsed
cy.get(`#${employee_records.message[0]}`).should('have.class', 'collapsed');
cy.get(`#${employee_records.message[1]}`).should('have.class', 'active-path');
// previous level connectors refreshed
cy.get(`path[data-parent="${employee_records.message[1]}"]`)
.should('have.class', 'collapsed-connector');
// child node's children and connectors rendered
cy.get(`[data-parent="${employee_records.message[3]}"]`).should('be.visible');
cy.get(`path[data-parent="${employee_records.message[3]}"]`).should('be.visible');
});
});
it('expands previous level nodes', () => {
2021-07-19 16:49:28 +00:00
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
2021-07-14 18:20:54 +00:00
cy.get(`#${employee_records.message[0]}`)
.click()
.should('have.class', 'active');
cy.get(`[data-parent="${employee_records.message[0]}"]`)
.should('be.visible');
cy.get('ul.hierarchy').children().should('have.length', 2);
cy.get(`#connectors`).children().should('have.length', 1);
});
});
it('edit node navigates to employee master', () => {
2021-07-19 16:49:28 +00:00
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
2021-07-14 18:20:54 +00:00
cy.get(`#${employee_records.message[0]}`).find('.btn-edit-node')
.click();
cy.url().should('include', `/employee/${employee_records.message[0]}`);
});
});
});