Skip to content

Commit

Permalink
Merge branch 'fix/document-upload-error' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Nov 3, 2023
2 parents 4cce373 + b5f5752 commit deff164
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 11 deletions.
1 change: 1 addition & 0 deletions components/operators/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
/>
Expand Down
2 changes: 1 addition & 1 deletion components/ui/country-doc-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion components/ui/doc-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
36 changes: 35 additions & 1 deletion e2e/cypress/e2e/operator.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 () {
Expand All @@ -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');
Expand All @@ -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');
Expand Down
11 changes: 8 additions & 3 deletions e2e/cypress/e2e/pages.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
})
})

Expand Down
9 changes: 7 additions & 2 deletions e2e/cypress/e2e/transparency-ranking.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
})
});
1 change: 0 additions & 1 deletion e2e/cypress/e2e/user.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion e2e/cypress/support/exceptions.js
Original file line number Diff line number Diff line change
@@ -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'));
2 changes: 1 addition & 1 deletion e2e/restore-db.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit deff164

Please sign in to comment.