Skip to content

Commit

Permalink
New components (1.5.0) and axios security update. (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmizzell authored Jan 12, 2021
1 parent 73bfdc6 commit f3b7f1a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 24 deletions.
18 changes: 18 additions & 0 deletions cypress/fixtures/datastoreImportInfo.json
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 4 additions & 2 deletions cypress/integration/dataset-stubbed.spec.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
10 changes: 5 additions & 5 deletions cypress/integration/search-stubbed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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');
});
Expand Down
32 changes: 17 additions & 15 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down Expand Up @@ -83,4 +85,4 @@ Cypress.Commands.add('stubSearchResults', (path) => {
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit f3b7f1a

Please sign in to comment.