fix: tests
This commit is contained in:
parent
e327148edf
commit
89c5bb6066
@ -1,21 +1,17 @@
|
||||
context('Organizational Chart', () => {
|
||||
before(() => {
|
||||
cy.login();
|
||||
cy.visit('/app/website');
|
||||
cy.visit('/app');
|
||||
|
||||
cy.call('erpnext.tests.ui_test_helpers.create_employee_records');
|
||||
cy.awesomebar('Organizational Chart');
|
||||
|
||||
cy.get('.frappe-control[data-fieldname=company] input').first().focus().as('input');
|
||||
cy.get('@input').clear().wait(200).type('Test Org Chart', { force: true });
|
||||
cy.get('@input').type('{enter}', { delay: 100 });
|
||||
cy.get('.frappe-control[data-fieldname=company] input').focus().as('input');
|
||||
cy.get('@input')
|
||||
.clear({ force: true })
|
||||
.type('Test Org Chart', { force: true });
|
||||
cy.wait(200);
|
||||
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', () => {
|
||||
@ -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-connections').contains('· 2 Connections');
|
||||
|
||||
// check children of first node
|
||||
cy.get('@employee_records').then(employee_records => {
|
||||
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||
// children of 1st root visible
|
||||
cy.get(`[data-parent="${employee_records.message[0]}"]`).as('child-node');
|
||||
cy.get('@child-node')
|
||||
@ -47,7 +42,7 @@ context('Organizational Chart', () => {
|
||||
});
|
||||
|
||||
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
|
||||
cy.get(`#${employee_records.message[1]}`)
|
||||
.click()
|
||||
@ -60,7 +55,7 @@ context('Organizational Chart', () => {
|
||||
});
|
||||
|
||||
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
|
||||
cy.get(`#${employee_records.message[3]}`)
|
||||
.click()
|
||||
@ -81,7 +76,7 @@ context('Organizational Chart', () => {
|
||||
});
|
||||
|
||||
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]}`)
|
||||
.click()
|
||||
.should('have.class', 'active');
|
||||
@ -95,7 +90,7 @@ context('Organizational Chart', () => {
|
||||
});
|
||||
|
||||
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')
|
||||
.click();
|
||||
|
||||
|
@ -2,24 +2,17 @@ context('Organizational Chart Mobile', () => {
|
||||
before(() => {
|
||||
cy.login();
|
||||
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.get('.frappe-control[data-fieldname=company] input').first().focus().as('input');
|
||||
cy.get('@input').clear().wait(200).type('Test Org Chart', { force: true });
|
||||
cy.get('@input').type('{enter}', { delay: 100 });
|
||||
cy.get('.frappe-control[data-fieldname=company] input').focus().as('input');
|
||||
cy.get('@input')
|
||||
.clear({ force: true })
|
||||
.type('Test Org Chart', { force: true });
|
||||
cy.wait(200);
|
||||
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', () => {
|
||||
@ -35,7 +28,7 @@ context('Organizational Chart Mobile', () => {
|
||||
});
|
||||
|
||||
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]}`)
|
||||
.click()
|
||||
.should('have.class', 'active');
|
||||
@ -68,7 +61,7 @@ context('Organizational Chart Mobile', () => {
|
||||
});
|
||||
|
||||
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]}`)
|
||||
.click()
|
||||
.should('have.class', 'active')
|
||||
@ -97,7 +90,7 @@ context('Organizational Chart Mobile', () => {
|
||||
});
|
||||
|
||||
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
|
||||
cy.get(`#${employee_records.message[1]}`)
|
||||
.next()
|
||||
@ -118,7 +111,7 @@ context('Organizational Chart Mobile', () => {
|
||||
});
|
||||
|
||||
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]}`)
|
||||
.click()
|
||||
.should('have.class', 'active');
|
||||
@ -137,7 +130,7 @@ context('Organizational Chart Mobile', () => {
|
||||
});
|
||||
|
||||
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
|
||||
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', () => {
|
||||
cy.get('@employee_records').then(() => {
|
||||
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(() => {
|
||||
// click on non-collapsed sibling group
|
||||
cy.get('.hierarchy-mobile')
|
||||
.prev()
|
||||
@ -176,7 +169,7 @@ context('Organizational Chart Mobile', () => {
|
||||
});
|
||||
|
||||
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')
|
||||
.click();
|
||||
|
||||
|
@ -17,6 +17,12 @@ def create_employee_records():
|
||||
employees = [emp1, emp2, emp3, emp4, emp5, emp6, emp7]
|
||||
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():
|
||||
company = frappe.db.exists('Company', 'Test Org Chart')
|
||||
if not company:
|
||||
|
Loading…
x
Reference in New Issue
Block a user