From 38c6db06ea1d25d9a13775efc3b2145823ce1bdb Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Mon, 21 Mar 2022 13:13:19 +0530 Subject: [PATCH 01/11] test: Added test script for control type "Dynamic Link" --- cypress/integration/control_dynamiclink.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cypress/integration/control_dynamiclink.js diff --git a/cypress/integration/control_dynamiclink.js b/cypress/integration/control_dynamiclink.js new file mode 100644 index 0000000000..590ab37c3b --- /dev/null +++ b/cypress/integration/control_dynamiclink.js @@ -0,0 +1,34 @@ +context('Dynamic Link', () => { + before(() => { + cy.login(); + cy.visit('/app/doctype'); + return cy.window().its('frappe').then(frappe => { + return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', { + name: 'Test Dynamic Link', + fields: [ + { + "label": "Document Type", + "fieldname": "doc_type", + "fieldtype": "Link", + "options": "DocType", + "in_list_view": 1, + }, + { + "label": "Document ID", + "fieldname": "doc_id", + "fieldtype": "Dynamic Link", + "options": "doc_type", + "in_list_view": 1, + }, + ] + }); + }); + }); + it('Creating a dynamic link and verifying it', () => { + cy.new_form('Test Dynamic Link'); + cy.get('form > [data-fieldname="doc_type"]').type('User'); + cy.get('form > [data-fieldname="doc_id"]').click(); + cy.get('[id="awesomplete_list_4"]').its('length').should('be.gte', 0); + + }); +}); From 9b69f4e08c1811a1b3e9a87b08335ad9c5193fc0 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Mon, 21 Mar 2022 13:32:16 +0530 Subject: [PATCH 02/11] test: fixing sider issues --- cypress/integration/control_dynamiclink.js | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/cypress/integration/control_dynamiclink.js b/cypress/integration/control_dynamiclink.js index 590ab37c3b..206d04e5f2 100644 --- a/cypress/integration/control_dynamiclink.js +++ b/cypress/integration/control_dynamiclink.js @@ -1,34 +1,34 @@ context('Dynamic Link', () => { - before(() => { - cy.login(); - cy.visit('/app/doctype'); - return cy.window().its('frappe').then(frappe => { - return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', { - name: 'Test Dynamic Link', - fields: [ - { - "label": "Document Type", - "fieldname": "doc_type", - "fieldtype": "Link", - "options": "DocType", - "in_list_view": 1, - }, - { - "label": "Document ID", - "fieldname": "doc_id", - "fieldtype": "Dynamic Link", - "options": "doc_type", - "in_list_view": 1, - }, - ] - }); - }); - }); - it('Creating a dynamic link and verifying it', () => { - cy.new_form('Test Dynamic Link'); + before(() => { + cy.login(); + cy.visit('/app/doctype'); + return cy.window().its('frappe').then(frappe => { + return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', { + name: 'Test Dynamic Link', + fields: [ + { + "label": "Document Type", + "fieldname": "doc_type", + "fieldtype": "Link", + "options": "DocType", + "in_list_view": 1, + }, + { + "label": "Document ID", + "fieldname": "doc_id", + "fieldtype": "Dynamic Link", + "options": "doc_type", + "in_list_view": 1, + }, + ] + }); + }); + }); + it('Creating a dynamic link and verifying it', () => { + cy.new_form('Test Dynamic Link'); cy.get('form > [data-fieldname="doc_type"]').type('User'); cy.get('form > [data-fieldname="doc_id"]').click(); cy.get('[id="awesomplete_list_4"]').its('length').should('be.gte', 0); - }); + }); }); From a139d1d369b5a24e8c4c0e2a7cedcfed7dd9fa90 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Mon, 21 Mar 2022 13:39:22 +0530 Subject: [PATCH 03/11] test: fixing sider issues --- cypress/integration/control_dynamiclink.js | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/cypress/integration/control_dynamiclink.js b/cypress/integration/control_dynamiclink.js index 206d04e5f2..c989889ca2 100644 --- a/cypress/integration/control_dynamiclink.js +++ b/cypress/integration/control_dynamiclink.js @@ -2,27 +2,27 @@ context('Dynamic Link', () => { before(() => { cy.login(); cy.visit('/app/doctype'); - return cy.window().its('frappe').then(frappe => { - return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', { - name: 'Test Dynamic Link', - fields: [ - { - "label": "Document Type", - "fieldname": "doc_type", - "fieldtype": "Link", - "options": "DocType", - "in_list_view": 1, - }, - { - "label": "Document ID", - "fieldname": "doc_id", - "fieldtype": "Dynamic Link", - "options": "doc_type", - "in_list_view": 1, - }, - ] - }); + return cy.window().its('frappe').then(frappe => { + return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', { + name: 'Test Dynamic Link', + fields: [ + { + "label": "Document Type", + "fieldname": "doc_type", + "fieldtype": "Link", + "options": "DocType", + "in_list_view": 1, + }, + { + "label": "Document ID", + "fieldname": "doc_id", + "fieldtype": "Dynamic Link", + "options": "doc_type", + "in_list_view": 1, + }, + ] }); + }); }); it('Creating a dynamic link and verifying it', () => { cy.new_form('Test Dynamic Link'); From 7fbbf577c90cbb877dc34c42b5e925373b2d34a4 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Mon, 21 Mar 2022 13:44:33 +0530 Subject: [PATCH 04/11] test: fixing sider issues --- cypress/integration/control_dynamiclink.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cypress/integration/control_dynamiclink.js b/cypress/integration/control_dynamiclink.js index c989889ca2..bef4034120 100644 --- a/cypress/integration/control_dynamiclink.js +++ b/cypress/integration/control_dynamiclink.js @@ -4,21 +4,21 @@ context('Dynamic Link', () => { cy.visit('/app/doctype'); return cy.window().its('frappe').then(frappe => { return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', { - name: 'Test Dynamic Link', + name: 'Test Dynamic Link', fields: [ { - "label": "Document Type", - "fieldname": "doc_type", - "fieldtype": "Link", - "options": "DocType", - "in_list_view": 1, + "label": "Document Type", + "fieldname": "doc_type", + "fieldtype": "Link", + "options": "DocType", + "in_list_view": 1, }, { - "label": "Document ID", - "fieldname": "doc_id", - "fieldtype": "Dynamic Link", - "options": "doc_type", - "in_list_view": 1, + "label": "Document ID", + "fieldname": "doc_id", + "fieldtype": "Dynamic Link", + "options": "doc_type", + "in_list_view": 1, }, ] }); From df62607c4324df555ad6c3c0c4e0c961a08ee6ae Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Mon, 21 Mar 2022 17:02:59 +0530 Subject: [PATCH 05/11] test: Corrected the selector --- cypress/integration/control_dynamiclink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/control_dynamiclink.js b/cypress/integration/control_dynamiclink.js index bef4034120..3df33acc3f 100644 --- a/cypress/integration/control_dynamiclink.js +++ b/cypress/integration/control_dynamiclink.js @@ -28,7 +28,7 @@ context('Dynamic Link', () => { cy.new_form('Test Dynamic Link'); cy.get('form > [data-fieldname="doc_type"]').type('User'); cy.get('form > [data-fieldname="doc_id"]').click(); - cy.get('[id="awesomplete_list_4"]').its('length').should('be.gte', 0); + cy.get_field("doc_id").its('length').should('be.gte', 0); }); }); From b2fef12b44103f2f990caf07c4171ed388fe159f Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Thu, 24 Mar 2022 19:42:38 +0530 Subject: [PATCH 06/11] test: Renaimg the file and also adding tests --- cypress/integration/control_dynamic_link.js | 103 ++++++++++++++++++++ cypress/integration/control_dynamiclink.js | 34 ------- cypress/support/index.js | 3 + 3 files changed, 106 insertions(+), 34 deletions(-) create mode 100644 cypress/integration/control_dynamic_link.js delete mode 100644 cypress/integration/control_dynamiclink.js diff --git a/cypress/integration/control_dynamic_link.js b/cypress/integration/control_dynamic_link.js new file mode 100644 index 0000000000..7d642b1b12 --- /dev/null +++ b/cypress/integration/control_dynamic_link.js @@ -0,0 +1,103 @@ +context('Dynamic Link', () => { + before(() => { + cy.login(); + cy.visit('/app/doctype'); + return cy.window().its('frappe').then(frappe => { + return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', { + name: 'Test Dynamic Link', + fields: [ + { + "label": "Document Type", + "fieldname": "doc_type", + "fieldtype": "Link", + "options": "DocType", + "in_list_view": 1, + "in_standard_filter": 1, + }, + { + "label": "Document ID", + "fieldname": "doc_id", + "fieldtype": "Dynamic Link", + "options": "doc_type", + "in_list_view": 1, + "in_standard_filter": 1, + }, + ] + }); + }); + }); + + + function get_dialog_with_dynamic_link() { + return cy.dialog({ + title: 'Dynamic Link', + fields: [{ + "label": "Document Type", + "fieldname": "doc_type", + "fieldtype": "Link", + "options": "DocType", + "in_list_view": 1, + }, + { + "label": "Document ID", + "fieldname": "doc_id", + "fieldtype": "Dynamic Link", + "options": "doc_type", + "in_list_view": 1, + }] + }); + } + + it('Creating a dynamic link and verifying it in a dialog', () => { + //Opening a dialog + get_dialog_with_dynamic_link().as('dialog'); + cy.get_field('doc_type').clear(); + + //Entering User in the Doctype field + cy.fill_field('doc_type','User','Link'); + + //Clicking on the Document ID field + cy.get_field('doc_id').click(); + + //Checking if the listbox have length greater than 0 + cy.get('.awesomplete').find("li").its('length').should('be.gte', 0); + + //Closing the dialog box + cy.get('.btn-modal-close > .icon').click(); + }); + + it('Creating a dynamic link and verifying it', () => { + //Visiting the dynamic link doctype + cy.visit('/app/test-dynamic-link'); + + //Clicking on the Document ID field + cy.get_field('doc_type').clear(); + + //Entering User in the Doctype field + cy.fill_field('doc_type','User','Link', {delay : 500}); + cy.get_field('doc_id').click(); + + //Checking if the listbox have length greater than 0 + cy.get('.awesomplete').find("li").its('length').should('be.gte', 0); + + //Opening a new form for dynamic link doctype + cy.new_form('Test Dynamic Link'); + cy.get_field('doc_type').clear(); + + //Entering User in the Doctype field + cy.fill_field('doc_type','User','Link', {delay : 500}); + cy.get_field('doc_id').click(); + + //Checking if the listbox have length greater than 0 + cy.get('.awesomplete').find("li").its('length').should('be.gte', 0); + cy.get_field('doc_type').clear(); + + //Entering System Settings in the Doctype field + cy.fill_field('doc_type','System Settings','Link', {delay : 500}); + cy.get_field('doc_id').click(); + + //Checking if the system throws error + cy.get('.modal-title').should('have.text','Error'); + cy.get('.msgprint').should('have.text','System Settings is not a valid DocType for Dynamic Link'); + }); +}); \ No newline at end of file diff --git a/cypress/integration/control_dynamiclink.js b/cypress/integration/control_dynamiclink.js deleted file mode 100644 index 3df33acc3f..0000000000 --- a/cypress/integration/control_dynamiclink.js +++ /dev/null @@ -1,34 +0,0 @@ -context('Dynamic Link', () => { - before(() => { - cy.login(); - cy.visit('/app/doctype'); - return cy.window().its('frappe').then(frappe => { - return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', { - name: 'Test Dynamic Link', - fields: [ - { - "label": "Document Type", - "fieldname": "doc_type", - "fieldtype": "Link", - "options": "DocType", - "in_list_view": 1, - }, - { - "label": "Document ID", - "fieldname": "doc_id", - "fieldtype": "Dynamic Link", - "options": "doc_type", - "in_list_view": 1, - }, - ] - }); - }); - }); - it('Creating a dynamic link and verifying it', () => { - cy.new_form('Test Dynamic Link'); - cy.get('form > [data-fieldname="doc_type"]').type('User'); - cy.get('form > [data-fieldname="doc_id"]').click(); - cy.get_field("doc_id").its('length').should('be.gte', 0); - - }); -}); diff --git a/cypress/support/index.js b/cypress/support/index.js index 9cd770a31e..f0b53ae833 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -17,6 +17,9 @@ import './commands'; import '@cypress/code-coverage/support'; +Cypress.on('uncaught:exception', (err, runnable) => { + return false +}); // Alternatively you can use CommonJS syntax: // require('./commands') From 8516ea6e474c73a97e8e770c852036c0908d7245 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Thu, 24 Mar 2022 20:14:19 +0530 Subject: [PATCH 07/11] test: Corrected the selector --- cypress/integration/control_dynamic_link.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cypress/integration/control_dynamic_link.js b/cypress/integration/control_dynamic_link.js index 7d642b1b12..d96843c10b 100644 --- a/cypress/integration/control_dynamic_link.js +++ b/cypress/integration/control_dynamic_link.js @@ -60,7 +60,7 @@ context('Dynamic Link', () => { cy.get_field('doc_id').click(); //Checking if the listbox have length greater than 0 - cy.get('.awesomplete').find("li").its('length').should('be.gte', 0); + cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0); //Closing the dialog box cy.get('.btn-modal-close > .icon').click(); @@ -78,7 +78,7 @@ context('Dynamic Link', () => { cy.get_field('doc_id').click(); //Checking if the listbox have length greater than 0 - cy.get('.awesomplete').find("li").its('length').should('be.gte', 0); + cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0); //Opening a new form for dynamic link doctype cy.new_form('Test Dynamic Link'); @@ -89,7 +89,7 @@ context('Dynamic Link', () => { cy.get_field('doc_id').click(); //Checking if the listbox have length greater than 0 - cy.get('.awesomplete').find("li").its('length').should('be.gte', 0); + cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0); cy.get_field('doc_type').clear(); //Entering System Settings in the Doctype field From e1138eaf927b340ffa6f7d9ca352514eefc2e325 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Thu, 24 Mar 2022 20:17:56 +0530 Subject: [PATCH 08/11] test: Fixing sider issues --- cypress/integration/control_dynamic_link.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cypress/integration/control_dynamic_link.js b/cypress/integration/control_dynamic_link.js index d96843c10b..26f7e0b85e 100644 --- a/cypress/integration/control_dynamic_link.js +++ b/cypress/integration/control_dynamic_link.js @@ -54,7 +54,7 @@ context('Dynamic Link', () => { cy.get_field('doc_type').clear(); //Entering User in the Doctype field - cy.fill_field('doc_type','User','Link'); + cy.fill_field('doc_type', 'User', 'Link'); //Clicking on the Document ID field cy.get_field('doc_id').click(); @@ -74,7 +74,7 @@ context('Dynamic Link', () => { cy.get_field('doc_type').clear(); //Entering User in the Doctype field - cy.fill_field('doc_type','User','Link', {delay : 500}); + cy.fill_field('doc_type', 'User', 'Link', {delay: 500}); cy.get_field('doc_id').click(); //Checking if the listbox have length greater than 0 @@ -85,7 +85,7 @@ context('Dynamic Link', () => { cy.get_field('doc_type').clear(); //Entering User in the Doctype field - cy.fill_field('doc_type','User','Link', {delay : 500}); + cy.fill_field('doc_type', 'User', 'Link', {delay: 500}); cy.get_field('doc_id').click(); //Checking if the listbox have length greater than 0 @@ -93,11 +93,11 @@ context('Dynamic Link', () => { cy.get_field('doc_type').clear(); //Entering System Settings in the Doctype field - cy.fill_field('doc_type','System Settings','Link', {delay : 500}); + cy.fill_field('doc_type', 'System Settings', 'Link', {delay: 500}); cy.get_field('doc_id').click(); //Checking if the system throws error - cy.get('.modal-title').should('have.text','Error'); - cy.get('.msgprint').should('have.text','System Settings is not a valid DocType for Dynamic Link'); + cy.get('.modal-title').should('have.text', 'Error'); + cy.get('.msgprint').should('have.text', 'System Settings is not a valid DocType for Dynamic Link'); }); }); \ No newline at end of file From b79f9918b4b3591d1a64fe98df4de14a935596f7 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Thu, 24 Mar 2022 20:23:46 +0530 Subject: [PATCH 09/11] test: Fixing sider issues --- cypress/support/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/index.js b/cypress/support/index.js index f0b53ae833..5980e96677 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -18,7 +18,7 @@ import './commands'; import '@cypress/code-coverage/support'; Cypress.on('uncaught:exception', (err, runnable) => { - return false + return false; }); // Alternatively you can use CommonJS syntax: From c07f62a104f1d8373da7cd218a2a01730a77dd57 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Fri, 25 Mar 2022 16:56:52 +0530 Subject: [PATCH 10/11] test: Added test for checking if dynamic link works by passing options as function --- cypress/integration/control_dynamic_link.js | 41 ++++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/cypress/integration/control_dynamic_link.js b/cypress/integration/control_dynamic_link.js index 26f7e0b85e..b9e9a7d99e 100644 --- a/cypress/integration/control_dynamic_link.js +++ b/cypress/integration/control_dynamic_link.js @@ -48,26 +48,49 @@ context('Dynamic Link', () => { }); } + function get_dialog_with_dynamic_link_option() { + return cy.dialog({ + title: 'Dynamic Link', + fields: [{ + "label": "Document Type", + "fieldname": "doc_type", + "fieldtype": "Link", + "options": "DocType", + "in_list_view": 1, + }, + { + "label": "Document ID", + "fieldname": "doc_id", + "fieldtype": "Dynamic Link", + "get_options": () => { return "User"; }, + "in_list_view": 1, + }] + }); + } + + it('Creating a dynamic link by passing option as function and verifying it in a dialog', () => { + get_dialog_with_dynamic_link_option().as('dialog'); + cy.get_field('doc_type').clear(); + cy.fill_field('doc_type', 'User', 'Link'); + cy.get_field('doc_id').click(); + + //Checking if the listbox have length greater than 0 + cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0); + cy.get('.btn-modal-close').click({force: true}); + }); + it('Creating a dynamic link and verifying it in a dialog', () => { - //Opening a dialog get_dialog_with_dynamic_link().as('dialog'); cy.get_field('doc_type').clear(); - - //Entering User in the Doctype field cy.fill_field('doc_type', 'User', 'Link'); - - //Clicking on the Document ID field cy.get_field('doc_id').click(); //Checking if the listbox have length greater than 0 cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0); - - //Closing the dialog box - cy.get('.btn-modal-close > .icon').click(); + cy.get('.btn-modal-close').click({force: true, multiple: true}); }); it('Creating a dynamic link and verifying it', () => { - //Visiting the dynamic link doctype cy.visit('/app/test-dynamic-link'); //Clicking on the Document ID field From 44fb9fae3958f309d9944f4bf3c6fd9959a30047 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 Date: Fri, 25 Mar 2022 17:15:57 +0530 Subject: [PATCH 11/11] test: Fixing sider issues --- cypress/integration/control_dynamic_link.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress/integration/control_dynamic_link.js b/cypress/integration/control_dynamic_link.js index b9e9a7d99e..cc1eb0b695 100644 --- a/cypress/integration/control_dynamic_link.js +++ b/cypress/integration/control_dynamic_link.js @@ -62,7 +62,9 @@ context('Dynamic Link', () => { "label": "Document ID", "fieldname": "doc_id", "fieldtype": "Dynamic Link", - "get_options": () => { return "User"; }, + "get_options": () => { + return "User"; + }, "in_list_view": 1, }] });