From f3e7a1827190ff120f9185ae24e7799cd1c689e6 Mon Sep 17 00:00:00 2001 From: jbrown-xentity Date: Wed, 6 Oct 2021 14:16:40 -0600 Subject: [PATCH 1/2] Upgrade ckanext-spatial Test that a spatial harvested dataset with bad tags is still editable, and can be added to a group. --- ckan/requirements.txt | 2 +- e2e/cypress/integration/spatial.spec.js | 30 +++++++++++++ .../integration/spatial_search.spec.js | 8 ---- e2e/cypress/support/command.js | 44 +++++++++++++++++++ 4 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 e2e/cypress/integration/spatial.spec.js delete mode 100644 e2e/cypress/integration/spatial_search.spec.js diff --git a/ckan/requirements.txt b/ckan/requirements.txt index 5effbc54..13f5e407 100644 --- a/ckan/requirements.txt +++ b/ckan/requirements.txt @@ -15,7 +15,7 @@ ckanext-envvars @ git+https://github.com/GSA/ckanext-envvars.git@33f7e190ab33224 -e git+https://github.com/GSA/ckanext-geodatagov.git@bc700f671cd1d890db265c65f5db1cba121297f4#egg=ckanext_geodatagov ckanext-googleanalyticsbasic @ git+https://github.com/GSA/ckanext-googleanalyticsbasic.git@c6a425d5e14d658c0fa3661fdc4423162161c3f4 -e git+https://github.com/GSA/ckanext-harvest.git@a418ed4a8b91feefc9f91bfce6e03a8af5c83c36#egg=ckanext_harvest --e git+https://github.com/gsa/ckanext-spatial.git@36981c39d624685bc85b84f801f2a2d6eaea67f6#egg=ckanext_spatial +-e git+https://github.com/gsa/ckanext-spatial.git@964c65284e8105bf6823457ee8053ecc978d591d#egg=ckanext_spatial ckantoolkit==0.0.3 click==7.1.2 cryptography==35.0.0 diff --git a/e2e/cypress/integration/spatial.spec.js b/e2e/cypress/integration/spatial.spec.js new file mode 100644 index 00000000..5484ec32 --- /dev/null +++ b/e2e/cypress/integration/spatial.spec.js @@ -0,0 +1,30 @@ +describe('Spatial', () => { + it('Can search geographies by name', () => { + cy.request('/api/3/action/location_search?q=california').should((response) => { + expect(response.body).to.have.property('success', true); + expect(response.body.result[0]).to.have.property('text', 'California'); + }); + }); + it('Can put a package in an organization', () => { + const group_name = 'climate'; + cy.logout(); + cy.login(); + cy.delete_group(group_name); + cy.create_group(group_name, "Climate Group"); + cy.request({ + url: '/api/action/package_patch', + method: 'POST', + body: { + "id": "nefsc-2000-spring-bottom-trawl-survey-al0002-ek500", + "groups": [{"name": group_name}] + } + }).should((response) => { + expect(response.body).to.have.property('success', true); + expect(response.body.result.groups[0]).to.have.property("name", "climate"); + + // Cleanup + cy.delete_group(group_name); + cy.logout(); + }) + }) +}); \ No newline at end of file diff --git a/e2e/cypress/integration/spatial_search.spec.js b/e2e/cypress/integration/spatial_search.spec.js deleted file mode 100644 index acee985a..00000000 --- a/e2e/cypress/integration/spatial_search.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -describe('Spatial Search', () => { - it('Can search geographies by name', () => { - cy.request('/api/3/action/location_search?q=california').should((response) => { - expect(response.body).to.have.property('success', true); - expect(response.body.result[0]).to.have.property('text', 'California'); - }); - }); -}); \ No newline at end of file diff --git a/e2e/cypress/support/command.js b/e2e/cypress/support/command.js index 19320fcd..80528707 100644 --- a/e2e/cypress/support/command.js +++ b/e2e/cypress/support/command.js @@ -39,6 +39,10 @@ Cypress.Commands.add('login', (userName, password, loginTest) => { cy.get('.btn-primary').eq(1).click() }) +Cypress.Commands.add('logout', () => { + cy.clearCookies(); +}) + Cypress.Commands.add('create_organization_ui', (orgName, orgDesc) => { /** * Method to fill out the form to create a CKAN organization @@ -83,6 +87,46 @@ Cypress.Commands.add('create_organization', (orgName, orgDesc) => { }) +Cypress.Commands.add('create_group', (groupName, groupDesc) => { + /** + * Method to create organization via CKAN API + * :PARAM groupName String: Name of the organization being created + * :PARAM groupDesc String: Description of the organization being created + * :RETURN null: + */ + + cy.request({ + url: '/api/action/group_create', + method: 'POST', + body: { + "description": groupDesc, + "title": groupName, + "approval_status": "approved", + "state": "active", + "name": groupName + } + }) +}) + +Cypress.Commands.add('delete_group', (groupName) => { + /** + * Method to create organization via CKAN API + * :PARAM groupName String: Name of the organization being created + * :PARAM groupDesc String: Description of the organization being created + * :RETURN null: + */ + + cy.request({ + url: '/api/action/group_purge', + method: 'POST', + failOnStatusCode: false, + body: { + "id": groupName + } + }) +}) + + Cypress.Commands.add('delete_organization', (orgName) => { /** * Method to purge an organization from the current state From ac22310190c023873f3187f8325a36f6a89cfd1a Mon Sep 17 00:00:00 2001 From: jbrown-xentity Date: Wed, 6 Oct 2021 14:18:40 -0600 Subject: [PATCH 2/2] Update test title --- e2e/cypress/integration/spatial.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/cypress/integration/spatial.spec.js b/e2e/cypress/integration/spatial.spec.js index 5484ec32..fa3d217c 100644 --- a/e2e/cypress/integration/spatial.spec.js +++ b/e2e/cypress/integration/spatial.spec.js @@ -5,7 +5,7 @@ describe('Spatial', () => { expect(response.body.result[0]).to.have.property('text', 'California'); }); }); - it('Can put a package in an organization', () => { + it('Can put a package with weird tags in an group', () => { const group_name = 'climate'; cy.logout(); cy.login();