Skip to content

Commit

Permalink
Merge pull request #915 from GSA/update-csw-harvest-spec
Browse files Browse the repository at this point in the history
Create CSW harvest source within test org;
  • Loading branch information
btylerburton authored Apr 7, 2023
2 parents 365666f + 8c07031 commit 25b56a2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 35 deletions.
32 changes: 5 additions & 27 deletions e2e/cypress/integration/000_harvest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ describe('Harvest', { testIsolation: false }, () => {
/**
* Test creating a valid datajson harvest source
*/
//cy.get('a[href="/organization/edit/'+harvestOrg+'"]').click()
cy.visit(`/organization/${harvestOrg}`);
cy.get('a[class="btn btn-primary"]').click();
cy.get('a[href="/harvest?organization=' + harvestOrg + '"]').click();
cy.get('a[class="btn btn-primary"]').click();
cy.create_harvest_source(
harvestOrg,
'http://nginx-harvest-source/data.json',
dataJsonHarvestSoureName,
'cypress test datajson',
Expand All @@ -51,13 +47,7 @@ describe('Harvest', { testIsolation: false }, () => {
});

it('Create a datajson harvest source INVALID', () => {
cy.visit('/organization/' + harvestOrg);
cy.hide_debug_toolbar();

cy.get('a[class="btn btn-primary"]').click();
cy.get('a[href="/harvest?organization=' + harvestOrg + '"]').click();
cy.get('a[class="btn btn-primary"]').click();
cy.create_harvest_source('😀', 'invalid datajson', 'invalid datajson', 'datajson', 'False', true);
cy.create_harvest_source(harvestOrg, '😀', 'invalid datajson', 'invalid datajson', 'datajson', 'False', true);
cy.contains('URL: Missing value');
});

Expand All @@ -77,13 +67,8 @@ describe('Harvest', { testIsolation: false }, () => {
/**
* Create a WAF ISO Harvest Source
*/
cy.visit('/organization/' + harvestOrg);
cy.hide_debug_toolbar();

cy.get('a[class="btn btn-primary"]').click();
cy.get('a[href="/harvest?organization=' + harvestOrg + '"]').click();
cy.get('a[class="btn btn-primary"]').click();
cy.create_harvest_source(
harvestOrg,
'http://nginx-harvest-source/iso-waf/',
wafIsoHarvestSourceName,
'cypress test waf iso',
Expand Down Expand Up @@ -111,13 +96,8 @@ describe('Harvest', { testIsolation: false }, () => {
/**
* Create a WAF ISO Harvest Source
*/
cy.visit('/organization/' + harvestOrg);
cy.hide_debug_toolbar();

cy.get('a[class="btn btn-primary"]').click();
cy.get('a[href="/harvest?organization=' + harvestOrg + '"]').click();
cy.get('a[class="btn btn-primary"]').click();
cy.create_harvest_source(
harvestOrg,
'http://nginx-harvest-source/fgdc-waf/',
wafFgdcHarvestSourceName,
'cypress test waf FGDC',
Expand Down Expand Up @@ -147,11 +127,9 @@ describe('Harvest', { testIsolation: false }, () => {
* how many harvest sources are created for CSW by going to
* https://catalog.data.gov/harvest?source_type=csw
*/
cy.visit(`/harvest/new`);

cy.hide_debug_toolbar();

cy.create_harvest_source(
harvestOrg,
'https://geonode.state.gov/catalogue/csw',
cswHarvestSourceName,
'cypress test csw',
Expand Down
26 changes: 18 additions & 8 deletions e2e/cypress/support/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ Cypress.Commands.add('check_dataset_harvested', (retries) => {
expect(true).to.be.false();
}

cy.reload(true)
cy.contains('#content section.module-content dl dt', 'Datasets').next().invoke('text').then($text => {
if ($text == '0') {
cy.wait(1000);
cy.check_dataset_harvested(retries - 1);
}
});
cy.reload(true);
cy.contains('#content section.module-content dl dt', 'Datasets')
.next()
.invoke('text')
.then(($text) => {
if ($text == '0') {
cy.wait(1000);
cy.check_dataset_harvested(retries - 1);
}
});
});

Cypress.Commands.add('login', (userName, password, loginTest) => {
Expand Down Expand Up @@ -185,15 +188,22 @@ Cypress.Commands.add('delete_dataset', (datasetName) => {

Cypress.Commands.add(
'create_harvest_source',
(dataSourceUrl, harvestTitle, harvestDesc, harvestType, harvestPrivate, invalidTest) => {
(harvestOrg, dataSourceUrl, harvestTitle, harvestDesc, harvestType, harvestPrivate, invalidTest) => {
/**
* Method to create a new CKAN harvest source via the CKAN harvest form
* :PARAM harvestOrg String: name of test org to create harvest source under
* :PARAM dataSourceUrl String: URL to source the data that will be harvested
* :PARAM harvestTitle String: Title of the organization's harvest
* :PARAM harvestDesc String: Description of the harvest being created
* :PARAM harvestType String: Harvest source type. Ex: waf, datajson
* :RETURN null:
*/
cy.visit('/organization/' + harvestOrg);
cy.hide_debug_toolbar();
cy.get('a[class="btn btn-primary"]').click();
cy.get('a[href="/harvest?organization=' + harvestOrg + '"]').click();
cy.get('a[class="btn btn-primary"]').click();

if (!invalidTest) {
cy.get('#field-url').type(dataSourceUrl);
}
Expand Down

0 comments on commit 25b56a2

Please sign in to comment.