seitime-frappe/cypress/integration/depends_on.js
Shivam Mishra 98d3533c2c
fix: UI tests (#9664)
* fix: fallback for default desk page

* fix: return if reference name does not exist

* refactor: rename to Query Report

* refactor: codacy linting fixes

* refactor: null check for data in workspace

* feat: enable cypress recording

* chore: codacy linting fixes

* refactor: don't set route explicitly

* fix (cypress): wait for request to be complete in grid pagination test

* fix (cypress): explicitly return async calls

* refactor: visit new_form directly

* refactor: skip some scripts for ui tests

* Revert "refactor: skip some scripts for ui tests"

This reverts commit 1e46e3cd5361c2910d25efb244774d153511af53.
2020-03-09 12:30:59 +00:00

63 lines
2.3 KiB
JavaScript

context('Depends On', () => {
beforeEach(() => {
cy.login();
return cy.new_form('Test Depends On');
});
before(() => {
cy.login();
cy.visit('/desk#workspace/Website');
return cy.window().its('frappe').then(frappe => {
return frappe.call('frappe.tests.ui_test_helpers.create_doctype', {
name: 'Test Depends On',
fields: [
{
"label": "Test Field",
"fieldname": "test_field",
"fieldtype": "Data",
},
{
"label": "Dependant Field",
"fieldname": "dependant_field",
"fieldtype": "Data",
"mandatory_depends_on": "eval:doc.test_field=='Some Value'",
"read_only_depends_on": "eval:doc.test_field=='Some Other Value'",
},
{
"label": "Display Dependant Field",
"fieldname": "display_dependant_field",
"fieldtype": "Data",
'depends_on': "eval:doc.test_field=='Value'"
},
]
});
});
});
it('should set the field as mandatory depending on other fields value', () => {
cy.new_form('Test Depends On');
cy.fill_field('test_field', 'Some Value');
cy.get('button.primary-action').contains('Save').click();
cy.get('.msgprint-dialog .modal-title').contains('Missing Fields').should('be.visible');
cy.get('body').click();
cy.fill_field('test_field', 'Random value');
cy.get('button.primary-action').contains('Save').click();
cy.get('.msgprint-dialog .modal-title').contains('Missing Fields').should('not.be.visible');
});
it('should set the field as read only depending on other fields value', () => {
cy.new_form('Test Depends On');
cy.fill_field('dependant_field', 'Some Value');
cy.fill_field('test_field', 'Some Other Value');
cy.get('body').click();
cy.get('.control-input [data-fieldname="dependant_field"]').should('be.disabled');
cy.fill_field('test_field', 'Random Value');
cy.get('body').click();
cy.get('.control-input [data-fieldname="dependant_field"]').should('not.be.disabled');
});
it('should display the field depending on other fields value', () => {
cy.new_form('Test Depends On');
cy.get('.control-input [data-fieldname="display_dependant_field"]').should('not.be.visible');
cy.get('.control-input [data-fieldname="test_field"]').clear();
cy.fill_field('test_field', 'Value');
cy.get('body').click();
cy.get('.control-input [data-fieldname="display_dependant_field"]').should('be.visible');
});
});