diff --git a/components/operators/filters.js b/components/operators/filters.js index 7d78aad4..7d7b9ba6 100644 --- a/components/operators/filters.js +++ b/components/operators/filters.js @@ -116,6 +116,7 @@ class OperatorsFilters extends React.Component { type="search" placeholder={this.props.intl.formatMessage({ id: f.placeholder })} className="search-input" + data-test-id={`search-input-${f.key}`} value={filters[f.key]} onChange={e => this.setSearch(e.currentTarget.value, f.key)} /> diff --git a/components/ui/country-doc-modal.js b/components/ui/country-doc-modal.js index 397806c5..6ec6e88f 100644 --- a/components/ui/country-doc-modal.js +++ b/components/ui/country-doc-modal.js @@ -215,7 +215,7 @@ class DocModal extends React.Component { name: 'file', label: intl.formatMessage({ id: 'file' }), required: !url, - default: { name: url } + default: !url ? null : { name: url } }} > {File} diff --git a/components/ui/doc-modal.js b/components/ui/doc-modal.js index f3c0e09a..b2be870c 100644 --- a/components/ui/doc-modal.js +++ b/components/ui/doc-modal.js @@ -222,7 +222,7 @@ class DocModal extends React.Component { name: 'file', label: intl.formatMessage({ id: 'file' }), required: !url, - default: { name: url } + default: !url ? null : { name: url } }} > {File} diff --git a/e2e/cypress/e2e/__image_snapshots__/Home Page content matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Home Page content matches visually #0.png index 8caa33e8..c2a6fb04 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Home Page content matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Home Page content matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages About page matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages About page matches visually #0.png index cbcfd2da..788e365e 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages About page matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages About page matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages Create account page matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages Create account page matches visually #0.png index 8371c1e6..49224d69 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages Create account page matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages Create account page matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages Create producer page matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages Create producer page matches visually #0.png index d9ca6c5c..ac608dab 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages Create producer page matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages Create producer page matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages Help page when visitng overviewmain matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages Help page when visitng overviewmain matches visually #0.png index 38581910..a91e50c3 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages Help page when visitng overviewmain matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages Help page when visitng overviewmain matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages Newsletter page matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages Newsletter page matches visually #0.png index ca8da440..7104d3bb 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages Newsletter page matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages Newsletter page matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages Terms page matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages Terms page matches visually #0.png deleted file mode 100644 index 53b98cbd..00000000 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages Terms page matches visually #0.png and /dev/null differ diff --git a/e2e/cypress/e2e/operator.cy.js b/e2e/cypress/e2e/operator.cy.js index c278df7f..49eb7580 100644 --- a/e2e/cypress/e2e/operator.cy.js +++ b/e2e/cypress/e2e/operator.cy.js @@ -78,7 +78,7 @@ describe('User', function () { .should('contains.text', '50% Provided (valid)') }) - it('can delete existing document', function () { + it('can delete existing document and reupload it', function () { cy.docExpandCategory('Legal registration'); cy.intercept('http://localhost:3000/operator-document-histories?*').as('documentsReload'); @@ -98,6 +98,27 @@ describe('User', function () { .parents('.c-doc-by-category') .find('.doc-by-category-chart') .should('contains.text', '75% Provided (valid)') + + cy.docGetProducerDocCard("Certificat d'agrément forestier") + .siblings('.c-doc-card-upload') + .contains('button', 'Add file') + .click(); + + // testing validation + cy.get('button').contains('Submit').click(); + cy.get('.c-file ~ .error').should('have.text', 'The field is required'); + cy.get('.rrt-text').should('have.text', 'Fill all the required fields'); + + cy.get('input[type=file]').attachFile('test_document.docx'); + + // cy.intercept('http://localhost:3000/operator-document-histories?*').as('documentsReload'); + cy.get('button').contains('Submit').click(); + cy.wait('@documentsReload'); + cy.wait(1000); + + cy.docGetProducerDocCard("Certificat d'agrément forestier") + .find('.doc-card-status') + .should('contains.text', 'Pending approval'); }) it('can mark document as non applicable', function () { @@ -108,6 +129,11 @@ describe('User', function () { .contains('button', 'Non applicable') .click(); + // testing validation + cy.get('button').contains('Submit').click(); + cy.get('textarea[name=reason] ~ .error').should('have.text', 'The field is required'); + cy.get('.rrt-text').should('have.text', 'Fill all the required fields'); + cy.get('#input-startDate').type('2022-03-30'); cy.get('#input-expireDate').type('2030-03-30'); cy.get('#input-reason').clear().type('Reason why this document is non applicable'); @@ -134,6 +160,14 @@ describe('User', function () { .click(); cy.contains('Add a document for the annex of Compte-rendu du conseil de concertation'); + + // testing validation + cy.get('button').contains('Submit').click(); + cy.get('input[name=name] ~ .error').should('have.text', 'The field is required'); + cy.get('input[name=startDate] ~ .error').should('have.text', 'The field is required'); + cy.get('.c-file ~ .error').should('have.text', 'The field is required'); + cy.get('.rrt-text').should('have.text', 'Fill all the required fields'); + cy.get('#input-name').type('Here is the name of annex'); cy.get('#input-startDate').type('2022-03-30'); cy.get('#input-expireDate').type('2030-03-30'); diff --git a/e2e/cypress/e2e/pages.cy.js b/e2e/cypress/e2e/pages.cy.js index 2b7e3bf2..77e2931f 100644 --- a/e2e/cypress/e2e/pages.cy.js +++ b/e2e/cypress/e2e/pages.cy.js @@ -86,12 +86,17 @@ describe('Pages', () => { }) it('displays content', function () { + cy.contains('Welcome to the Open Timber Portal. This document lets the user of these Services'); + }) + }) - cy.contains('World Resources Institute Privacy Policy'); + describe('Privacy policy page', () => { + beforeEach(() => { + cy.visit('http://localhost:4000/privacy-policy'); }) - it('matches visually', function () { - cy.matchImage(); + it('displays content', function () { + cy.contains('List of Cookies that May Be Set'); }) }) diff --git a/e2e/cypress/e2e/transparency-ranking.cy.js b/e2e/cypress/e2e/transparency-ranking.cy.js index 417b663b..7f967463 100644 --- a/e2e/cypress/e2e/transparency-ranking.cy.js +++ b/e2e/cypress/e2e/transparency-ranking.cy.js @@ -13,8 +13,13 @@ describe('Transparency ranking page', function () { describe('filters', function () { it('can filter by producer name', function () { - cy.get('.search-input').clear().type('lorem') + cy.get('[data-test-id=search-input-operator]').clear().type('lorem') cy.get('.c-ranking table tbody').find('tr').should('have.length', 1); - }) + }); + + it('can filter by fmu name', function () { + cy.get('[data-test-id=search-input-fmu]').clear().type('lopola') + cy.get('.c-table-expanded-row table tbody').find('tr').should('have.length', 1); + }); }) }); diff --git a/e2e/cypress/e2e/user.cy.js b/e2e/cypress/e2e/user.cy.js index 7c7340bb..fac7e208 100644 --- a/e2e/cypress/e2e/user.cy.js +++ b/e2e/cypress/e2e/user.cy.js @@ -55,7 +55,6 @@ describe('User', () => { cy.get('#input-name').type(`Super New Producer ${nanoid(6)}`); cy.get('#input-details').type('Producer description'); - cy.get('#select-locale .react-select__single-value').contains('English'); cy.selectOption('[name=operator_type]', 'E', 'Estate'); cy.get('#input-website').type('wrong website'); cy.get('#input-website').clear(); diff --git a/e2e/cypress/support/exceptions.js b/e2e/cypress/support/exceptions.js index 64c23698..f492afe3 100644 --- a/e2e/cypress/support/exceptions.js +++ b/e2e/cypress/support/exceptions.js @@ -1 +1,2 @@ -Cypress.on('uncaught:exception', err => !err.message.includes('ResizeObserver loop limit exceeded')) +Cypress.on('uncaught:exception', err => !err.message.includes('ResizeObserver loop limit exceeded') && + !err.message.includes('ResizeObserver loop completed with undelivered notifications')); diff --git a/e2e/restore-db.sh b/e2e/restore-db.sh index 4401e6b8..b3b1390b 100755 --- a/e2e/restore-db.sh +++ b/e2e/restore-db.sh @@ -1,7 +1,7 @@ #!/bin/sh cd ../../db -./restore.sh test_db_backup.dump fti_api_cypress +./restore-test.sh test_db_backup.dump fti_api_cypress cd ../otp-api POSTGRES_DATABASE=fti_api_cypress bundle exec rails db:migrate