From f3b7f1a6523e77fc64b705909e4ec79a67bef51a Mon Sep 17 00:00:00 2001 From: fmizzell Date: Tue, 12 Jan 2021 08:19:27 -0600 Subject: [PATCH] New components (1.5.0) and axios security update. (#50) --- cypress/fixtures/datastoreImportInfo.json | 18 ++++++++++++ cypress/integration/dataset-stubbed.spec.js | 6 ++-- cypress/integration/search-stubbed.spec.js | 10 +++---- cypress/support/commands.js | 32 +++++++++++---------- package.json | 4 +-- 5 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 cypress/fixtures/datastoreImportInfo.json diff --git a/cypress/fixtures/datastoreImportInfo.json b/cypress/fixtures/datastoreImportInfo.json new file mode 100644 index 0000000..b4561a1 --- /dev/null +++ b/cypress/fixtures/datastoreImportInfo.json @@ -0,0 +1,18 @@ +{ + "numOfColumns": 3, + "columns":{ + "record_number":{ + "type":"text", + "description":"" + }, + "date":{ + "type":"text", + "description":"CMS Certification Number (CCN)" + }, + "price":{ + "type":"text", + "description":"Facility Name" + } + }, + "numOfRows":200 +} diff --git a/cypress/integration/dataset-stubbed.spec.js b/cypress/integration/dataset-stubbed.spec.js index 3e90706..45d3299 100644 --- a/cypress/integration/dataset-stubbed.spec.js +++ b/cypress/integration/dataset-stubbed.spec.js @@ -1,8 +1,10 @@ context('Dataset stubbed', () => { beforeEach(() => { // cy.visit('/dataset/95f8eac4-fd1f-4b35-8472-5c87e9425dfa') - cy.stubMetadata('/dataset/1234-abcd'); - cy.stubDatatable('/dataset/1234-abcd'); + cy.stubMetadata(); + cy.stubDatatable(); + cy.stubDatastoreImportInfo(); + cy.visit('/dataset/1234-abcd') }) it('I see the title and description', () => { diff --git a/cypress/integration/search-stubbed.spec.js b/cypress/integration/search-stubbed.spec.js index 5b5ca0f..f5d1c57 100644 --- a/cypress/integration/search-stubbed.spec.js +++ b/cypress/integration/search-stubbed.spec.js @@ -116,12 +116,12 @@ context('Search stubbed', () => { it('I can change the amount of results per page', () => { cy.stubSearchResults('/search'); cy.get('.dc-search-results-message').contains('10 datasets found'); - cy.get('.dataset-results-count').contains('1-10 out of 10 datasets') + cy.get('.dataset-results-count').contains('1-10 of 10 datasets') cy.get(searchList).children().its('length').should('eq', 10); cy.findByLabelText('Page Size').select('5') cy.wait(500); cy.get('.dc-search-results-message').contains('10 datasets found'); - cy.get('.dataset-results-count').contains('1-5 out of 10 datasets') + cy.get('.dataset-results-count').contains('1-5 of 10 datasets') cy.get(searchList).children().its('length').should('eq', 5); }); @@ -134,15 +134,15 @@ context('Search stubbed', () => { cy.findByLabelText('Page Size').select('5'); cy.wait(500) cy.get('.pagination').children().its('length').should('eq', 4); - cy.get('.dataset-results-count').contains('1-5 out of 10 datasets') + cy.get('.dataset-results-count').contains('1-5 of 10 datasets') cy.get('.dc-results-list ol div.dc-search-list-item:nth-child(1) h2') .should('contain', 'U.S. Tobacco Usage Statistics'); cy.findByRole('link', {name: 'Go to page number 2'}).click(); - cy.get('.dataset-results-count').contains('6-10 out of 10 datasets'); + cy.get('.dataset-results-count').contains('6-10 of 10 datasets'); cy.get('.dc-results-list ol div.dc-search-list-item:nth-child(1) h2') .should('contain', 'Afghanistan Election Districts'); cy.findByRole('link', {name: 'Go to previous page'}).click(); - cy.get('.dataset-results-count').contains('1-5 out of 10 datasets'); + cy.get('.dataset-results-count').contains('1-5 of 10 datasets'); cy.get('.dc-results-list ol div.dc-search-list-item:nth-child(1) h2') .should('contain', 'U.S. Tobacco Usage Statistics'); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 2edc0a9..21832e4 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -1,27 +1,29 @@ import '@testing-library/cypress/add-commands'; -Cypress.Commands.add('stubMetadata', (path) => { +Cypress.Commands.add('stubDatastoreImportInfo', () => { cy.server(); - cy.route(`**/metastore/schemas/dataset/items/1234-abcd?**`, 'fx:datasetMetadata') - cy.visit(path) + cy.route(/.*\/datastore\/imports.*/, 'fx:datastoreImportInfo') }); -Cypress.Commands.add('stubDatatable', (path) => { +Cypress.Commands.add('stubMetadata', () => { + cy.server(); + cy.route(/.*\/metastore\/schemas\/dataset\/items\/1234-abcd\?.*/, 'fx:datasetMetadata') +}); + +Cypress.Commands.add('stubDatatable', () => { cy.server(); cy.fixture('datasetSqlCount').then((res) => { - cy.route(/^(?=.*COUNT)(?=.*price)(?=.*3).*$/, () => ([{expression: "26"}])) - cy.route(/^(?=.*\[SELECT COUNT\(\*\) FROM 1234abcd]&show-db-columns).*$/, res) - cy.route(/^(?=.*\[SELECT COUNT\(\*\) FROM 1234abcd];&show-db-columns).*$/, res) + cy.route(/.*\[SELECT COUNT\(\*\) FROM .*/, res) + cy.route(/.*\[SELECT COUNT\(\*\) FROM .*price.*/, () => ([{expression: "26"}])) }) cy.fixture('datasetSqlResults').then((res) => { - cy.route(/^(?=.*1234abcd)(?=.*LIMIT 20).*$/, res.slice(0, 20)); - cy.route(/^(?=.*1234abcd)(?=.*LIMIT 50).*$/, res.slice(0, 50)) - cy.route(/^(?=.*1234abcd)(?=.*LIMIT 100).*$/, res.slice(0, 100)) - cy.route(/^(?=.*1234abcd)(?=.*35.08)(?=.*LIMIT 20).*$/, res.filter((item) => item.price == '35.08')) - cy.route(/^(?=.*1234abcd)(?=.*ORDER BY record_number ASC).*$/, res.slice(0, 20)) - cy.route(/^(?=.*1234abcd)(?=.*ORDER BY record_number DESC).*$/, res.reverse().slice(0, 20)) + cy.route(/.*\[SELECT \* FROM .*LIMIT 20.*/, res.slice(0, 20)); + cy.route(/.*\[SELECT \* FROM .*LIMIT 50.*/, res.slice(0, 50)) + cy.route(/.*\[SELECT \* FROM .*LIMIT 100.*/, res.slice(0, 100)) + cy.route(/.*\[SELECT \* FROM .*price =.*/, res.filter((item) => item.price == '35.08')) + cy.route(/.*\[SELECT \* FROM .*ORDER BY record_number ASC.*/, res.slice(0, 20)) + cy.route(/.*\[SELECT \* FROM .*ORDER BY record_number DESC.*/, res.reverse().slice(0, 20)) }) - cy.visit(path) }); Cypress.Commands.add('stubSearchResults', (path) => { @@ -83,4 +85,4 @@ Cypress.Commands.add('stubSearchResults', (path) => { // // // -- This is will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) \ No newline at end of file +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/package.json b/package.json index f5c6553..d45adbf 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": false, "homepage": "frontend/build", "dependencies": { - "@civicactions/data-catalog-components": "^1.4.2", + "@civicactions/data-catalog-components": "^1.5.0", "@fortawesome/fontawesome-svg-core": "^1.2.25", "@fortawesome/free-brands-svg-icons": "^5.11.2", "@fortawesome/free-solid-svg-icons": "^5.11.2", @@ -13,7 +13,7 @@ "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", - "axios": "^0.19.2", + "axios": "^0.21.1", "bootstrap": "^4.4.1", "excerpts": "^0.0.3", "node-sass": "^4.14.1",