From 1cf8c79d635216aa2314df6c4e350ec622437379 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 12 Aug 2024 13:22:43 +0300 Subject: [PATCH 01/42] chore: removes sample spec --- cypress/e2e/sample_spec.js | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 cypress/e2e/sample_spec.js diff --git a/cypress/e2e/sample_spec.js b/cypress/e2e/sample_spec.js deleted file mode 100644 index 96d52d507..000000000 --- a/cypress/e2e/sample_spec.js +++ /dev/null @@ -1,16 +0,0 @@ -describe('Home page', function() { - it('Visits the home page', function() { - cy.visit('/') - }) -}) - -describe('Log in as admin', function() { - it('Goes to login page, logs in with default creds, and should redirect to index', function() { - cy.visit('/auth/?next=/index.htm') - - cy.get('.input-group > .floating-label-group > input[name="username"].form-control').type(`admin{enter}`) - cy.get('.input-group > .floating-label-group > input[name="password"].form-control').type(`admin{enter}`) - - cy.url().should("include", "/index.htm") // redirected back to home page - }) -}) From c26d739ef9ab7eadd1430be4a35a56c3441ce220 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 12 Aug 2024 13:24:17 +0300 Subject: [PATCH 02/42] fix: retuns false on uncaught exepction Also changes the url to the full localhost url. This is done so the tests can actually get to the point where they run as uncaught issues were otherwise blocking them before they even got started. We can debug this later --- cypress/support/commands.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 8733629d8..617fa3006 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -16,11 +16,14 @@ // -- This is a child command -- // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) - Cypress.Commands.add("login", () => { - cy.visit('/auth/?next=/index.htm'); + cy.visit('localhost:8000/auth/?next=/index.htm'); cy.get('.input-group > .floating-label-group > input[name="username"].form-control').type(`admin{enter}`); cy.get('.input-group > .floating-label-group > input[name="password"].form-control').type(`admin{enter}`); - }); + +Cypress.on('uncaught:exception', (err, runnable) => { + // returning false here prevents Cypress from failing the test temporary solution but we could log here and debug the uncaught issues + return false +}) From bf265a729ab3609cc337c17455f1eb69df051706 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 12 Aug 2024 13:26:17 +0300 Subject: [PATCH 03/42] wip: feat: adds flag for enforcement workflow test --- .../e2e/flag_for_enforcement_workflow.cy.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cypress/e2e/flag_for_enforcement_workflow.cy.js diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js new file mode 100644 index 000000000..ff1fc80d3 --- /dev/null +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -0,0 +1,26 @@ +describe('Going through the Flag For Enforcement Workflow', function () { + + beforeEach(() => { + cy.login() + cy.visit("http://localhost:8000/plugins/init-workflow") + }) + + it('Go through the workflow', function () { + cy.contains("Workflows"); + cy.contains("Flag for Enforcement").click(); + // Starting the workflow + cy.contains("Save and Continue").click(); + cy.wait(5000); + cy.get('[aria-label="Case Reference"]').should('be.visible').click().type('Case Ref'); + // cy.get('#cke_2_contents > .cke_wysiwyg_frame').click().type('test'); + // cy.wait(5000); + // cy.get('[aria-label="Subtitle"]').should('be.visible').click().type('Subtitle'); + // cy.get('[aria-label="File ID (key)"]').should('be.visible').click().type('File ID (key)'); + // cy.get('#cke_2_contents').click().type('test type ref'); + cy.contains("Save and Continue").click(); + // cy.get('[aria-label="Flagged by"]').should('be.visible').click().type('Case Ref'); + // cy.get('.card_component.full_name > .row > .form-group > [style="max-width: 600px; position: relative"] > .col-xs-12 > .form-control').type('Test'); + // cy.get(':nth-child(2) > .card-component > .new-provisional-edit-card-container > .card > .install-buttons > .fa-plus > span').click(); + // cy.get('.close-new-step > .btn > span').click(); + }) +}) From b8a6e3acfd78987e8273a43c32b6ddd355d2dd95 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 12 Aug 2024 14:43:44 +0300 Subject: [PATCH 04/42] wip: feat: selects first option in dropdown --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index ff1fc80d3..d370f37cb 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -10,17 +10,10 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains("Flag for Enforcement").click(); // Starting the workflow cy.contains("Save and Continue").click(); - cy.wait(5000); - cy.get('[aria-label="Case Reference"]').should('be.visible').click().type('Case Ref'); - // cy.get('#cke_2_contents > .cke_wysiwyg_frame').click().type('test'); - // cy.wait(5000); - // cy.get('[aria-label="Subtitle"]').should('be.visible').click().type('Subtitle'); - // cy.get('[aria-label="File ID (key)"]').should('be.visible').click().type('File ID (key)'); - // cy.get('#cke_2_contents').click().type('test type ref'); - cy.contains("Save and Continue").click(); - // cy.get('[aria-label="Flagged by"]').should('be.visible').click().type('Case Ref'); - // cy.get('.card_component.full_name > .row > .form-group > [style="max-width: 600px; position: relative"] > .col-xs-12 > .form-control').type('Test'); - // cy.get(':nth-child(2) > .card-component > .new-provisional-edit-card-container > .card > .install-buttons > .fa-plus > span').click(); - // cy.get('.close-new-step > .btn > span').click(); + cy.wait(2000); + cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); + cy.contains("Flagged by").siblings('.row').click(); + // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name + cy.get('.select2-results__options li').first().click(); }) }) From d33cbcacbd0907c7b85706d8aff541dc38d96dea Mon Sep 17 00:00:00 2001 From: Andrea K Date: Wed, 14 Aug 2024 14:20:07 +0300 Subject: [PATCH 05/42] refactor: changes double quotes to single quotes --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index d370f37cb..1473c6043 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -2,18 +2,22 @@ describe('Going through the Flag For Enforcement Workflow', function () { beforeEach(() => { cy.login() - cy.visit("http://localhost:8000/plugins/init-workflow") + cy.visit('http://localhost:8000/plugins/init-workflow') }) it('Go through the workflow', function () { - cy.contains("Workflows"); - cy.contains("Flag for Enforcement").click(); + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); // Starting the workflow - cy.contains("Save and Continue").click(); + cy.contains('Save and Continue').click(); cy.wait(2000); cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); - cy.contains("Flagged by").siblings('.row').click(); + cy.contains('Flagged by').siblings('.row').click(); // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name cy.get('.select2-results__options li').first().click(); + cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); }) }) From 057485fb668c7ee49256e385ed36b3507944697f Mon Sep 17 00:00:00 2001 From: Andrea K Date: Wed, 14 Aug 2024 17:28:29 +0300 Subject: [PATCH 06/42] feat: adds a cypress command that allows editing rich textboxes --- cypress/support/commands.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 617fa3006..fe709c047 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -26,4 +26,13 @@ Cypress.Commands.add("login", () => { Cypress.on('uncaught:exception', (err, runnable) => { // returning false here prevents Cypress from failing the test temporary solution but we could log here and debug the uncaught issues return false -}) +}); + +Cypress.Commands.add("type_ckeditor", (element, content) => { + cy.window().then(win => { + // uncomment this to find the actual instance name you need + // console.log(win.CKEDITOR.instances); + win.CKEDITOR.instances[element].setData(content); + }); +}); + \ No newline at end of file From 22eca490f80b2e787833beaafc31e84f75effb6c Mon Sep 17 00:00:00 2001 From: Andrea K Date: Wed, 14 Aug 2024 17:32:37 +0300 Subject: [PATCH 07/42] test: adds to the ffe workflow --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index 1473c6043..5d1b55c24 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -15,9 +15,19 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Continue').click(); cy.wait(2000); cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); + cy.type_ckeditor('editor2', 'test reason for enforcement'); cy.contains('Flagged by').siblings('.row').click(); // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name + // TODO test with organisation as well cy.get('.select2-results__options li').first().click(); cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); + cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); + cy.contains('Select resources').siblings('.row').click(); + // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name + cy.get('.select2-results__options li').first().click(); + cy.contains('Save and Continue').click(); + cy.wait(2000); + // TODO check that information that was entered corresponds + cy.contains('Save and Complete Workflow').click(); }) }) From 13299f9887f718bfe53ca041de67b688e8bbf036 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Wed, 14 Aug 2024 17:33:19 +0300 Subject: [PATCH 08/42] chore: adds cypress gitignore Ignores videos and screenshots generated from cypress studio --- cypress/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cypress/.gitignore diff --git a/cypress/.gitignore b/cypress/.gitignore new file mode 100644 index 000000000..968e508e3 --- /dev/null +++ b/cypress/.gitignore @@ -0,0 +1,2 @@ +/videos +/screenshots \ No newline at end of file From b17da75cef7b98ab9a8619494380383cf00bb6a5 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 11:23:40 +0300 Subject: [PATCH 09/42] test: check all populated fields and go through workflow with just id --- .../e2e/flag_for_enforcement_workflow.cy.js | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index 5d1b55c24..3d99a2d7e 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -3,9 +3,9 @@ describe('Going through the Flag For Enforcement Workflow', function () { beforeEach(() => { cy.login() cy.visit('http://localhost:8000/plugins/init-workflow') - }) + }); - it('Go through the workflow', function () { + it('Go through the workflow and populate all fields', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); // Makes sure the autogenerated id is not undefined @@ -26,8 +26,30 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); + cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement'); + // Only checks if the date we selected is present as the year and month could change + cy.contains('Flagged Date Value:').siblings().should('contain', '17'); + // TODO actually create the person and use the name in the check here + cy.contains('Actor:').siblings().should('have.text', 'test'); cy.wait(2000); - // TODO check that information that was entered corresponds cy.contains('Save and Complete Workflow').click(); - }) + }); + + it('Go through the workflow and only with Enforcement ID', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + // Starting the workflow + cy.contains('Save and Continue').click(); + cy.wait(2000); + cy.contains('Next Step').click(); + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('Save and Complete Workflow').click(); + }); + }) From 28561620677d02794bcf1ef63f8556d04baa28b3 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 11:27:22 +0300 Subject: [PATCH 10/42] test: adds test with only case reference Also adds comments and sections off different tabs in the code --- .../e2e/flag_for_enforcement_workflow.cy.js | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index 3d99a2d7e..df4bcb8aa 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -8,11 +8,14 @@ describe('Going through the Flag For Enforcement Workflow', function () { it('Go through the workflow and populate all fields', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); + + // Initial step tab // Makes sure the autogenerated id is not undefined cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - // Starting the workflow cy.contains('Save and Continue').click(); + + // Enforcement Details Tab cy.wait(2000); cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); cy.type_ckeditor('editor2', 'test reason for enforcement'); @@ -26,6 +29,8 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); + + // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); cy.contains('ResourceID:').siblings().should('not.have.text', ''); cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); @@ -38,18 +43,44 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Complete Workflow').click(); }); - it('Go through the workflow and only with Enforcement ID', function () { + it('Go through the workflow only with Enforcement ID', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); + + // Initial step tab // Makes sure the autogenerated id is not undefined cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - // Starting the workflow cy.contains('Save and Continue').click(); + + // Enforcement Details Tab cy.wait(2000); cy.contains('Next Step').click(); + + // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); cy.contains('Save and Complete Workflow').click(); }); + it('Go through the workflow and populate only Case Reference', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); + cy.contains('Save and Complete Workflow').click(); + }); }) From e87df40bb93ad487a5a5c6b0ccf7660545d629e9 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 11:59:10 +0300 Subject: [PATCH 11/42] test: adds tests for each field --- .../e2e/flag_for_enforcement_workflow.cy.js | 105 +++++++++++++++++- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index df4bcb8aa..9d597098c 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -39,11 +39,12 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Flagged Date Value:').siblings().should('contain', '17'); // TODO actually create the person and use the name in the check here cy.contains('Actor:').siblings().should('have.text', 'test'); + cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); cy.wait(2000); cy.contains('Save and Complete Workflow').click(); }); - it('Go through the workflow only with Enforcement ID', function () { + it('Workflow with only Enforcement ID', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); @@ -62,7 +63,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Complete Workflow').click(); }); - it('Go through the workflow and populate only Case Reference', function () { + it('Workflow with only Case Reference', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); @@ -83,4 +84,102 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); cy.contains('Save and Complete Workflow').click(); }); -}) + + it('Workflow with only Reason For Enforcement', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.type_ckeditor('editor2', 'test reason for enforcement'); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement'); + cy.contains('Save and Complete Workflow').click(); + }); + + it('Workflow with only Flagged By', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.contains('Flagged by').siblings('.row').click(); + // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name + // TODO test with organisation as well + cy.get('.select2-results__options li').first().click(); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + // TODO actually create the person and use the name in the check here + cy.contains('Actor:').siblings().should('have.text', 'test'); + cy.contains('Save and Complete Workflow').click(); + }); + + + it('Workflow with only Flagged Date', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); + cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + // Only checks if the date we selected is present as the year and month could change + cy.contains('Flagged Date Value:').siblings().should('contain', '17'); + cy.contains('Save and Complete Workflow').click(); + }); + + + it('Workflow with only Associated Resource', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.contains('Select resources').siblings('.row').click(); + // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name + cy.get('.select2-results__options li').first().click(); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); + cy.contains('Save and Complete Workflow').click(); + }); +}); From 4ebb3627319b4af1fc56be20cab26c78cf8e430e Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 12:16:38 +0300 Subject: [PATCH 12/42] test: fix flagged date selection --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index 9d597098c..fbf511b73 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -146,7 +146,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Enforcement Details Tab cy.wait(2000); - cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); + cy.get('[aria-label="Flagged Date"]').click(); cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); cy.contains('Save and Continue').click(); From 2f17e4b4576497a93ebb55683b69ec99d693bf9d Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 12:16:58 +0300 Subject: [PATCH 13/42] test: removes unnecessary next redirect --- cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index fe709c047..3214d2f20 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -17,7 +17,7 @@ // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) Cypress.Commands.add("login", () => { - cy.visit('localhost:8000/auth/?next=/index.htm'); + cy.visit('localhost:8000/auth/'); cy.get('.input-group > .floating-label-group > input[name="username"].form-control').type(`admin{enter}`); cy.get('.input-group > .floating-label-group > input[name="password"].form-control').type(`admin{enter}`); From 00620aabf89e1109091b19ce4367de710a0d134d Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 12 Aug 2024 13:22:43 +0300 Subject: [PATCH 14/42] chore: removes sample spec --- cypress/e2e/sample_spec.js | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 cypress/e2e/sample_spec.js diff --git a/cypress/e2e/sample_spec.js b/cypress/e2e/sample_spec.js deleted file mode 100644 index 96d52d507..000000000 --- a/cypress/e2e/sample_spec.js +++ /dev/null @@ -1,16 +0,0 @@ -describe('Home page', function() { - it('Visits the home page', function() { - cy.visit('/') - }) -}) - -describe('Log in as admin', function() { - it('Goes to login page, logs in with default creds, and should redirect to index', function() { - cy.visit('/auth/?next=/index.htm') - - cy.get('.input-group > .floating-label-group > input[name="username"].form-control').type(`admin{enter}`) - cy.get('.input-group > .floating-label-group > input[name="password"].form-control').type(`admin{enter}`) - - cy.url().should("include", "/index.htm") // redirected back to home page - }) -}) From 4a1a7f5c52b21c5a139b44a6f0373d716b296fc0 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 12 Aug 2024 13:24:17 +0300 Subject: [PATCH 15/42] fix: retuns false on uncaught exepction Also changes the url to the full localhost url. This is done so the tests can actually get to the point where they run as uncaught issues were otherwise blocking them before they even got started. We can debug this later --- cypress/support/commands.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 8733629d8..617fa3006 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -16,11 +16,14 @@ // -- This is a child command -- // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) - Cypress.Commands.add("login", () => { - cy.visit('/auth/?next=/index.htm'); + cy.visit('localhost:8000/auth/?next=/index.htm'); cy.get('.input-group > .floating-label-group > input[name="username"].form-control').type(`admin{enter}`); cy.get('.input-group > .floating-label-group > input[name="password"].form-control').type(`admin{enter}`); - }); + +Cypress.on('uncaught:exception', (err, runnable) => { + // returning false here prevents Cypress from failing the test temporary solution but we could log here and debug the uncaught issues + return false +}) From c168802d4a89f730262c9e49c2a5bfc72d580708 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 12 Aug 2024 13:26:17 +0300 Subject: [PATCH 16/42] wip: feat: adds flag for enforcement workflow test --- .../e2e/flag_for_enforcement_workflow.cy.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cypress/e2e/flag_for_enforcement_workflow.cy.js diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js new file mode 100644 index 000000000..ff1fc80d3 --- /dev/null +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -0,0 +1,26 @@ +describe('Going through the Flag For Enforcement Workflow', function () { + + beforeEach(() => { + cy.login() + cy.visit("http://localhost:8000/plugins/init-workflow") + }) + + it('Go through the workflow', function () { + cy.contains("Workflows"); + cy.contains("Flag for Enforcement").click(); + // Starting the workflow + cy.contains("Save and Continue").click(); + cy.wait(5000); + cy.get('[aria-label="Case Reference"]').should('be.visible').click().type('Case Ref'); + // cy.get('#cke_2_contents > .cke_wysiwyg_frame').click().type('test'); + // cy.wait(5000); + // cy.get('[aria-label="Subtitle"]').should('be.visible').click().type('Subtitle'); + // cy.get('[aria-label="File ID (key)"]').should('be.visible').click().type('File ID (key)'); + // cy.get('#cke_2_contents').click().type('test type ref'); + cy.contains("Save and Continue").click(); + // cy.get('[aria-label="Flagged by"]').should('be.visible').click().type('Case Ref'); + // cy.get('.card_component.full_name > .row > .form-group > [style="max-width: 600px; position: relative"] > .col-xs-12 > .form-control').type('Test'); + // cy.get(':nth-child(2) > .card-component > .new-provisional-edit-card-container > .card > .install-buttons > .fa-plus > span').click(); + // cy.get('.close-new-step > .btn > span').click(); + }) +}) From 839def5a399ead955a3a640f8b8e06c6e7a68ef1 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 12 Aug 2024 14:43:44 +0300 Subject: [PATCH 17/42] wip: feat: selects first option in dropdown --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index ff1fc80d3..d370f37cb 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -10,17 +10,10 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains("Flag for Enforcement").click(); // Starting the workflow cy.contains("Save and Continue").click(); - cy.wait(5000); - cy.get('[aria-label="Case Reference"]').should('be.visible').click().type('Case Ref'); - // cy.get('#cke_2_contents > .cke_wysiwyg_frame').click().type('test'); - // cy.wait(5000); - // cy.get('[aria-label="Subtitle"]').should('be.visible').click().type('Subtitle'); - // cy.get('[aria-label="File ID (key)"]').should('be.visible').click().type('File ID (key)'); - // cy.get('#cke_2_contents').click().type('test type ref'); - cy.contains("Save and Continue").click(); - // cy.get('[aria-label="Flagged by"]').should('be.visible').click().type('Case Ref'); - // cy.get('.card_component.full_name > .row > .form-group > [style="max-width: 600px; position: relative"] > .col-xs-12 > .form-control').type('Test'); - // cy.get(':nth-child(2) > .card-component > .new-provisional-edit-card-container > .card > .install-buttons > .fa-plus > span').click(); - // cy.get('.close-new-step > .btn > span').click(); + cy.wait(2000); + cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); + cy.contains("Flagged by").siblings('.row').click(); + // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name + cy.get('.select2-results__options li').first().click(); }) }) From e4387c336ef7a4293c6bcbabbbd54d82b8ab356b Mon Sep 17 00:00:00 2001 From: Andrea K Date: Wed, 14 Aug 2024 14:20:07 +0300 Subject: [PATCH 18/42] refactor: changes double quotes to single quotes --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index d370f37cb..1473c6043 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -2,18 +2,22 @@ describe('Going through the Flag For Enforcement Workflow', function () { beforeEach(() => { cy.login() - cy.visit("http://localhost:8000/plugins/init-workflow") + cy.visit('http://localhost:8000/plugins/init-workflow') }) it('Go through the workflow', function () { - cy.contains("Workflows"); - cy.contains("Flag for Enforcement").click(); + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); // Starting the workflow - cy.contains("Save and Continue").click(); + cy.contains('Save and Continue').click(); cy.wait(2000); cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); - cy.contains("Flagged by").siblings('.row').click(); + cy.contains('Flagged by').siblings('.row').click(); // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name cy.get('.select2-results__options li').first().click(); + cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); }) }) From 0b1391100b4a9d3127ed2e9676813623a13f0e21 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Wed, 14 Aug 2024 17:28:29 +0300 Subject: [PATCH 19/42] feat: adds a cypress command that allows editing rich textboxes --- cypress/support/commands.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 617fa3006..fe709c047 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -26,4 +26,13 @@ Cypress.Commands.add("login", () => { Cypress.on('uncaught:exception', (err, runnable) => { // returning false here prevents Cypress from failing the test temporary solution but we could log here and debug the uncaught issues return false -}) +}); + +Cypress.Commands.add("type_ckeditor", (element, content) => { + cy.window().then(win => { + // uncomment this to find the actual instance name you need + // console.log(win.CKEDITOR.instances); + win.CKEDITOR.instances[element].setData(content); + }); +}); + \ No newline at end of file From 7040fb61918f070e285cd426addfae73539cb141 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Wed, 14 Aug 2024 17:32:37 +0300 Subject: [PATCH 20/42] test: adds to the ffe workflow --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index 1473c6043..5d1b55c24 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -15,9 +15,19 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Continue').click(); cy.wait(2000); cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); + cy.type_ckeditor('editor2', 'test reason for enforcement'); cy.contains('Flagged by').siblings('.row').click(); // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name + // TODO test with organisation as well cy.get('.select2-results__options li').first().click(); cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); + cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); + cy.contains('Select resources').siblings('.row').click(); + // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name + cy.get('.select2-results__options li').first().click(); + cy.contains('Save and Continue').click(); + cy.wait(2000); + // TODO check that information that was entered corresponds + cy.contains('Save and Complete Workflow').click(); }) }) From dfad8f7cd4063f48e97b5199c450f8d71cebfa6b Mon Sep 17 00:00:00 2001 From: Andrea K Date: Wed, 14 Aug 2024 17:33:19 +0300 Subject: [PATCH 21/42] chore: adds cypress gitignore Ignores videos and screenshots generated from cypress studio --- cypress/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cypress/.gitignore diff --git a/cypress/.gitignore b/cypress/.gitignore new file mode 100644 index 000000000..968e508e3 --- /dev/null +++ b/cypress/.gitignore @@ -0,0 +1,2 @@ +/videos +/screenshots \ No newline at end of file From 89be1977f1ae9b0ae7ecc5bf8d0e45d18356751d Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 11:23:40 +0300 Subject: [PATCH 22/42] test: check all populated fields and go through workflow with just id --- .../e2e/flag_for_enforcement_workflow.cy.js | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index 5d1b55c24..3d99a2d7e 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -3,9 +3,9 @@ describe('Going through the Flag For Enforcement Workflow', function () { beforeEach(() => { cy.login() cy.visit('http://localhost:8000/plugins/init-workflow') - }) + }); - it('Go through the workflow', function () { + it('Go through the workflow and populate all fields', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); // Makes sure the autogenerated id is not undefined @@ -26,8 +26,30 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); + cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement'); + // Only checks if the date we selected is present as the year and month could change + cy.contains('Flagged Date Value:').siblings().should('contain', '17'); + // TODO actually create the person and use the name in the check here + cy.contains('Actor:').siblings().should('have.text', 'test'); cy.wait(2000); - // TODO check that information that was entered corresponds cy.contains('Save and Complete Workflow').click(); - }) + }); + + it('Go through the workflow and only with Enforcement ID', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + // Starting the workflow + cy.contains('Save and Continue').click(); + cy.wait(2000); + cy.contains('Next Step').click(); + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('Save and Complete Workflow').click(); + }); + }) From a057b03a1e9c449bcf85e3653bf1b581d18ae025 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 11:27:22 +0300 Subject: [PATCH 23/42] test: adds test with only case reference Also adds comments and sections off different tabs in the code --- .../e2e/flag_for_enforcement_workflow.cy.js | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index 3d99a2d7e..df4bcb8aa 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -8,11 +8,14 @@ describe('Going through the Flag For Enforcement Workflow', function () { it('Go through the workflow and populate all fields', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); + + // Initial step tab // Makes sure the autogenerated id is not undefined cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - // Starting the workflow cy.contains('Save and Continue').click(); + + // Enforcement Details Tab cy.wait(2000); cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); cy.type_ckeditor('editor2', 'test reason for enforcement'); @@ -26,6 +29,8 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); + + // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); cy.contains('ResourceID:').siblings().should('not.have.text', ''); cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); @@ -38,18 +43,44 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Complete Workflow').click(); }); - it('Go through the workflow and only with Enforcement ID', function () { + it('Go through the workflow only with Enforcement ID', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); + + // Initial step tab // Makes sure the autogenerated id is not undefined cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - // Starting the workflow cy.contains('Save and Continue').click(); + + // Enforcement Details Tab cy.wait(2000); cy.contains('Next Step').click(); + + // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); cy.contains('Save and Complete Workflow').click(); }); + it('Go through the workflow and populate only Case Reference', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); + cy.contains('Save and Complete Workflow').click(); + }); }) From 88afd82d4846bf3c42ca09ed1aa1078e2ffab9aa Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 11:59:10 +0300 Subject: [PATCH 24/42] test: adds tests for each field --- .../e2e/flag_for_enforcement_workflow.cy.js | 105 +++++++++++++++++- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index df4bcb8aa..9d597098c 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -39,11 +39,12 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Flagged Date Value:').siblings().should('contain', '17'); // TODO actually create the person and use the name in the check here cy.contains('Actor:').siblings().should('have.text', 'test'); + cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); cy.wait(2000); cy.contains('Save and Complete Workflow').click(); }); - it('Go through the workflow only with Enforcement ID', function () { + it('Workflow with only Enforcement ID', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); @@ -62,7 +63,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Complete Workflow').click(); }); - it('Go through the workflow and populate only Case Reference', function () { + it('Workflow with only Case Reference', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); @@ -83,4 +84,102 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); cy.contains('Save and Complete Workflow').click(); }); -}) + + it('Workflow with only Reason For Enforcement', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.type_ckeditor('editor2', 'test reason for enforcement'); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement'); + cy.contains('Save and Complete Workflow').click(); + }); + + it('Workflow with only Flagged By', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.contains('Flagged by').siblings('.row').click(); + // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name + // TODO test with organisation as well + cy.get('.select2-results__options li').first().click(); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + // TODO actually create the person and use the name in the check here + cy.contains('Actor:').siblings().should('have.text', 'test'); + cy.contains('Save and Complete Workflow').click(); + }); + + + it('Workflow with only Flagged Date', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); + cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + // Only checks if the date we selected is present as the year and month could change + cy.contains('Flagged Date Value:').siblings().should('contain', '17'); + cy.contains('Save and Complete Workflow').click(); + }); + + + it('Workflow with only Associated Resource', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(2000); + cy.contains('Select resources').siblings('.row').click(); + // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name + cy.get('.select2-results__options li').first().click(); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); + cy.contains('Save and Complete Workflow').click(); + }); +}); From 9e969a1146d0b77ee0a0cbcba539bd27be9819a6 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 12:16:38 +0300 Subject: [PATCH 25/42] test: fix flagged date selection --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index 9d597098c..fbf511b73 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -146,7 +146,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Enforcement Details Tab cy.wait(2000); - cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); + cy.get('[aria-label="Flagged Date"]').click(); cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); cy.contains('Save and Continue').click(); From 77f8667a3f4c3c38d3f1459144660b6608ab4701 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 12:16:58 +0300 Subject: [PATCH 26/42] test: removes unnecessary next redirect --- cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index fe709c047..3214d2f20 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -17,7 +17,7 @@ // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) Cypress.Commands.add("login", () => { - cy.visit('localhost:8000/auth/?next=/index.htm'); + cy.visit('localhost:8000/auth/'); cy.get('.input-group > .floating-label-group > input[name="username"].form-control').type(`admin{enter}`); cy.get('.input-group > .floating-label-group > input[name="password"].form-control').type(`admin{enter}`); From fdbfcb757cab23a7bb67828919b6c3a52d0e591d Mon Sep 17 00:00:00 2001 From: Andrea K Date: Thu, 15 Aug 2024 15:18:07 +0300 Subject: [PATCH 27/42] chore: removes spaces --- cypress/e2e/flag_for_enforcement_workflow.cy.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js index fbf511b73..236a59412 100644 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/flag_for_enforcement_workflow.cy.js @@ -133,7 +133,6 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Complete Workflow').click(); }); - it('Workflow with only Flagged Date', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); @@ -158,7 +157,6 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Complete Workflow').click(); }); - it('Workflow with only Associated Resource', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); From cc24d1b999dbf6e4ed4f6c42235946af1745ed6f Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 12:55:51 +0300 Subject: [PATCH 28/42] test: creates person to be used in tests also renames tests to run in order --- cypress/e2e/01_create_a_person_test.cy.js | 29 +++++++++++++++++++ ...=> 02_flag_for_enforcement_workflow.cy.js} | 0 2 files changed, 29 insertions(+) create mode 100644 cypress/e2e/01_create_a_person_test.cy.js rename cypress/e2e/{flag_for_enforcement_workflow.cy.js => 02_flag_for_enforcement_workflow.cy.js} (100%) diff --git a/cypress/e2e/01_create_a_person_test.cy.js b/cypress/e2e/01_create_a_person_test.cy.js new file mode 100644 index 000000000..ab6702cb9 --- /dev/null +++ b/cypress/e2e/01_create_a_person_test.cy.js @@ -0,0 +1,29 @@ +describe('Going through the Flag For Enforcement Workflow', function () { + + beforeEach(() => { + cy.login(); + cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&resource-type-filter=%5B%7B%22graphid%22%3A%2222477f01-1a44-11e9-b0a9-000d3ab1e588%22%2C%22name%22%3A%22Person%22%2C%22inverted%22%3Afalse%7D%5D'); + // cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&resource-type-filter=%5B%7B%22graphid%22%3A%22b9e0701e-5463-11e9-b5f5-000d3ab1e588%22%2C%22name%22%3A%22Activity%22%2C%22inverted%22%3Afalse%7D%5D'); + }); + + it('Create a person', function () { + cy.wait(5000).then(() => { + cy.get('#search-results-list').then(($el) => { + if ($el.find('.search-listing').length > 0) { + // A caveat to this is that it will only look at the first page (which shouldn't be a problem with a fresh instance) since the search was failing locally to find Test Person (probably a permissions issue as all objects were created as Provisional) + if (!$el.text().includes('Test Person')) { + cy.visit('http://localhost:8000/add-resource/22477f01-1a44-11e9-b0a9-000d3ab1e588') + cy.contains('Names').click(); + cy.get('[aria-label="Full Name"]').should('be.visible').type('Test Person'); + cy.get('button').contains('Add').click(); + } + } else { + cy.visit('http://localhost:8000/add-resource/22477f01-1a44-11e9-b0a9-000d3ab1e588') + cy.contains('Names').click(); + cy.get('[aria-label="Full Name"]').should('be.visible').type('Test Person'); + cy.get('button').contains('Add').click(); + } + }) + }); + }); +}); diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/02_flag_for_enforcement_workflow.cy.js similarity index 100% rename from cypress/e2e/flag_for_enforcement_workflow.cy.js rename to cypress/e2e/02_flag_for_enforcement_workflow.cy.js From a15b657dd3510c82bb1268223635f1ea5c4cfcc1 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 13:20:24 +0300 Subject: [PATCH 29/42] test: delete test since its been renamed --- .../e2e/flag_for_enforcement_workflow.cy.js | 185 ------------------ 1 file changed, 185 deletions(-) delete mode 100644 cypress/e2e/flag_for_enforcement_workflow.cy.js diff --git a/cypress/e2e/flag_for_enforcement_workflow.cy.js b/cypress/e2e/flag_for_enforcement_workflow.cy.js deleted file mode 100644 index fbf511b73..000000000 --- a/cypress/e2e/flag_for_enforcement_workflow.cy.js +++ /dev/null @@ -1,185 +0,0 @@ -describe('Going through the Flag For Enforcement Workflow', function () { - - beforeEach(() => { - cy.login() - cy.visit('http://localhost:8000/plugins/init-workflow') - }); - - it('Go through the workflow and populate all fields', function () { - cy.contains('Workflows'); - cy.contains('Flag for Enforcement').click(); - - // Initial step tab - // Makes sure the autogenerated id is not undefined - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - cy.contains('Save and Continue').click(); - - // Enforcement Details Tab - cy.wait(2000); - cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); - cy.type_ckeditor('editor2', 'test reason for enforcement'); - cy.contains('Flagged by').siblings('.row').click(); - // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name - // TODO test with organisation as well - cy.get('.select2-results__options li').first().click(); - cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); - cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); - cy.contains('Select resources').siblings('.row').click(); - // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name - cy.get('.select2-results__options li').first().click(); - cy.contains('Save and Continue').click(); - - // Enforcement Summary tab - cy.contains('ResourceID:').siblings().should('not.have.text'); - cy.contains('ResourceID:').siblings().should('not.have.text', ''); - cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); - cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement'); - // Only checks if the date we selected is present as the year and month could change - cy.contains('Flagged Date Value:').siblings().should('contain', '17'); - // TODO actually create the person and use the name in the check here - cy.contains('Actor:').siblings().should('have.text', 'test'); - cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); - cy.wait(2000); - cy.contains('Save and Complete Workflow').click(); - }); - - it('Workflow with only Enforcement ID', function () { - cy.contains('Workflows'); - cy.contains('Flag for Enforcement').click(); - - // Initial step tab - // Makes sure the autogenerated id is not undefined - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - cy.contains('Save and Continue').click(); - - // Enforcement Details Tab - cy.wait(2000); - cy.contains('Next Step').click(); - - // Enforcement Summary tab - cy.contains('ResourceID:').siblings().should('not.have.text'); - cy.contains('Save and Complete Workflow').click(); - }); - - it('Workflow with only Case Reference', function () { - cy.contains('Workflows'); - cy.contains('Flag for Enforcement').click(); - - // Initial step tab - // Makes sure the autogenerated id is not undefined - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - cy.contains('Save and Continue').click(); - - // Enforcement Details Tab - cy.wait(2000); - cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); - cy.contains('Save and Continue').click(); - - // Enforcement Summary tab - cy.contains('ResourceID:').siblings().should('not.have.text'); - cy.contains('ResourceID:').siblings().should('not.have.text', ''); - cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref'); - cy.contains('Save and Complete Workflow').click(); - }); - - it('Workflow with only Reason For Enforcement', function () { - cy.contains('Workflows'); - cy.contains('Flag for Enforcement').click(); - - // Initial step tab - // Makes sure the autogenerated id is not undefined - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - cy.contains('Save and Continue').click(); - - // Enforcement Details Tab - cy.wait(2000); - cy.type_ckeditor('editor2', 'test reason for enforcement'); - cy.contains('Save and Continue').click(); - - // Enforcement Summary tab - cy.contains('ResourceID:').siblings().should('not.have.text'); - cy.contains('ResourceID:').siblings().should('not.have.text', ''); - cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement'); - cy.contains('Save and Complete Workflow').click(); - }); - - it('Workflow with only Flagged By', function () { - cy.contains('Workflows'); - cy.contains('Flag for Enforcement').click(); - - // Initial step tab - // Makes sure the autogenerated id is not undefined - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - cy.contains('Save and Continue').click(); - - // Enforcement Details Tab - cy.wait(2000); - cy.contains('Flagged by').siblings('.row').click(); - // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name - // TODO test with organisation as well - cy.get('.select2-results__options li').first().click(); - cy.contains('Save and Continue').click(); - - // Enforcement Summary tab - cy.contains('ResourceID:').siblings().should('not.have.text'); - cy.contains('ResourceID:').siblings().should('not.have.text', ''); - // TODO actually create the person and use the name in the check here - cy.contains('Actor:').siblings().should('have.text', 'test'); - cy.contains('Save and Complete Workflow').click(); - }); - - - it('Workflow with only Flagged Date', function () { - cy.contains('Workflows'); - cy.contains('Flag for Enforcement').click(); - - // Initial step tab - // Makes sure the autogenerated id is not undefined - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - cy.contains('Save and Continue').click(); - - // Enforcement Details Tab - cy.wait(2000); - cy.get('[aria-label="Flagged Date"]').click(); - cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); - cy.contains('Save and Continue').click(); - - // Enforcement Summary tab - cy.contains('ResourceID:').siblings().should('not.have.text'); - cy.contains('ResourceID:').siblings().should('not.have.text', ''); - // Only checks if the date we selected is present as the year and month could change - cy.contains('Flagged Date Value:').siblings().should('contain', '17'); - cy.contains('Save and Complete Workflow').click(); - }); - - - it('Workflow with only Associated Resource', function () { - cy.contains('Workflows'); - cy.contains('Flag for Enforcement').click(); - - // Initial step tab - // Makes sure the autogenerated id is not undefined - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); - cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); - cy.contains('Save and Continue').click(); - - // Enforcement Details Tab - cy.wait(2000); - cy.contains('Select resources').siblings('.row').click(); - // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name - cy.get('.select2-results__options li').first().click(); - cy.contains('Save and Continue').click(); - - // Enforcement Summary tab - cy.contains('ResourceID:').siblings().should('not.have.text'); - cy.contains('ResourceID:').siblings().should('not.have.text', ''); - cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); - cy.contains('Save and Complete Workflow').click(); - }); -}); From 5d594f2e8c267baecea240c81355fdd4e4d5bca8 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 13:38:52 +0300 Subject: [PATCH 30/42] test: adds create heritage asset test also renames tests --- ...son_test.cy.js => 01_create_a_person.cy.js} | 3 +-- cypress/e2e/02_create_a_heritage_asset.cy.js | 18 ++++++++++++++++++ ... => 03_flag_for_enforcement_workflow.cy.js} | 6 ++---- 3 files changed, 21 insertions(+), 6 deletions(-) rename cypress/e2e/{01_create_a_person_test.cy.js => 01_create_a_person.cy.js} (95%) create mode 100644 cypress/e2e/02_create_a_heritage_asset.cy.js rename cypress/e2e/{02_flag_for_enforcement_workflow.cy.js => 03_flag_for_enforcement_workflow.cy.js} (96%) diff --git a/cypress/e2e/01_create_a_person_test.cy.js b/cypress/e2e/01_create_a_person.cy.js similarity index 95% rename from cypress/e2e/01_create_a_person_test.cy.js rename to cypress/e2e/01_create_a_person.cy.js index ab6702cb9..9e539ada4 100644 --- a/cypress/e2e/01_create_a_person_test.cy.js +++ b/cypress/e2e/01_create_a_person.cy.js @@ -1,5 +1,4 @@ -describe('Going through the Flag For Enforcement Workflow', function () { - +describe('Creating a person named Test Person if one doesnt exist', function () { beforeEach(() => { cy.login(); cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&resource-type-filter=%5B%7B%22graphid%22%3A%2222477f01-1a44-11e9-b0a9-000d3ab1e588%22%2C%22name%22%3A%22Person%22%2C%22inverted%22%3Afalse%7D%5D'); diff --git a/cypress/e2e/02_create_a_heritage_asset.cy.js b/cypress/e2e/02_create_a_heritage_asset.cy.js new file mode 100644 index 000000000..424bcd8c5 --- /dev/null +++ b/cypress/e2e/02_create_a_heritage_asset.cy.js @@ -0,0 +1,18 @@ +describe('Creating a Heritage Asset if none exist', function () { + beforeEach(() => { + cy.login(); + cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&resource-type-filter=%5B%7B%22graphid%22%3A%22076f9381-7b00-11e9-8d6b-80000b44d1d9%22%2C%22name%22%3A%22Heritage%20Asset%22%2C%22inverted%22%3Afalse%7D%5D'); + }); + + it('Create a heritage asset', function () { + cy.wait(5000).then(() => { + cy.get('#search-results-list').then(($el) => { + if (!$el.find('.search-listing').length > 0) { + // If no Heritage Assets exist create an empty heritage asset + cy.visit('http://localhost:8000/add-resource/076f9381-7b00-11e9-8d6b-80000b44d1d9') + cy.get('button').contains('Add').click(); + }; + }) + }); + }); +}); diff --git a/cypress/e2e/02_flag_for_enforcement_workflow.cy.js b/cypress/e2e/03_flag_for_enforcement_workflow.cy.js similarity index 96% rename from cypress/e2e/02_flag_for_enforcement_workflow.cy.js rename to cypress/e2e/03_flag_for_enforcement_workflow.cy.js index 236a59412..c1005862d 100644 --- a/cypress/e2e/02_flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/03_flag_for_enforcement_workflow.cy.js @@ -37,8 +37,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement'); // Only checks if the date we selected is present as the year and month could change cy.contains('Flagged Date Value:').siblings().should('contain', '17'); - // TODO actually create the person and use the name in the check here - cy.contains('Actor:').siblings().should('have.text', 'test'); + cy.contains('Actor:').siblings().should('have.text', 'Test Person'); cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); cy.wait(2000); cy.contains('Save and Complete Workflow').click(); @@ -128,8 +127,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); cy.contains('ResourceID:').siblings().should('not.have.text', ''); - // TODO actually create the person and use the name in the check here - cy.contains('Actor:').siblings().should('have.text', 'test'); + cy.contains('Actor:').siblings().should('have.text', 'Test Person'); cy.contains('Save and Complete Workflow').click(); }); From 0e9a9a53bae7e542efa39f7983ca052ce1a4b8fe Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 13:45:44 +0300 Subject: [PATCH 31/42] test: adds commented search for the created person --- cypress/e2e/03_flag_for_enforcement_workflow.cy.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cypress/e2e/03_flag_for_enforcement_workflow.cy.js b/cypress/e2e/03_flag_for_enforcement_workflow.cy.js index c1005862d..5f000a424 100644 --- a/cypress/e2e/03_flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/03_flag_for_enforcement_workflow.cy.js @@ -22,6 +22,8 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Flagged by').siblings('.row').click(); // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name // TODO test with organisation as well + // Commented out for now as search seems to be broken on local + // cy.get('.select2-search__field').type('Test Person'); cy.get('.select2-results__options li').first().click(); cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); @@ -121,12 +123,16 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Flagged by').siblings('.row').click(); // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name // TODO test with organisation as well + // Commented out for now as search seems to be broken on local + // cy.get('.select2-search__field').type('Test Person'); + cy.wait(5000); cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); cy.contains('ResourceID:').siblings().should('not.have.text', ''); + // TODO test with multiple people cy.contains('Actor:').siblings().should('have.text', 'Test Person'); cy.contains('Save and Complete Workflow').click(); }); From 39f0788e238ae1632fe7c733ef86662450414bb9 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 13:46:40 +0300 Subject: [PATCH 32/42] ops: uncomment the test step --- .github/workflows/project.yml | 208 +++++++++++++++++----------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 125357184..7dbb05e65 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -268,109 +268,109 @@ jobs: run: | name=${{ fromJSON(steps.buildx.outputs.metadata)['image.name'] }} echo "image_name=$name" | sed 's/,.*//g' >> $GITHUB_OUTPUT - # Test-Arches: - # runs-on: [self-hosted] - # needs: [Build-Arches-Final] - # container: - # image: cypress/included:12.3.0 - # env: - # HOME: "" - # DEBUG: "cypress:*" - # CYPRESS_BASE_URL: http://arches:8000 - # steps: - # - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - # - name: Check out repository code - # uses: actions/checkout@v3 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # submodules: 'true' - # - name: Cypress run - # uses: cypress-io/github-action@v4 - # with: - # browser: firefox - # install: false - # wait-on: 'http://arches:8000' - # wait-on-timeout: 6000 - # - uses: actions/upload-artifact@v3 - # if: failure() - # with: - # name: cypress-screenshots - # path: cypress/screenshots - # - uses: actions/upload-artifact@v3 - # if: always() - # with: - # name: cypress-videos - # path: cypress/videos - # services: - # elasticsearch: - # image: elasticsearch:8.4.0 - # ports: - # - "9200:9200" - # - "9300:9300" - # env: - # TZ: "PST" - # discovery.type: "single-node" - # discovery.seed_hosts: "[]" - # xpack.security.enabled: "false" - # ES_JAVA_OPTS: "-Xms400m -Xmx400m" - # options: >- - # --health-cmd "curl -s --fail http://localhost:9200/_cat/health || exit 1" - # --health-interval 10s - # --health-timeout 5s - # --health-retries 10 + Test-Arches: + runs-on: [self-hosted] + needs: [Build-Arches-Final] + container: + image: cypress/included:12.3.0 + env: + HOME: "" + DEBUG: "cypress:*" + CYPRESS_BASE_URL: http://arches:8000 + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - name: Check out repository code + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + submodules: 'true' + - name: Cypress run + uses: cypress-io/github-action@v4 + with: + browser: firefox + install: false + wait-on: 'http://arches:8000' + wait-on-timeout: 6000 + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: cypress-screenshots + path: cypress/screenshots + - uses: actions/upload-artifact@v3 + if: always() + with: + name: cypress-videos + path: cypress/videos + services: + elasticsearch: + image: elasticsearch:8.4.0 + ports: + - "9200:9200" + - "9300:9300" + env: + TZ: "PST" + discovery.type: "single-node" + discovery.seed_hosts: "[]" + xpack.security.enabled: "false" + ES_JAVA_OPTS: "-Xms400m -Xmx400m" + options: >- + --health-cmd "curl -s --fail http://localhost:9200/_cat/health || exit 1" + --health-interval 10s + --health-timeout 5s + --health-retries 10 - # db: - # image: flaxandteal/arches_coral_postgres - # #volumes: - # # - ${{ github.workspace }}/scripts/init-unix.sql:/docker-entrypoint-initdb.d/init.sql # to set up the DB template - # ports: - # - '5432:5432' - # env: - # POSTGRES_USER: postgres - # POSTGRES_PASS: postgres - # POSTGRES_DB: postgres - # POSTGRES_MULTIPLE_EXTENSIONS: postgis,postgis_topology - # TZ: PST - # options: >- - # --health-cmd "pg_isready -h 127.0.0.1 -U postgres -d postgres" - # --health-interval 10s - # --health-timeout 5s - # --health-retries 20 + db: + image: flaxandteal/arches_coral_postgres + #volumes: + # - ${{ github.workspace }}/scripts/init-unix.sql:/docker-entrypoint-initdb.d/init.sql # to set up the DB template + ports: + - '5432:5432' + env: + POSTGRES_USER: postgres + POSTGRES_PASS: postgres + POSTGRES_DB: postgres + POSTGRES_MULTIPLE_EXTENSIONS: postgis,postgis_topology + TZ: PST + options: >- + --health-cmd "pg_isready -h 127.0.0.1 -U postgres -d postgres" + --health-interval 10s + --health-timeout 5s + --health-retries 20 - # arches: - # image: "${{ needs['Build-Arches-Final'].outputs.image }}" - # env: - # ALLOW_BOOTSTRAP: "True" - # ARCHES_PROJECT: "${{ env.ARCHES_PROJECT }}" - # COMPRESS_OFFLINE: "False" - # INSTALL_CORAL_PACKAGE: "True" - # INSTALL_DEFAULT_GRAPHS: "False" - # INSTALL_DEFAULT_CONCEPTS: "False" - # PGUSERNAME: "postgres" - # PGPASSWORD: "postgres" - # PGDBNAME: "arches" - # PGHOST: "db" - # PGPORT: "5432" - # RABBITMQ_USER: "rabbitmq" - # RABBITMQ_PASS: "rabbitmq" - # CANTALOUPE_HOST: "cantaloupe" - # CANTALOUPE_PORT: "8182" - # COUCHDB_HOST: "couchdb" - # COUCHDB_PORT: "5984" - # COUCHDB_USER: "admin" - # COUCHDB_PASS: "password" - # ESHOST: "elasticsearch" - # ESPORT: "9200" - # CELERY_BROKER_URL: "amqp://rabbitmq" - # DJANGO_MODE: "PROD" - # DJANGO_DEBUG: "False" - # DOMAIN_NAMES: "arches" - # PYTHONUNBUFFERED: "0" - # TZ: "PST" - # ports: - # - '8000:8000' - # options: >- - # --health-cmd "curl --fail http://localhost:8000/templates/views/components/language-switcher.htm || exit 1" - # --health-interval 10s - # --health-timeout 5s - # --health-retries 1000 + arches: + image: "${{ needs['Build-Arches-Final'].outputs.image }}" + env: + ALLOW_BOOTSTRAP: "True" + ARCHES_PROJECT: "${{ env.ARCHES_PROJECT }}" + COMPRESS_OFFLINE: "False" + INSTALL_CORAL_PACKAGE: "True" + INSTALL_DEFAULT_GRAPHS: "False" + INSTALL_DEFAULT_CONCEPTS: "False" + PGUSERNAME: "postgres" + PGPASSWORD: "postgres" + PGDBNAME: "arches" + PGHOST: "db" + PGPORT: "5432" + RABBITMQ_USER: "rabbitmq" + RABBITMQ_PASS: "rabbitmq" + CANTALOUPE_HOST: "cantaloupe" + CANTALOUPE_PORT: "8182" + COUCHDB_HOST: "couchdb" + COUCHDB_PORT: "5984" + COUCHDB_USER: "admin" + COUCHDB_PASS: "password" + ESHOST: "elasticsearch" + ESPORT: "9200" + CELERY_BROKER_URL: "amqp://rabbitmq" + DJANGO_MODE: "PROD" + DJANGO_DEBUG: "False" + DOMAIN_NAMES: "arches" + PYTHONUNBUFFERED: "0" + TZ: "PST" + ports: + - '8000:8000' + options: >- + --health-cmd "curl --fail http://localhost:8000/templates/views/components/language-switcher.htm || exit 1" + --health-interval 10s + --health-timeout 5s + --health-retries 1000 From 191a39cde23680e85201a9fd913a0cdb53aef110 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 15:24:26 +0300 Subject: [PATCH 33/42] test: add temporary solution that selects Test Person --- cypress/e2e/03_flag_for_enforcement_workflow.cy.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/03_flag_for_enforcement_workflow.cy.js b/cypress/e2e/03_flag_for_enforcement_workflow.cy.js index 5f000a424..17ed71ff5 100644 --- a/cypress/e2e/03_flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/03_flag_for_enforcement_workflow.cy.js @@ -24,7 +24,8 @@ describe('Going through the Flag For Enforcement Workflow', function () { // TODO test with organisation as well // Commented out for now as search seems to be broken on local // cy.get('.select2-search__field').type('Test Person'); - cy.get('.select2-results__options li').first().click(); + cy.contains('Test Person').click(); + // cy.get('.select2-results__options li').first().click(); cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); cy.contains('Select resources').siblings('.row').click(); @@ -125,8 +126,8 @@ describe('Going through the Flag For Enforcement Workflow', function () { // TODO test with organisation as well // Commented out for now as search seems to be broken on local // cy.get('.select2-search__field').type('Test Person'); - cy.wait(5000); - cy.get('.select2-results__options li').first().click(); + cy.contains('Test Person').click(); + // cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); // Enforcement Summary tab From ad045a8e5f4479bae5defb99599bfa6c5f3ebb32 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 17:12:41 +0300 Subject: [PATCH 34/42] test: adds create organisation test --- cypress/e2e/01_create_a_person.cy.js | 3 +-- cypress/e2e/03_create_an_organisation.cy.js | 27 +++++++++++++++++++ ...=> 04_flag_for_enforcement_workflow.cy.js} | 0 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 cypress/e2e/03_create_an_organisation.cy.js rename cypress/e2e/{03_flag_for_enforcement_workflow.cy.js => 04_flag_for_enforcement_workflow.cy.js} (100%) diff --git a/cypress/e2e/01_create_a_person.cy.js b/cypress/e2e/01_create_a_person.cy.js index 9e539ada4..8116990b5 100644 --- a/cypress/e2e/01_create_a_person.cy.js +++ b/cypress/e2e/01_create_a_person.cy.js @@ -1,8 +1,7 @@ describe('Creating a person named Test Person if one doesnt exist', function () { beforeEach(() => { cy.login(); - cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&resource-type-filter=%5B%7B%22graphid%22%3A%2222477f01-1a44-11e9-b0a9-000d3ab1e588%22%2C%22name%22%3A%22Person%22%2C%22inverted%22%3Afalse%7D%5D'); - // cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&resource-type-filter=%5B%7B%22graphid%22%3A%22b9e0701e-5463-11e9-b5f5-000d3ab1e588%22%2C%22name%22%3A%22Activity%22%2C%22inverted%22%3Afalse%7D%5D'); + cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=125&language=*&term-filter=%5B%7B%22context%22%3A%22%22%2C%22context_label%22%3A%22Person%20-%20Name%22%2C%22id%22%3A%22termTest%20PersonPerson%20-%20Name%22%2C%22text%22%3A%22Test%20Person%22%2C%22type%22%3A%22term%22%2C%22value%22%3A%22Test%20Person%22%2C%22inverted%22%3Afalse%2C%22selected%22%3Atrue%7D%5D'); }); it('Create a person', function () { diff --git a/cypress/e2e/03_create_an_organisation.cy.js b/cypress/e2e/03_create_an_organisation.cy.js new file mode 100644 index 000000000..bcc11fe37 --- /dev/null +++ b/cypress/e2e/03_create_an_organisation.cy.js @@ -0,0 +1,27 @@ +describe('Creating a organisation named Test Organisation if one doesnt exist', function () { + beforeEach(() => { + cy.login(); + cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=125&language=*&term-filter=%5B%7B%22context%22%3A%22%22%2C%22context_label%22%3A%22Organization%20-%20Names%22%2C%22id%22%3A%22termTest%20OrganisationOrganization%20-%20Names%22%2C%22text%22%3A%22Test%20Organisation%22%2C%22type%22%3A%22term%22%2C%22value%22%3A%22Test%20Organisation%22%2C%22inverted%22%3Afalse%2C%22selected%22%3Atrue%7D%5D'); + }); + + it('Create an organisation', function () { + cy.wait(5000).then(() => { + cy.get('#search-results-list').then(($el) => { + if ($el.find('.search-listing').length > 0) { + // A caveat to this is that it will only look at the first page (which shouldn't be a problem with a fresh instance) since the search was failing locally to find Test Organisation (probably a permissions issue as all objects were created as Provisional) + if (!$el.text().includes('Test Organisation')) { + cy.visit('http://localhost:8000/add-resource/d4a88461-5463-11e9-90d9-000d3ab1e588') + cy.contains('Names').click(); + cy.get('[aria-label="Organization Name"]').should('be.visible').type('Test Organisation'); + cy.get('button').contains('Add').click(); + } + } else { + cy.visit('http://localhost:8000/add-resource/d4a88461-5463-11e9-90d9-000d3ab1e588') + cy.contains('Names').click(); + cy.get('[aria-label="Organization Name"]').should('be.visible').type('Test Organisation'); + cy.get('button').contains('Add').click(); + } + }) + }); + }); +}); diff --git a/cypress/e2e/03_flag_for_enforcement_workflow.cy.js b/cypress/e2e/04_flag_for_enforcement_workflow.cy.js similarity index 100% rename from cypress/e2e/03_flag_for_enforcement_workflow.cy.js rename to cypress/e2e/04_flag_for_enforcement_workflow.cy.js From 96e625dd5d9b0cc08fb6134d54b90346e5d1102f Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 17:15:07 +0300 Subject: [PATCH 35/42] test: search properly for test person --- .../e2e/04_flag_for_enforcement_workflow.cy.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/04_flag_for_enforcement_workflow.cy.js b/cypress/e2e/04_flag_for_enforcement_workflow.cy.js index 17ed71ff5..39e8e9377 100644 --- a/cypress/e2e/04_flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/04_flag_for_enforcement_workflow.cy.js @@ -20,12 +20,9 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); cy.type_ckeditor('editor2', 'test reason for enforcement'); cy.contains('Flagged by').siblings('.row').click(); - // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name - // TODO test with organisation as well - // Commented out for now as search seems to be broken on local - // cy.get('.select2-search__field').type('Test Person'); - cy.contains('Test Person').click(); - // cy.get('.select2-results__options li').first().click(); + // TODO test with organisation as well as with multiple people/orgs + cy.get('.select2-search__field').type('Test Person'); + cy.get('.select2-results__options li').first().click(); cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); cy.contains('Select resources').siblings('.row').click(); @@ -122,12 +119,9 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Enforcement Details Tab cy.wait(2000); cy.contains('Flagged by').siblings('.row').click(); - // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a test person and we can find them by name // TODO test with organisation as well - // Commented out for now as search seems to be broken on local - // cy.get('.select2-search__field').type('Test Person'); - cy.contains('Test Person').click(); - // cy.get('.select2-results__options li').first().click(); + cy.get('.select2-search__field').type('Test Person'); + cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); // Enforcement Summary tab From 2852e161b9aeddecf395c307ecfc9f85e1820ea2 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Mon, 19 Aug 2024 18:07:14 +0300 Subject: [PATCH 36/42] test: lower waits --- .../04_flag_for_enforcement_workflow.cy.js | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/04_flag_for_enforcement_workflow.cy.js b/cypress/e2e/04_flag_for_enforcement_workflow.cy.js index 39e8e9377..5969ef344 100644 --- a/cypress/e2e/04_flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/04_flag_for_enforcement_workflow.cy.js @@ -1,8 +1,8 @@ describe('Going through the Flag For Enforcement Workflow', function () { beforeEach(() => { - cy.login() - cy.visit('http://localhost:8000/plugins/init-workflow') + cy.login(); + cy.visit('http://localhost:8000/plugins/init-workflow'); }); it('Go through the workflow and populate all fields', function () { @@ -16,12 +16,13 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Continue').click(); // Enforcement Details Tab - cy.wait(2000); + cy.wait(900); cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); cy.type_ckeditor('editor2', 'test reason for enforcement'); cy.contains('Flagged by').siblings('.row').click(); // TODO test with organisation as well as with multiple people/orgs cy.get('.select2-search__field').type('Test Person'); + cy.wait(400); cy.get('.select2-results__options li').first().click(); cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); @@ -39,7 +40,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Flagged Date Value:').siblings().should('contain', '17'); cy.contains('Actor:').siblings().should('have.text', 'Test Person'); cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); - cy.wait(2000); + cy.wait(900); cy.contains('Save and Complete Workflow').click(); }); @@ -53,13 +54,18 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); cy.contains('Save and Continue').click(); + // Enforcement Details Tab - cy.wait(2000); + cy.wait(900); cy.contains('Next Step').click(); - + // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().invoke('text').as('enforcementId') cy.contains('Save and Complete Workflow').click(); + + console.log(this.enforcementId); + cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true'); }); it('Workflow with only Case Reference', function () { @@ -73,7 +79,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Continue').click(); // Enforcement Details Tab - cy.wait(2000); + cy.wait(900); cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); cy.contains('Save and Continue').click(); @@ -95,7 +101,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Continue').click(); // Enforcement Details Tab - cy.wait(2000); + cy.wait(900); cy.type_ckeditor('editor2', 'test reason for enforcement'); cy.contains('Save and Continue').click(); @@ -117,10 +123,11 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Continue').click(); // Enforcement Details Tab - cy.wait(2000); + cy.wait(900); cy.contains('Flagged by').siblings('.row').click(); // TODO test with organisation as well cy.get('.select2-search__field').type('Test Person'); + cy.wait(400); cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); @@ -143,7 +150,7 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Save and Continue').click(); // Enforcement Details Tab - cy.wait(2000); + cy.wait(900); cy.get('[aria-label="Flagged Date"]').click(); cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); cy.contains('Save and Continue').click(); @@ -162,12 +169,14 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Initial step tab // Makes sure the autogenerated id is not undefined + cy.wait(900); cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); cy.contains('Save and Continue').click(); // Enforcement Details Tab - cy.wait(2000); + cy.contains('Select resources').scrollIntoView(); + cy.wait(1000); cy.contains('Select resources').siblings('.row').click(); // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name cy.get('.select2-results__options li').first().click(); From 0d217dd82450556b9284a24a9894701bf1023720 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Tue, 20 Aug 2024 13:23:47 +0300 Subject: [PATCH 37/42] ops: comment out test step since it doesnt work --- .github/workflows/project.yml | 208 +++++++++++++++++----------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 7dbb05e65..125357184 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -268,109 +268,109 @@ jobs: run: | name=${{ fromJSON(steps.buildx.outputs.metadata)['image.name'] }} echo "image_name=$name" | sed 's/,.*//g' >> $GITHUB_OUTPUT - Test-Arches: - runs-on: [self-hosted] - needs: [Build-Arches-Final] - container: - image: cypress/included:12.3.0 - env: - HOME: "" - DEBUG: "cypress:*" - CYPRESS_BASE_URL: http://arches:8000 - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - name: Check out repository code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - submodules: 'true' - - name: Cypress run - uses: cypress-io/github-action@v4 - with: - browser: firefox - install: false - wait-on: 'http://arches:8000' - wait-on-timeout: 6000 - - uses: actions/upload-artifact@v3 - if: failure() - with: - name: cypress-screenshots - path: cypress/screenshots - - uses: actions/upload-artifact@v3 - if: always() - with: - name: cypress-videos - path: cypress/videos - services: - elasticsearch: - image: elasticsearch:8.4.0 - ports: - - "9200:9200" - - "9300:9300" - env: - TZ: "PST" - discovery.type: "single-node" - discovery.seed_hosts: "[]" - xpack.security.enabled: "false" - ES_JAVA_OPTS: "-Xms400m -Xmx400m" - options: >- - --health-cmd "curl -s --fail http://localhost:9200/_cat/health || exit 1" - --health-interval 10s - --health-timeout 5s - --health-retries 10 + # Test-Arches: + # runs-on: [self-hosted] + # needs: [Build-Arches-Final] + # container: + # image: cypress/included:12.3.0 + # env: + # HOME: "" + # DEBUG: "cypress:*" + # CYPRESS_BASE_URL: http://arches:8000 + # steps: + # - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + # - name: Check out repository code + # uses: actions/checkout@v3 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # submodules: 'true' + # - name: Cypress run + # uses: cypress-io/github-action@v4 + # with: + # browser: firefox + # install: false + # wait-on: 'http://arches:8000' + # wait-on-timeout: 6000 + # - uses: actions/upload-artifact@v3 + # if: failure() + # with: + # name: cypress-screenshots + # path: cypress/screenshots + # - uses: actions/upload-artifact@v3 + # if: always() + # with: + # name: cypress-videos + # path: cypress/videos + # services: + # elasticsearch: + # image: elasticsearch:8.4.0 + # ports: + # - "9200:9200" + # - "9300:9300" + # env: + # TZ: "PST" + # discovery.type: "single-node" + # discovery.seed_hosts: "[]" + # xpack.security.enabled: "false" + # ES_JAVA_OPTS: "-Xms400m -Xmx400m" + # options: >- + # --health-cmd "curl -s --fail http://localhost:9200/_cat/health || exit 1" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 10 - db: - image: flaxandteal/arches_coral_postgres - #volumes: - # - ${{ github.workspace }}/scripts/init-unix.sql:/docker-entrypoint-initdb.d/init.sql # to set up the DB template - ports: - - '5432:5432' - env: - POSTGRES_USER: postgres - POSTGRES_PASS: postgres - POSTGRES_DB: postgres - POSTGRES_MULTIPLE_EXTENSIONS: postgis,postgis_topology - TZ: PST - options: >- - --health-cmd "pg_isready -h 127.0.0.1 -U postgres -d postgres" - --health-interval 10s - --health-timeout 5s - --health-retries 20 + # db: + # image: flaxandteal/arches_coral_postgres + # #volumes: + # # - ${{ github.workspace }}/scripts/init-unix.sql:/docker-entrypoint-initdb.d/init.sql # to set up the DB template + # ports: + # - '5432:5432' + # env: + # POSTGRES_USER: postgres + # POSTGRES_PASS: postgres + # POSTGRES_DB: postgres + # POSTGRES_MULTIPLE_EXTENSIONS: postgis,postgis_topology + # TZ: PST + # options: >- + # --health-cmd "pg_isready -h 127.0.0.1 -U postgres -d postgres" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 20 - arches: - image: "${{ needs['Build-Arches-Final'].outputs.image }}" - env: - ALLOW_BOOTSTRAP: "True" - ARCHES_PROJECT: "${{ env.ARCHES_PROJECT }}" - COMPRESS_OFFLINE: "False" - INSTALL_CORAL_PACKAGE: "True" - INSTALL_DEFAULT_GRAPHS: "False" - INSTALL_DEFAULT_CONCEPTS: "False" - PGUSERNAME: "postgres" - PGPASSWORD: "postgres" - PGDBNAME: "arches" - PGHOST: "db" - PGPORT: "5432" - RABBITMQ_USER: "rabbitmq" - RABBITMQ_PASS: "rabbitmq" - CANTALOUPE_HOST: "cantaloupe" - CANTALOUPE_PORT: "8182" - COUCHDB_HOST: "couchdb" - COUCHDB_PORT: "5984" - COUCHDB_USER: "admin" - COUCHDB_PASS: "password" - ESHOST: "elasticsearch" - ESPORT: "9200" - CELERY_BROKER_URL: "amqp://rabbitmq" - DJANGO_MODE: "PROD" - DJANGO_DEBUG: "False" - DOMAIN_NAMES: "arches" - PYTHONUNBUFFERED: "0" - TZ: "PST" - ports: - - '8000:8000' - options: >- - --health-cmd "curl --fail http://localhost:8000/templates/views/components/language-switcher.htm || exit 1" - --health-interval 10s - --health-timeout 5s - --health-retries 1000 + # arches: + # image: "${{ needs['Build-Arches-Final'].outputs.image }}" + # env: + # ALLOW_BOOTSTRAP: "True" + # ARCHES_PROJECT: "${{ env.ARCHES_PROJECT }}" + # COMPRESS_OFFLINE: "False" + # INSTALL_CORAL_PACKAGE: "True" + # INSTALL_DEFAULT_GRAPHS: "False" + # INSTALL_DEFAULT_CONCEPTS: "False" + # PGUSERNAME: "postgres" + # PGPASSWORD: "postgres" + # PGDBNAME: "arches" + # PGHOST: "db" + # PGPORT: "5432" + # RABBITMQ_USER: "rabbitmq" + # RABBITMQ_PASS: "rabbitmq" + # CANTALOUPE_HOST: "cantaloupe" + # CANTALOUPE_PORT: "8182" + # COUCHDB_HOST: "couchdb" + # COUCHDB_PORT: "5984" + # COUCHDB_USER: "admin" + # COUCHDB_PASS: "password" + # ESHOST: "elasticsearch" + # ESPORT: "9200" + # CELERY_BROKER_URL: "amqp://rabbitmq" + # DJANGO_MODE: "PROD" + # DJANGO_DEBUG: "False" + # DOMAIN_NAMES: "arches" + # PYTHONUNBUFFERED: "0" + # TZ: "PST" + # ports: + # - '8000:8000' + # options: >- + # --health-cmd "curl --fail http://localhost:8000/templates/views/components/language-switcher.htm || exit 1" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 1000 From c23ba1d8b55892252ddf9cd1935e54d1ddd99248 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Tue, 20 Aug 2024 13:50:24 +0300 Subject: [PATCH 38/42] test: select the created heritage asset --- cypress/e2e/01_create_a_person.cy.js | 26 +++++++++++++++++-- .../flag_for_enforcement_workflow.cy.js} | 17 +++++++----- cypress/e2e/02_create_a_heritage_asset.cy.js | 6 +++-- 3 files changed, 38 insertions(+), 11 deletions(-) rename cypress/e2e/{04_flag_for_enforcement_workflow.cy.js => 01_flag_for_enforcement/flag_for_enforcement_workflow.cy.js} (94%) diff --git a/cypress/e2e/01_create_a_person.cy.js b/cypress/e2e/01_create_a_person.cy.js index 8116990b5..df7e01bca 100644 --- a/cypress/e2e/01_create_a_person.cy.js +++ b/cypress/e2e/01_create_a_person.cy.js @@ -1,10 +1,10 @@ -describe('Creating a person named Test Person if one doesnt exist', function () { +describe('Creating a person named Test Person and a person named John Doe if they dont exist', function () { beforeEach(() => { cy.login(); - cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=125&language=*&term-filter=%5B%7B%22context%22%3A%22%22%2C%22context_label%22%3A%22Person%20-%20Name%22%2C%22id%22%3A%22termTest%20PersonPerson%20-%20Name%22%2C%22text%22%3A%22Test%20Person%22%2C%22type%22%3A%22term%22%2C%22value%22%3A%22Test%20Person%22%2C%22inverted%22%3Afalse%2C%22selected%22%3Atrue%7D%5D'); }); it('Create a person', function () { + cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=125&language=*&term-filter=%5B%7B%22context%22%3A%22%22%2C%22context_label%22%3A%22Person%20-%20Name%22%2C%22id%22%3A%22termTest%20PersonPerson%20-%20Name%22%2C%22text%22%3A%22Test%20Person%22%2C%22type%22%3A%22term%22%2C%22value%22%3A%22Test%20Person%22%2C%22inverted%22%3Afalse%2C%22selected%22%3Atrue%7D%5D'); cy.wait(5000).then(() => { cy.get('#search-results-list').then(($el) => { if ($el.find('.search-listing').length > 0) { @@ -24,4 +24,26 @@ describe('Creating a person named Test Person if one doesnt exist', function () }) }); }); + + it('Create a second person', function () { + cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=329&term-filter=%5B%7B%22context%22%3A%22%22%2C%22context_label%22%3A%22Person%20-%20Name%22%2C%22id%22%3A%22termJohn%20DoePerson%20-%20Name%22%2C%22text%22%3A%22John%20Doe%22%2C%22type%22%3A%22term%22%2C%22value%22%3A%22John%20Doe%22%2C%22inverted%22%3Afalse%2C%22selected%22%3Atrue%7D%5D&language=*'); + cy.wait(5000).then(() => { + cy.get('#search-results-list').then(($el) => { + if ($el.find('.search-listing').length > 0) { + // A caveat to this is that it will only look at the first page (which shouldn't be a problem with a fresh instance) since the search was failing locally to find John Doe (probably a permissions issue as all objects were created as Provisional) + if (!$el.text().includes('John Doe')) { + cy.visit('http://localhost:8000/add-resource/22477f01-1a44-11e9-b0a9-000d3ab1e588') + cy.contains('Names').click(); + cy.get('[aria-label="Full Name"]').should('be.visible').type('John Doe'); + cy.get('button').contains('Add').click(); + } + } else { + cy.visit('http://localhost:8000/add-resource/22477f01-1a44-11e9-b0a9-000d3ab1e588') + cy.contains('Names').click(); + cy.get('[aria-label="Full Name"]').should('be.visible').type('John Doe'); + cy.get('button').contains('Add').click(); + } + }) + }); + }); }); diff --git a/cypress/e2e/04_flag_for_enforcement_workflow.cy.js b/cypress/e2e/01_flag_for_enforcement/flag_for_enforcement_workflow.cy.js similarity index 94% rename from cypress/e2e/04_flag_for_enforcement_workflow.cy.js rename to cypress/e2e/01_flag_for_enforcement/flag_for_enforcement_workflow.cy.js index 5969ef344..24cfa03e5 100644 --- a/cypress/e2e/04_flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/01_flag_for_enforcement/flag_for_enforcement_workflow.cy.js @@ -24,11 +24,14 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.get('.select2-search__field').type('Test Person'); cy.wait(400); cy.get('.select2-results__options li').first().click(); - cy.get('[aria-label="Flagged Date"]').should('be.visible').click(); + cy.contains('Flagged by').siblings('.row').click(); + cy.get('.select2-search__field').type('John Doe'); + cy.wait(600); + cy.get('.select2-results__options li').first().click(); + cy.get('[aria-label="Flagged Date"]').scrollIntoView().should('be.visible').click(); cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click(); cy.contains('Select resources').siblings('.row').click(); - // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name - cy.get('.select2-results__options li').first().click(); + cy.get('.select2-results__options li').contains('TestAsset').click(); cy.contains('Save and Continue').click(); // Enforcement Summary tab @@ -38,8 +41,8 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement'); // Only checks if the date we selected is present as the year and month could change cy.contains('Flagged Date Value:').siblings().should('contain', '17'); - cy.contains('Actor:').siblings().should('have.text', 'Test Person'); - cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); + cy.contains('Actor:').siblings().should('have.text', 'John Doe, Test Person'); + cy.contains('Associated Resources:').siblings().should('have.text', 'None TestAsset'); cy.wait(900); cy.contains('Save and Complete Workflow').click(); }); @@ -178,14 +181,14 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.contains('Select resources').scrollIntoView(); cy.wait(1000); cy.contains('Select resources').siblings('.row').click(); + cy.get('.select2-results__options li').contains('TestAsset').click(); // Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name - cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); cy.contains('ResourceID:').siblings().should('not.have.text', ''); - cy.contains('Associated Resources:').siblings().should('have.text', 'Undefined'); + cy.contains('Associated Resources:').siblings().should('have.text', 'None TestAsset'); cy.contains('Save and Complete Workflow').click(); }); }); diff --git a/cypress/e2e/02_create_a_heritage_asset.cy.js b/cypress/e2e/02_create_a_heritage_asset.cy.js index 424bcd8c5..144a02471 100644 --- a/cypress/e2e/02_create_a_heritage_asset.cy.js +++ b/cypress/e2e/02_create_a_heritage_asset.cy.js @@ -1,7 +1,7 @@ -describe('Creating a Heritage Asset if none exist', function () { +describe('Creating a Heritage Asset named TestAsset if it doesnt exist', function () { beforeEach(() => { cy.login(); - cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&resource-type-filter=%5B%7B%22graphid%22%3A%22076f9381-7b00-11e9-8d6b-80000b44d1d9%22%2C%22name%22%3A%22Heritage%20Asset%22%2C%22inverted%22%3Afalse%7D%5D'); + cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=336&term-filter=%5B%7B%22inverted%22%3Afalse%2C%22type%22%3A%22string%22%2C%22context%22%3A%22%22%2C%22context_label%22%3A%22%22%2C%22id%22%3A%22TestAsset%22%2C%22text%22%3A%22TestAsset%22%2C%22value%22%3A%22TestAsset%22%2C%22selected%22%3Atrue%7D%5D&language=*'); }); it('Create a heritage asset', function () { @@ -10,6 +10,8 @@ describe('Creating a Heritage Asset if none exist', function () { if (!$el.find('.search-listing').length > 0) { // If no Heritage Assets exist create an empty heritage asset cy.visit('http://localhost:8000/add-resource/076f9381-7b00-11e9-8d6b-80000b44d1d9') + cy.contains('Heritage Asset Names').click(); + cy.get('[aria-label="Name"]').should('be.visible').type('TestAsset'); cy.get('button').contains('Add').click(); }; }) From d1f58608dca62ca502e1a13d678eea0d1e775307 Mon Sep 17 00:00:00 2001 From: Andrea K Date: Tue, 20 Aug 2024 14:03:54 +0300 Subject: [PATCH 39/42] test: tests with multiple people as well as organisation --- .../flag_for_enforcement_workflow.cy.js | 63 +++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/01_flag_for_enforcement/flag_for_enforcement_workflow.cy.js b/cypress/e2e/01_flag_for_enforcement/flag_for_enforcement_workflow.cy.js index 24cfa03e5..b914626cb 100644 --- a/cypress/e2e/01_flag_for_enforcement/flag_for_enforcement_workflow.cy.js +++ b/cypress/e2e/01_flag_for_enforcement/flag_for_enforcement_workflow.cy.js @@ -20,9 +20,8 @@ describe('Going through the Flag For Enforcement Workflow', function () { cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref'); cy.type_ckeditor('editor2', 'test reason for enforcement'); cy.contains('Flagged by').siblings('.row').click(); - // TODO test with organisation as well as with multiple people/orgs cy.get('.select2-search__field').type('Test Person'); - cy.wait(400); + cy.wait(500); cy.get('.select2-results__options li').first().click(); cy.contains('Flagged by').siblings('.row').click(); cy.get('.select2-search__field').type('John Doe'); @@ -128,20 +127,74 @@ describe('Going through the Flag For Enforcement Workflow', function () { // Enforcement Details Tab cy.wait(900); cy.contains('Flagged by').siblings('.row').click(); - // TODO test with organisation as well cy.get('.select2-search__field').type('Test Person'); - cy.wait(400); + cy.wait(500); cy.get('.select2-results__options li').first().click(); cy.contains('Save and Continue').click(); // Enforcement Summary tab cy.contains('ResourceID:').siblings().should('not.have.text'); cy.contains('ResourceID:').siblings().should('not.have.text', ''); - // TODO test with multiple people cy.contains('Actor:').siblings().should('have.text', 'Test Person'); cy.contains('Save and Complete Workflow').click(); }); + it('Workflow with only Flagged By using Organisation', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(900); + cy.contains('Flagged by').siblings('.row').click(); + cy.get('.select2-search__field').type('Test Organisation'); + cy.wait(500); + cy.get('.select2-results__options li').first().click(); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Actor:').siblings().should('have.text', 'Test Organisation'); + cy.contains('Save and Complete Workflow').click(); + }); + + it('Workflow with only Flagged By using both an Organisation and a Person', function () { + cy.contains('Workflows'); + cy.contains('Flag for Enforcement').click(); + + // Initial step tab + // Makes sure the autogenerated id is not undefined + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value'); + cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', ''); + cy.contains('Save and Continue').click(); + + // Enforcement Details Tab + cy.wait(900); + cy.contains('Flagged by').siblings('.row').click(); + cy.get('.select2-search__field').type('Test Organisation'); + cy.wait(500); + cy.get('.select2-results__options li').first().click(); + cy.wait(500); + cy.contains('Flagged by').siblings('.row').click(); + cy.get('.select2-search__field').type('Test Person'); + cy.wait(500); + cy.get('.select2-results__options li').first().click(); + cy.contains('Save and Continue').click(); + + // Enforcement Summary tab + cy.contains('ResourceID:').siblings().should('not.have.text'); + cy.contains('ResourceID:').siblings().should('not.have.text', ''); + cy.contains('Actor:').siblings().should('have.text', 'Test Person, Test Organisation'); + cy.contains('Save and Complete Workflow').click(); + }); + + it('Workflow with only Flagged Date', function () { cy.contains('Workflows'); cy.contains('Flag for Enforcement').click(); From 16c704230c984b379fd098ea272f5fe39510434a Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Thu, 29 Aug 2024 15:07:20 +0100 Subject: [PATCH 40/42] test: adding cypress tests for curatorial inspection workflow.. added testFileForUpload.txt to try implementation for file upload --- .../curatorial_inspection_workflow.cy.js | 132 ++++++++++++++++++ .../testFileForUpload.txt | 1 + 2 files changed, 133 insertions(+) create mode 100644 cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js create mode 100644 cypress/e2e/04_curatorial_inspection_workflow/testFileForUpload.txt diff --git a/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js b/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js new file mode 100644 index 000000000..64fac27f9 --- /dev/null +++ b/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js @@ -0,0 +1,132 @@ +describe('Going through the Incident Report', function () { + + beforeEach(() => { + cy.login(); + cy.visit('http://localhost:8000/plugins/init-workflow'); + }); + + it('Go through the workflow and populate all fields', function () { + cy.contains('Workflows'); + cy.contains('Curatorial Inspection').click(); + + // Curatorial Inspection opening screen + cy.get('.select2-selection__rendered').contains('Start new or please select from below'); + cy.get('.btn-success').contains('Start New'); + cy.get('.btn-primary').contains('Open Selected'); + cy.get('.btn-danger').contains('Clear Recents'); + + cy.get('.btn-success').contains('Start New').click(); + + // Start tab + cy.get('.widget-input-label').contains('Consultation ID'); + cy.get('.widget-input').should('be.disabled'); + + cy.get('.workflow-nav-tab').contains('Asset Details').click(); + cy.get('.workflow-nav-tab').contains('Attendees Details').click(); + cy.get('.workflow-nav-tab').contains('Comments').click(); + cy.get('.workflow-nav-tab').contains('Upload').click(); + cy.get('.workflow-nav-tab').contains('Sign Off').click(); + + cy.get('.tabbed-workflow-footer').contains('Save and Continue').click(); + + // Asset Details tab + cy.get('.tabbed-workflow-footer').contains('Previous Step'); + cy.get('.tabbed-workflow-footer').contains('Next Step'); + cy.wait(2000); + + cy.get('.control-label').contains('SMR Number'); + cy.get('.select2-selection__rendered').contains('Add new Relationship').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('HA/01').click(); + + cy.get('.control-label').contains('B File Reference'); + cy.get('[aria-label="B File Reference"]').click().type('Testing'); + + cy.get('.control-label').contains('BDLO Reference').scrollIntoView(); + cy.get('[aria-label="BDLO Reference"]').click().type('Testing'); + + cy.get('.control-label').contains('HPRM Reference').scrollIntoView(); + cy.get('[aria-label="HPRM Reference"]').click().type('Testing'); + + cy.get('.control-labx').contains('Date Consulted'); + cy.get('[aria-label="Date Consulted"]').click(); + cy.get('.card_component.log_date > .row > .form-group > .col-xs-12 > :nth-child(1) > .input-group > .input-group-addon').click(); + + cy.get('.btn-primary').contains('Previous Step'); + cy.get('.btn-danger').contains('Undo'); + cy.get('.btn-success').contains('Save and Continue').click(); + + // Attendees Details tab + cy.get('.tabbed-workflow-footer').contains('Previous Step'); + cy.get('.tabbed-workflow-footer').contains('Next Step'); + cy.wait(2000); + + cy.get('.control-label').contains('CWT Area Supervisor'); + cy.get('.card_component.cwt_area_supervisor > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.control-label').contains('Archaeologist'); + cy.get('.card_component.archaeologist > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.control-label').contains('CWT Area Manager'); + cy.get('.card_component.cwt_area_manager > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.control-label').contains('Owner').scrollIntoView(); + cy.get('.card_component.owner > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.control-label').contains('HED Staff'); + cy.get('.card_component.hed_staff_value > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.btn-primary').contains('Previous Step'); + cy.get('.btn-danger').contains('Undo'); + cy.get('.btn-success').contains('Save and Continue').click(); + + // Comments tabs + cy.get('.control-label').contains('Curatorial Description Type'); + cy.get('.select2-selection__rendered').contains('Select an option').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Comments'); + cy.get('.select2-results__option').contains('Further Recommendations'); + cy.get('.select2-results__option').contains('Items Discussed'); + cy.get('.select2-results__option').contains('Action'); + + cy.get('.select2-results__option').contains('Comments').click(); + cy.get('.cke_contents').click().type('Testing'); + cy.get('.btn-success').contains('Add').click(); + + cy.get('.btn-primary').contains('Previous Step'); + cy.get('.btn-danger').contains('Undo'); + cy.get('.btn-success').contains('Save and Continue').click(); + + // Upload tab + cy.wait(2000); + cy.get('.bord-top > .btn').contains('Select Files') + //cy.get('.media-block').selectFile('cypress/e2e/04_curatorial_inspection_workflow/testFileForUpload.txt'); + cy.get('.tabbed-workflow-footer-button-container').contains('Next Step').click(); + + // Sign Off + cy.wait(2000); + cy.get('.control-labx').contains('Signed Off On'); + cy.get('[aria-label="Signed Off On"]').click(); + cy.get('.input-group-addon').click(); + + cy.get('.control-label').contains('Report Submitted By'); + cy.get('.card_component.report_submitted_by_value > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').contains('Add new Relationship').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.tabbed-workflow-footer-button-container').contains('Previous Step'); + cy.get('.tabbed-workflow-footer-button-container').contains('Save').click(); + + cy.get('.workflow-top-control > .btn-success').contains('Save and Complete Workflow').click(); + }) +}) \ No newline at end of file diff --git a/cypress/e2e/04_curatorial_inspection_workflow/testFileForUpload.txt b/cypress/e2e/04_curatorial_inspection_workflow/testFileForUpload.txt new file mode 100644 index 000000000..86e0f38f2 --- /dev/null +++ b/cypress/e2e/04_curatorial_inspection_workflow/testFileForUpload.txt @@ -0,0 +1 @@ +Dummy file to test file upload \ No newline at end of file From 9405ff321e20e598e488841c59c45a0898029e78 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Wed, 4 Sep 2024 11:32:03 +0100 Subject: [PATCH 41/42] test: adding indvidual tab tests --- .../curatorial_inspection_workflow.cy.js | 204 ++++++++++++++++++ 1 file changed, 204 insertions(+) diff --git a/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js b/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js index 64fac27f9..b040c3c55 100644 --- a/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js +++ b/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js @@ -129,4 +129,208 @@ describe('Going through the Incident Report', function () { cy.get('.workflow-top-control > .btn-success').contains('Save and Complete Workflow').click(); }) + + it('Asset Details populate all fields', function () { + cy.contains('Workflows'); + cy.contains('Curatorial Inspection').click(); + + // Curatorial Inspection opening screen + cy.get('.select2-selection__rendered').contains('Start new or please select from below'); + cy.get('.btn-success').contains('Start New'); + cy.get('.btn-primary').contains('Open Selected'); + cy.get('.btn-danger').contains('Clear Recents'); + + cy.get('.btn-success').contains('Start New').click(); + + // Start tab + cy.get('.tabbed-workflow-footer').contains('Save and Continue').click(); + + // Asset Details tab + cy.get('.tabbed-workflow-footer').contains('Previous Step'); + cy.get('.tabbed-workflow-footer').contains('Next Step'); + cy.wait(2000); + + cy.get('.control-label').contains('SMR Number'); + cy.get('.select2-selection__rendered').contains('Add new Relationship').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('HA/01').click(); + + cy.get('.control-label').contains('B File Reference'); + cy.get('[aria-label="B File Reference"]').click().type('Testing'); + + cy.get('.control-label').contains('BDLO Reference').scrollIntoView(); + cy.get('[aria-label="BDLO Reference"]').click().type('Testing'); + + cy.get('.control-label').contains('HPRM Reference').scrollIntoView(); + cy.get('[aria-label="HPRM Reference"]').click().type('Testing'); + + cy.get('.control-labx').contains('Date Consulted'); + cy.get('[aria-label="Date Consulted"]').click(); + cy.get('.card_component.log_date > .row > .form-group > .col-xs-12 > :nth-child(1) > .input-group > .input-group-addon').click(); + }) + + it('Attendees Details populate all fields', function () { + cy.contains('Workflows'); + cy.contains('Curatorial Inspection').click(); + + // Curatorial Inspection opening screen + cy.get('.select2-selection__rendered').contains('Start new or please select from below'); + cy.get('.btn-success').contains('Start New'); + cy.get('.btn-primary').contains('Open Selected'); + cy.get('.btn-danger').contains('Clear Recents'); + + cy.get('.btn-success').contains('Start New').click(); + + // Start tab + cy.get('.tabbed-workflow-footer').contains('Save and Continue').click(); + + // Asset Details tab + cy.get('.btn-primary').contains('Next Step').click(); + + // Attendees Details tab + cy.get('.tabbed-workflow-footer').contains('Previous Step'); + cy.get('.tabbed-workflow-footer').contains('Next Step'); + cy.wait(2000); + + cy.get('.control-label').contains('CWT Area Supervisor'); + cy.get('.card_component.cwt_area_supervisor > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.control-label').contains('Archaeologist'); + cy.get('.card_component.archaeologist > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.control-label').contains('CWT Area Manager'); + cy.get('.card_component.cwt_area_manager > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.control-label').contains('Owner').scrollIntoView(); + cy.get('.card_component.owner > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.control-label').contains('HED Staff'); + cy.get('.card_component.hed_staff_value > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + }) + + it('Comment tab populate all fields', function () { + cy.contains('Workflows'); + cy.contains('Curatorial Inspection').click(); + + // Curatorial Inspection opening screen + cy.get('.select2-selection__rendered').contains('Start new or please select from below'); + cy.get('.btn-success').contains('Start New'); + cy.get('.btn-primary').contains('Open Selected'); + cy.get('.btn-danger').contains('Clear Recents'); + + cy.get('.btn-success').contains('Start New').click(); + + // Start tab + cy.get('.tabbed-workflow-footer').contains('Save and Continue').click(); + + // Asset Details tab + cy.get('.tabbed-workflow-footer').contains('Next Step'); + + // Attendees Details tab + cy.get('.tabbed-workflow-footer').contains('Next Step'); + + // Comments tabs + cy.get('.control-label').contains('Curatorial Description Type'); + cy.get('.select2-selection__rendered').contains('Select an option').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Comments'); + cy.get('.select2-results__option').contains('Further Recommendations'); + cy.get('.select2-results__option').contains('Items Discussed'); + cy.get('.select2-results__option').contains('Action'); + + cy.get('.select2-results__option').contains('Comments').click(); + cy.get('.cke_contents').click().type('Testing'); + cy.get('.btn-success').contains('Add').click(); + }) + + it('Upload tab and populate all fields', function () { + cy.contains('Workflows'); + cy.contains('Curatorial Inspection').click(); + + // Curatorial Inspection opening screen + cy.get('.select2-selection__rendered').contains('Start new or please select from below'); + cy.get('.btn-success').contains('Start New'); + cy.get('.btn-primary').contains('Open Selected'); + cy.get('.btn-danger').contains('Clear Recents'); + + cy.get('.btn-success').contains('Start New').click(); + + // Start tab + cy.get('.widget-input-label').contains('Consultation ID'); + cy.get('.widget-input').should('be.disabled'); + + cy.get('.workflow-nav-tab').contains('Asset Details').click(); + cy.get('.workflow-nav-tab').contains('Attendees Details').click(); + cy.get('.workflow-nav-tab').contains('Comments').click(); + cy.get('.workflow-nav-tab').contains('Upload').click(); + cy.get('.workflow-nav-tab').contains('Sign Off').click(); + + cy.get('.tabbed-workflow-footer').contains('Save and Continue').click(); + + // Asset Details tab + cy.get('.tabbed-workflow-footer').contains('Next Step').click(); + + // Attendees Details tab + cy.get('.tabbed-workflow-footer').contains('Next Step').click(); + + // Comments tabs + cy.get('.btn-primary').contains('Next Step').click(); + + // Upload tab + cy.wait(2000); + cy.get('.bord-top > .btn').contains('Select Files') + //cy.get('.media-block').selectFile('cypress/e2e/04_curatorial_inspection_workflow/testFileForUpload.txt'); + }) + + it('Sign Off tab and populate all fields', function () { + cy.contains('Workflows'); + cy.contains('Curatorial Inspection').click(); + + // Curatorial Inspection opening screen + cy.get('.select2-selection__rendered').contains('Start new or please select from below'); + cy.get('.btn-success').contains('Start New'); + cy.get('.btn-primary').contains('Open Selected'); + cy.get('.btn-danger').contains('Clear Recents'); + + cy.get('.btn-success').contains('Start New').click(); + + // Start tab + cy.get('.tabbed-workflow-footer').contains('Save and Continue').click(); + + // Asset Details tab + cy.get('.tabbed-workflow-footer').contains('Next Step').click(); + + // Attendees Details tab + cy.get('.tabbed-workflow-footer').contains('Next Step').click(); + + // Comments tabs + cy.get('.btn-primary').contains('Next Step').click(); + + // Upload tab + cy.get('.tabbed-workflow-footer-button-container').contains('Next Step').click(); + + // Sign Off + cy.wait(2000); + cy.get('.control-labx').contains('Signed Off On'); + cy.get('[aria-label="Signed Off On"]').click(); + cy.get('.input-group-addon').click(); + + cy.get('.control-label').contains('Report Submitted By'); + cy.get('.card_component.report_submitted_by_value > .widget-wrapper > .form-group > .row > .col-xs-12 > .select2 > .selection > .select2-selection').contains('Add new Relationship').click(); + cy.wait(2000); + cy.get('.select2-results__option').contains('Test Person').click(); + + cy.get('.tabbed-workflow-footer-button-container').contains('Previous Step'); + cy.get('.tabbed-workflow-footer-button-container').contains('Save').click(); + }) }) \ No newline at end of file From af62b7281c8de049deb17da862e90a07034b7f8e Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Thu, 5 Sep 2024 14:35:03 +0100 Subject: [PATCH 42/42] test: updating cypress config for baseUrl --- cypress.config.js | 1 + .../curatorial_inspection_workflow.cy.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cypress.config.js b/cypress.config.js index d0dedb14b..d5e4ccea4 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -2,6 +2,7 @@ module.exports = { projectId: 'arches', video: true, e2e: { + baseUrl:"http://localhost:8000", setupNodeEvents(on, config) {}, specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}', }, diff --git a/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js b/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js index b040c3c55..aa1e95dbd 100644 --- a/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js +++ b/cypress/e2e/04_curatorial_inspection_workflow/curatorial_inspection_workflow.cy.js @@ -2,7 +2,7 @@ describe('Going through the Incident Report', function () { beforeEach(() => { cy.login(); - cy.visit('http://localhost:8000/plugins/init-workflow'); + cy.visit('/plugins/init-workflow'); }); it('Go through the workflow and populate all fields', function () {