From a6b1dffac969221042edfcfc2bf36c2acaec91c4 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:07:57 +0530 Subject: [PATCH 01/15] test for contact form --- .../site/components/com_contact/Form.cy.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/System/integration/site/components/com_contact/Form.cy.js diff --git a/tests/System/integration/site/components/com_contact/Form.cy.js b/tests/System/integration/site/components/com_contact/Form.cy.js new file mode 100644 index 0000000000000..b6d3054506bfe --- /dev/null +++ b/tests/System/integration/site/components/com_contact/Form.cy.js @@ -0,0 +1,18 @@ +describe('Test that the Contact Form', () => { + it('can display a Contact Form', () => { + cy.task('queryDB', `SELECT id FROM #__users WHERE username = '${Cypress.env('username')}'`) + .then((id) => { + cy.db_createContact({ name: 'contact 1', user_id: id[0].id }) + .then(() => cy.db_createMenuItem({ title: 'automated test', link: 'index.php?option=com_contact&view=category&id=4', path: '?option=com_contact&view=category&id=4' })) + .then(() => { + cy.visit('/'); + cy.get('a:contains(automated test)').click(); + cy.get('a:contains(automated test)').click(); + cy.get('a:contains(contact 1)').click(); + + cy.contains('Contact Form'); + cy.get('.m-0').should('exist'); + }); + }); + }); +}); From bf22118524b3cceec33b3684f3d64aea8cdedec5 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:56:45 +0530 Subject: [PATCH 02/15] updates --- tests/System/integration/site/components/com_contact/Form.cy.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/System/integration/site/components/com_contact/Form.cy.js b/tests/System/integration/site/components/com_contact/Form.cy.js index b6d3054506bfe..696b72a4ec438 100644 --- a/tests/System/integration/site/components/com_contact/Form.cy.js +++ b/tests/System/integration/site/components/com_contact/Form.cy.js @@ -7,7 +7,6 @@ describe('Test that the Contact Form', () => { .then(() => { cy.visit('/'); cy.get('a:contains(automated test)').click(); - cy.get('a:contains(automated test)').click(); cy.get('a:contains(contact 1)').click(); cy.contains('Contact Form'); From d5a546ea737c670fb31fd19c3294e2967c2982c0 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:54:40 +0530 Subject: [PATCH 03/15] updates --- .../site/components/com_contact/Form.cy.js | 23 +++++++++---------- tests/System/support/commands/db.js | 8 +++++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/System/integration/site/components/com_contact/Form.cy.js b/tests/System/integration/site/components/com_contact/Form.cy.js index 696b72a4ec438..8a5c15eea2177 100644 --- a/tests/System/integration/site/components/com_contact/Form.cy.js +++ b/tests/System/integration/site/components/com_contact/Form.cy.js @@ -1,17 +1,16 @@ describe('Test that the Contact Form', () => { it('can display a Contact Form', () => { - cy.task('queryDB', `SELECT id FROM #__users WHERE username = '${Cypress.env('username')}'`) - .then((id) => { - cy.db_createContact({ name: 'contact 1', user_id: id[0].id }) - .then(() => cy.db_createMenuItem({ title: 'automated test', link: 'index.php?option=com_contact&view=category&id=4', path: '?option=com_contact&view=category&id=4' })) - .then(() => { - cy.visit('/'); - cy.get('a:contains(automated test)').click(); - cy.get('a:contains(contact 1)').click(); + cy.db_getUserId().then((id) => { + cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }) + .then(() => { + cy.task('queryDB', 'SELECT id FROM #__contact_details WHERE name = \'contact 1\'') + .then(async (contactId) => { + cy.visit(`index.php?option=com_contact&view=contact&id='${contactId[0].id}'`); + }); - cy.contains('Contact Form'); - cy.get('.m-0').should('exist'); - }); - }); + cy.contains('Contact Form'); + cy.get('.m-0').should('exist'); + }); + }); }); }); diff --git a/tests/System/support/commands/db.js b/tests/System/support/commands/db.js index 8cc06dc1d7514..8177d2d63d9cf 100644 --- a/tests/System/support/commands/db.js +++ b/tests/System/support/commands/db.js @@ -142,3 +142,11 @@ Cypress.Commands.add('db_createUser', (userData) => { return info.insertId; }); }); + +Cypress.Commands.add('db_getUserId',()=>{ + cy.task('queryDB', `SELECT id FROM #__users WHERE username = '${Cypress.env('username')}'`) + .then(async (id) => { + + return cy.wrap(id[0].id); + }); +}) \ No newline at end of file From 9584c38e553fb56493f8398a76e3933e7069cfc7 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:59:26 +0530 Subject: [PATCH 04/15] add a blank line at last --- tests/System/support/commands/db.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/System/support/commands/db.js b/tests/System/support/commands/db.js index 8177d2d63d9cf..88cd298e519f5 100644 --- a/tests/System/support/commands/db.js +++ b/tests/System/support/commands/db.js @@ -149,4 +149,4 @@ Cypress.Commands.add('db_getUserId',()=>{ return cy.wrap(id[0].id); }); -}) \ No newline at end of file +}) From 438672897434722862ef4a946e05b74af399e02d Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 00:43:45 +0530 Subject: [PATCH 05/15] updates --- tests/System/support/commands/db.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/System/support/commands/db.js b/tests/System/support/commands/db.js index 88cd298e519f5..9d5e6567521f4 100644 --- a/tests/System/support/commands/db.js +++ b/tests/System/support/commands/db.js @@ -143,10 +143,10 @@ Cypress.Commands.add('db_createUser', (userData) => { }); }); -Cypress.Commands.add('db_getUserId',()=>{ +Cypress.Commands.add('db_getUserId', () => { cy.task('queryDB', `SELECT id FROM #__users WHERE username = '${Cypress.env('username')}'`) - .then(async (id) => { - + .then(async (id) => { + return cy.wrap(id[0].id); - }); -}) + }); +}); From 9039994740eaa3634565f416a5c1e3baf63a85a7 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 17:06:25 +0530 Subject: [PATCH 06/15] updates --- .../integration/site/components/com_contact/Form.cy.js | 9 +++------ tests/System/support/commands/db.js | 10 ++++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/System/integration/site/components/com_contact/Form.cy.js b/tests/System/integration/site/components/com_contact/Form.cy.js index 8a5c15eea2177..b2fbab83e352f 100644 --- a/tests/System/integration/site/components/com_contact/Form.cy.js +++ b/tests/System/integration/site/components/com_contact/Form.cy.js @@ -2,12 +2,9 @@ describe('Test that the Contact Form', () => { it('can display a Contact Form', () => { cy.db_getUserId().then((id) => { cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }) - .then(() => { - cy.task('queryDB', 'SELECT id FROM #__contact_details WHERE name = \'contact 1\'') - .then(async (contactId) => { - cy.visit(`index.php?option=com_contact&view=contact&id='${contactId[0].id}'`); - }); - + .then((id) => { + cy.visit(`index.php?option=com_contact&view=contact&id='${id}'`); + cy.contains('Contact Form'); cy.get('.m-0').should('exist'); }); diff --git a/tests/System/support/commands/db.js b/tests/System/support/commands/db.js index 9d5e6567521f4..cc94106c6b7f4 100644 --- a/tests/System/support/commands/db.js +++ b/tests/System/support/commands/db.js @@ -145,8 +145,10 @@ Cypress.Commands.add('db_createUser', (userData) => { Cypress.Commands.add('db_getUserId', () => { cy.task('queryDB', `SELECT id FROM #__users WHERE username = '${Cypress.env('username')}'`) - .then(async (id) => { - - return cy.wrap(id[0].id); + .then((id) => { + if (id.length===0) { + return 0; + } + return id[0].id; }); -}); +}); \ No newline at end of file From 9138ade9f6137fa382a8ff88c925a350ba8e2671 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 18:38:07 +0530 Subject: [PATCH 07/15] updates --- .../System/integration/site/components/com_contact/Form.cy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/System/integration/site/components/com_contact/Form.cy.js b/tests/System/integration/site/components/com_contact/Form.cy.js index b2fbab83e352f..103cbbea2e11f 100644 --- a/tests/System/integration/site/components/com_contact/Form.cy.js +++ b/tests/System/integration/site/components/com_contact/Form.cy.js @@ -2,8 +2,8 @@ describe('Test that the Contact Form', () => { it('can display a Contact Form', () => { cy.db_getUserId().then((id) => { cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }) - .then((id) => { - cy.visit(`index.php?option=com_contact&view=contact&id='${id}'`); + .then((ContactId) => { + cy.visit(`index.php?option=com_contact&view=contact&id='${ContactId}'`); cy.contains('Contact Form'); cy.get('.m-0').should('exist'); From f89fe6d6320ea8c79ec02dc89485f96f7a9c92b5 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 19:19:14 +0530 Subject: [PATCH 08/15] updates --- tests/System/integration/site/components/com_contact/Form.cy.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/System/integration/site/components/com_contact/Form.cy.js b/tests/System/integration/site/components/com_contact/Form.cy.js index 103cbbea2e11f..28d2212bec812 100644 --- a/tests/System/integration/site/components/com_contact/Form.cy.js +++ b/tests/System/integration/site/components/com_contact/Form.cy.js @@ -4,7 +4,6 @@ describe('Test that the Contact Form', () => { cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }) .then((ContactId) => { cy.visit(`index.php?option=com_contact&view=contact&id='${ContactId}'`); - cy.contains('Contact Form'); cy.get('.m-0').should('exist'); }); From e417d655a6018ca4444287fc139505573cef2c6e Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 19:44:03 +0530 Subject: [PATCH 09/15] adding endline --- tests/System/support/commands/db.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/System/support/commands/db.js b/tests/System/support/commands/db.js index cc94106c6b7f4..3f03c65054a3f 100644 --- a/tests/System/support/commands/db.js +++ b/tests/System/support/commands/db.js @@ -146,9 +146,9 @@ Cypress.Commands.add('db_createUser', (userData) => { Cypress.Commands.add('db_getUserId', () => { cy.task('queryDB', `SELECT id FROM #__users WHERE username = '${Cypress.env('username')}'`) .then((id) => { - if (id.length===0) { + if (id.length === 0) { return 0; } return id[0].id; }); -}); \ No newline at end of file +}); From b4e98a5476188924602881dd1f1e528dd98265ea Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 21:01:33 +0530 Subject: [PATCH 10/15] Update and rename Form.cy.js to contact_details_page.cy.js --- .../com_contact/{Form.cy.js => contact_details_page.cy.js} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename tests/System/integration/site/components/com_contact/{Form.cy.js => contact_details_page.cy.js} (88%) diff --git a/tests/System/integration/site/components/com_contact/Form.cy.js b/tests/System/integration/site/components/com_contact/contact_details_page.cy.js similarity index 88% rename from tests/System/integration/site/components/com_contact/Form.cy.js rename to tests/System/integration/site/components/com_contact/contact_details_page.cy.js index 28d2212bec812..3291ea0ec27b8 100644 --- a/tests/System/integration/site/components/com_contact/Form.cy.js +++ b/tests/System/integration/site/components/com_contact/contact_details_page.cy.js @@ -2,8 +2,8 @@ describe('Test that the Contact Form', () => { it('can display a Contact Form', () => { cy.db_getUserId().then((id) => { cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }) - .then((ContactId) => { - cy.visit(`index.php?option=com_contact&view=contact&id='${ContactId}'`); + .then((contactId) => { + cy.visit(`index.php?option=com_contact&view=contact&id='${contactId}'`); cy.contains('Contact Form'); cy.get('.m-0').should('exist'); }); From 32b908dc0beb35106f084cde645b38bfb52903ab Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 21:13:59 +0530 Subject: [PATCH 11/15] Rename contact_details_page.cy.js to Contact.cy.js --- .../com_contact/{contact_details_page.cy.js => Contact.cy.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/System/integration/site/components/com_contact/{contact_details_page.cy.js => Contact.cy.js} (100%) diff --git a/tests/System/integration/site/components/com_contact/contact_details_page.cy.js b/tests/System/integration/site/components/com_contact/Contact.cy.js similarity index 100% rename from tests/System/integration/site/components/com_contact/contact_details_page.cy.js rename to tests/System/integration/site/components/com_contact/Contact.cy.js From 229c129936487410b9eaf381004bc055774f2a40 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 23:04:29 +0530 Subject: [PATCH 12/15] Update Contact.cy.js --- .../site/components/com_contact/Contact.cy.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/System/integration/site/components/com_contact/Contact.cy.js b/tests/System/integration/site/components/com_contact/Contact.cy.js index 3291ea0ec27b8..825b30f49bf3a 100644 --- a/tests/System/integration/site/components/com_contact/Contact.cy.js +++ b/tests/System/integration/site/components/com_contact/Contact.cy.js @@ -1,12 +1,12 @@ describe('Test that the Contact Form', () => { it('can display a Contact Form', () => { cy.db_getUserId().then((id) => { - cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }) - .then((contactId) => { - cy.visit(`index.php?option=com_contact&view=contact&id='${contactId}'`); - cy.contains('Contact Form'); - cy.get('.m-0').should('exist'); - }); + cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }); + }).then((ContactId) => { + cy.visit(`index.php?option=com_contact&view=contact&id='${ContactId}'`); + + cy.contains('Contact Form'); + cy.get('.m-0').should('exist'); }); }); }); From 59d36086a6537a78b8d29b7302bbc0bd45bb6cf8 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 23:05:00 +0530 Subject: [PATCH 13/15] Update Contact.cy.js --- .../integration/site/components/com_contact/Contact.cy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/System/integration/site/components/com_contact/Contact.cy.js b/tests/System/integration/site/components/com_contact/Contact.cy.js index 825b30f49bf3a..419ab39d9e01c 100644 --- a/tests/System/integration/site/components/com_contact/Contact.cy.js +++ b/tests/System/integration/site/components/com_contact/Contact.cy.js @@ -2,8 +2,8 @@ describe('Test that the Contact Form', () => { it('can display a Contact Form', () => { cy.db_getUserId().then((id) => { cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }); - }).then((ContactId) => { - cy.visit(`index.php?option=com_contact&view=contact&id='${ContactId}'`); + }).then((contactId) => { + cy.visit(`index.php?option=com_contact&view=contact&id='${contactId}'`); cy.contains('Contact Form'); cy.get('.m-0').should('exist'); From c6773e3214ad8598956ef69d24ca3e546d3c5a6c Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 23:34:01 +0530 Subject: [PATCH 14/15] Update Contact.cy.js --- .../site/components/com_contact/Contact.cy.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/System/integration/site/components/com_contact/Contact.cy.js b/tests/System/integration/site/components/com_contact/Contact.cy.js index 419ab39d9e01c..7951ecdc03f24 100644 --- a/tests/System/integration/site/components/com_contact/Contact.cy.js +++ b/tests/System/integration/site/components/com_contact/Contact.cy.js @@ -1,12 +1,11 @@ describe('Test that the Contact Form', () => { it('can display a Contact Form', () => { - cy.db_getUserId().then((id) => { - cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 }); - }).then((contactId) => { - cy.visit(`index.php?option=com_contact&view=contact&id='${contactId}'`); + cy.db_getUserId().then((id) => cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 })) + .then((contactId) => { + cy.visit(`index.php?option=com_contact&view=contact&id='${contactId}'`); - cy.contains('Contact Form'); - cy.get('.m-0').should('exist'); - }); + cy.contains('Contact Form'); + cy.get('.m-0').should('exist'); + }); }); }); From 9748cbd5893ce7954dcee184749604bcc0df6810 Mon Sep 17 00:00:00 2001 From: rajputanuj31 <115709571+rajputanuj31@users.noreply.github.com> Date: Thu, 23 Mar 2023 23:38:49 +0530 Subject: [PATCH 15/15] Update Contact.cy.js --- .../integration/site/components/com_contact/Contact.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/System/integration/site/components/com_contact/Contact.cy.js b/tests/System/integration/site/components/com_contact/Contact.cy.js index 7951ecdc03f24..e48649bcf17f8 100644 --- a/tests/System/integration/site/components/com_contact/Contact.cy.js +++ b/tests/System/integration/site/components/com_contact/Contact.cy.js @@ -1,6 +1,6 @@ describe('Test that the Contact Form', () => { it('can display a Contact Form', () => { - cy.db_getUserId().then((id) => cy.db_createContact({ name: 'contact 1', user_id: id, featured: 1 })) + cy.db_getUserId().then((id) => cy.db_createContact({ name: 'contact 1', user_id: id })) .then((contactId) => { cy.visit(`index.php?option=com_contact&view=contact&id='${contactId}'`);