fix: tests
This commit is contained in:
parent
e327148edf
commit
89c5bb6066
@ -1,21 +1,17 @@
|
|||||||
context('Organizational Chart', () => {
|
context('Organizational Chart', () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.login();
|
cy.login();
|
||||||
cy.visit('/app/website');
|
cy.visit('/app');
|
||||||
|
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.create_employee_records');
|
||||||
cy.awesomebar('Organizational Chart');
|
cy.awesomebar('Organizational Chart');
|
||||||
|
|
||||||
cy.get('.frappe-control[data-fieldname=company] input').first().focus().as('input');
|
cy.get('.frappe-control[data-fieldname=company] input').focus().as('input');
|
||||||
cy.get('@input').clear().wait(200).type('Test Org Chart', { force: true });
|
cy.get('@input')
|
||||||
cy.get('@input').type('{enter}', { delay: 100 });
|
.clear({ force: true })
|
||||||
|
.type('Test Org Chart', { force: true });
|
||||||
|
cy.wait(200);
|
||||||
cy.get('@input').blur({ force: true });
|
cy.get('@input').blur({ force: true });
|
||||||
|
|
||||||
cy.wait(500);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
return cy.window().its('frappe').then(frappe => {
|
|
||||||
return frappe.call('erpnext.tests.ui_test_helpers.create_employee_records');
|
|
||||||
}).as('employee_records');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders root nodes and loads children for the first expandable node', () => {
|
it('renders root nodes and loads children for the first expandable node', () => {
|
||||||
@ -29,8 +25,7 @@ context('Organizational Chart', () => {
|
|||||||
cy.get('@first-child').get('.node-info').find('.node-title').contains('CEO');
|
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');
|
cy.get('@first-child').get('.node-info').find('.node-connections').contains('· 2 Connections');
|
||||||
|
|
||||||
// check children of first node
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
|
||||||
// children of 1st root visible
|
// children of 1st root visible
|
||||||
cy.get(`[data-parent="${employee_records.message[0]}"]`).as('child-node');
|
cy.get(`[data-parent="${employee_records.message[0]}"]`).as('child-node');
|
||||||
cy.get('@child-node')
|
cy.get('@child-node')
|
||||||
@ -47,7 +42,7 @@ context('Organizational Chart', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('hides active nodes children and connectors on expanding sibling node', () => {
|
it('hides active nodes children and connectors on expanding sibling node', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
// click sibling
|
// click sibling
|
||||||
cy.get(`#${employee_records.message[1]}`)
|
cy.get(`#${employee_records.message[1]}`)
|
||||||
.click()
|
.click()
|
||||||
@ -60,7 +55,7 @@ context('Organizational Chart', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('collapses previous level nodes and refreshes connectors on expanding child node', () => {
|
it('collapses previous level nodes and refreshes connectors on expanding child node', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
// click child node
|
// click child node
|
||||||
cy.get(`#${employee_records.message[3]}`)
|
cy.get(`#${employee_records.message[3]}`)
|
||||||
.click()
|
.click()
|
||||||
@ -81,7 +76,7 @@ context('Organizational Chart', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('expands previous level nodes', () => {
|
it('expands previous level nodes', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
cy.get(`#${employee_records.message[0]}`)
|
cy.get(`#${employee_records.message[0]}`)
|
||||||
.click()
|
.click()
|
||||||
.should('have.class', 'active');
|
.should('have.class', 'active');
|
||||||
@ -95,7 +90,7 @@ context('Organizational Chart', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('edit node navigates to employee master', () => {
|
it('edit node navigates to employee master', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
cy.get(`#${employee_records.message[0]}`).find('.btn-edit-node')
|
cy.get(`#${employee_records.message[0]}`).find('.btn-edit-node')
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
|
|||||||
@ -2,24 +2,17 @@ context('Organizational Chart Mobile', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.login();
|
cy.login();
|
||||||
cy.viewport(375, 667);
|
cy.viewport(375, 667);
|
||||||
cy.visit('/app/website');
|
cy.visit('/app');
|
||||||
|
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.create_employee_records');
|
||||||
cy.awesomebar('Organizational Chart');
|
cy.awesomebar('Organizational Chart');
|
||||||
|
|
||||||
cy.get('.frappe-control[data-fieldname=company] input').first().focus().as('input');
|
cy.get('.frappe-control[data-fieldname=company] input').focus().as('input');
|
||||||
cy.get('@input').clear().wait(200).type('Test Org Chart', { force: true });
|
cy.get('@input')
|
||||||
cy.get('@input').type('{enter}', { delay: 100 });
|
.clear({ force: true })
|
||||||
|
.type('Test Org Chart', { force: true });
|
||||||
|
cy.wait(200);
|
||||||
cy.get('@input').blur({ force: true });
|
cy.get('@input').blur({ force: true });
|
||||||
|
|
||||||
cy.wait(500);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.viewport(375, 667);
|
|
||||||
cy.wait(500);
|
|
||||||
|
|
||||||
return cy.window().its('frappe').then(frappe => {
|
|
||||||
return frappe.call('erpnext.tests.ui_test_helpers.create_employee_records');
|
|
||||||
}).as('employee_records');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders root nodes', () => {
|
it('renders root nodes', () => {
|
||||||
@ -35,7 +28,7 @@ context('Organizational Chart Mobile', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('expands root node', () => {
|
it('expands root node', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
cy.get(`#${employee_records.message[1]}`)
|
cy.get(`#${employee_records.message[1]}`)
|
||||||
.click()
|
.click()
|
||||||
.should('have.class', 'active');
|
.should('have.class', 'active');
|
||||||
@ -68,7 +61,7 @@ context('Organizational Chart Mobile', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('expands child node', () => {
|
it('expands child node', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
cy.get(`#${employee_records.message[3]}`)
|
cy.get(`#${employee_records.message[3]}`)
|
||||||
.click()
|
.click()
|
||||||
.should('have.class', 'active')
|
.should('have.class', 'active')
|
||||||
@ -97,7 +90,7 @@ context('Organizational Chart Mobile', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('renders sibling group', () => {
|
it('renders sibling group', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
// sibling group visible for parent
|
// sibling group visible for parent
|
||||||
cy.get(`#${employee_records.message[1]}`)
|
cy.get(`#${employee_records.message[1]}`)
|
||||||
.next()
|
.next()
|
||||||
@ -118,7 +111,7 @@ context('Organizational Chart Mobile', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('expands previous level nodes', () => {
|
it('expands previous level nodes', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
cy.get(`#${employee_records.message[6]}`)
|
cy.get(`#${employee_records.message[6]}`)
|
||||||
.click()
|
.click()
|
||||||
.should('have.class', 'active');
|
.should('have.class', 'active');
|
||||||
@ -137,7 +130,7 @@ context('Organizational Chart Mobile', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('expands sibling group', () => {
|
it('expands sibling group', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
// sibling group visible for parent
|
// sibling group visible for parent
|
||||||
cy.get(`#${employee_records.message[6]}`).click();
|
cy.get(`#${employee_records.message[6]}`).click();
|
||||||
|
|
||||||
@ -164,7 +157,7 @@ context('Organizational Chart Mobile', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('goes to the respective level after clicking on non-collapsed sibling group', () => {
|
it('goes to the respective level after clicking on non-collapsed sibling group', () => {
|
||||||
cy.get('@employee_records').then(() => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(() => {
|
||||||
// click on non-collapsed sibling group
|
// click on non-collapsed sibling group
|
||||||
cy.get('.hierarchy-mobile')
|
cy.get('.hierarchy-mobile')
|
||||||
.prev()
|
.prev()
|
||||||
@ -176,7 +169,7 @@ context('Organizational Chart Mobile', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('edit node navigates to employee master', () => {
|
it('edit node navigates to employee master', () => {
|
||||||
cy.get('@employee_records').then(employee_records => {
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
cy.get(`#${employee_records.message[0]}`).find('.btn-edit-node')
|
cy.get(`#${employee_records.message[0]}`).find('.btn-edit-node')
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,12 @@ def create_employee_records():
|
|||||||
employees = [emp1, emp2, emp3, emp4, emp5, emp6, emp7]
|
employees = [emp1, emp2, emp3, emp4, emp5, emp6, emp7]
|
||||||
return employees
|
return employees
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_employee_records():
|
||||||
|
return frappe.db.get_list('Employee', filters={
|
||||||
|
'company': 'Test Org Chart'
|
||||||
|
}, pluck='name', order_by='name')
|
||||||
|
|
||||||
def create_company():
|
def create_company():
|
||||||
company = frappe.db.exists('Company', 'Test Org Chart')
|
company = frappe.db.exists('Company', 'Test Org Chart')
|
||||||
if not company:
|
if not company:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user