fix: tests
diff --git a/cypress/integration/test_organizational_chart_desktop.js b/cypress/integration/test_organizational_chart_desktop.js
index 95592e2..0493732 100644
--- a/cypress/integration/test_organizational_chart_desktop.js
+++ b/cypress/integration/test_organizational_chart_desktop.js
@@ -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 @@
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 @@
});
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 @@
});
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 @@
});
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 @@
});
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();
diff --git a/cypress/integration/test_organizational_chart_mobile.js b/cypress/integration/test_organizational_chart_mobile.js
index 632d15b..1dcfbcf 100644
--- a/cypress/integration/test_organizational_chart_mobile.js
+++ b/cypress/integration/test_organizational_chart_mobile.js
@@ -2,24 +2,17 @@
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 @@
});
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 @@
});
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 @@
});
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 @@
});
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 @@
});
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 @@
});
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 @@
});
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();
diff --git a/erpnext/tests/ui_test_helpers.py b/erpnext/tests/ui_test_helpers.py
index f66d69b..fc3aa29 100644
--- a/erpnext/tests/ui_test_helpers.py
+++ b/erpnext/tests/ui_test_helpers.py
@@ -17,6 +17,12 @@
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: