diff --git a/.github/workflows/ci_check_translations.yml b/.github/workflows/ci_check_translations.yml index 3e6e08c2e0..501723bcb0 100644 --- a/.github/workflows/ci_check_translations.yml +++ b/.github/workflows/ci_check_translations.yml @@ -31,7 +31,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/ci_e2e_cypress_base.yml b/.github/workflows/ci_e2e_cypress_base.yml index 2018c42595..841b6ce2a1 100644 --- a/.github/workflows/ci_e2e_cypress_base.yml +++ b/.github/workflows/ci_e2e_cypress_base.yml @@ -41,7 +41,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} @@ -51,7 +51,7 @@ jobs: - run: sudo apt-get install poppler-utils - name: Cache build id: cache-build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./prod key: >- diff --git a/.github/workflows/ci_e2e_cypress_pages.yml b/.github/workflows/ci_e2e_cypress_pages.yml index 9710d3bc61..01c82807a3 100644 --- a/.github/workflows/ci_e2e_cypress_pages.yml +++ b/.github/workflows/ci_e2e_cypress_pages.yml @@ -41,7 +41,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} @@ -51,7 +51,7 @@ jobs: - run: sudo apt-get install poppler-utils - name: Cache build id: cache-build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./prod key: >- diff --git a/.github/workflows/ci_e2e_cypress_ssettings.yml b/.github/workflows/ci_e2e_cypress_ssettings.yml index 801adfec47..ab289b3a72 100644 --- a/.github/workflows/ci_e2e_cypress_ssettings.yml +++ b/.github/workflows/ci_e2e_cypress_ssettings.yml @@ -41,7 +41,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} @@ -51,7 +51,7 @@ jobs: - run: sudo apt-get install poppler-utils - name: Cache build id: cache-build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./prod key: >- diff --git a/.github/workflows/ci_e2e_puppeteer.yml b/.github/workflows/ci_e2e_puppeteer.yml index 5470b6edc3..f03cdd08dc 100644 --- a/.github/workflows/ci_e2e_puppeteer.yml +++ b/.github/workflows/ci_e2e_puppeteer.yml @@ -38,7 +38,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} @@ -48,7 +48,7 @@ jobs: - run: sudo apt-get install poppler-utils - name: Cache build id: cache-build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./prod key: >- diff --git a/.github/workflows/ci_eslint.yml b/.github/workflows/ci_eslint.yml index bcc80bb2ac..006b8f09d2 100644 --- a/.github/workflows/ci_eslint.yml +++ b/.github/workflows/ci_eslint.yml @@ -20,7 +20,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/ci_ts_emit_check.yml b/.github/workflows/ci_ts_emit_check.yml index 79ba13c775..43d4deee50 100644 --- a/.github/workflows/ci_ts_emit_check.yml +++ b/.github/workflows/ci_ts_emit_check.yml @@ -20,7 +20,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/ci_ts_types.yml b/.github/workflows/ci_ts_types.yml index d32e0b1f40..e402cce149 100644 --- a/.github/workflows/ci_ts_types.yml +++ b/.github/workflows/ci_ts_types.yml @@ -20,7 +20,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/ci_unit_tests.yml b/.github/workflows/ci_unit_tests.yml index 64474aa49a..1b99d6d5ca 100644 --- a/.github/workflows/ci_unit_tests.yml +++ b/.github/workflows/ci_unit_tests.yml @@ -53,7 +53,7 @@ jobs: mongodb-port: 27017 - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} @@ -87,7 +87,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/create_pre_release.yml b/.github/workflows/create_pre_release.yml index 5c4aa416ca..0db9814cf2 100644 --- a/.github/workflows/create_pre_release.yml +++ b/.github/workflows/create_pre_release.yml @@ -30,7 +30,7 @@ jobs: run: yarn install - name: Cache build id: cache-build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./prod key: ${{ runner.os }}-build-${{ hashFiles('app/**/*.*') }}-${{ hashFiles('database/**/*.*') }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/run.js') }}-${{ hashFiles('**/server.js') }} diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 915cac872a..322197095d 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -30,7 +30,7 @@ jobs: run: yarn install - name: Cache build id: cache-build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./prod key: ${{ runner.os }}-build-${{ hashFiles('app/**/*.*') }}-${{ hashFiles('database/**/*.*') }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/run.js') }}-${{ hashFiles('**/server.js') }} diff --git a/.github/workflows/create_testing_release.yml b/.github/workflows/create_testing_release.yml index ce5f0db443..e65d360a1d 100644 --- a/.github/workflows/create_testing_release.yml +++ b/.github/workflows/create_testing_release.yml @@ -30,7 +30,7 @@ jobs: run: yarn install - name: Cache build id: cache-build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./prod key: ${{ runner.os }}-build-${{ hashFiles('app/**/*.*') }}-${{ hashFiles('database/**/*.*') }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/run.js') }}-${{ hashFiles('**/server.js') }} diff --git a/.github/workflows/security_audit.yml b/.github/workflows/security_audit.yml index 936ca144e3..9effb9eaeb 100644 --- a/.github/workflows/security_audit.yml +++ b/.github/workflows/security_audit.yml @@ -18,7 +18,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./node_modules key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/cypress/cypress.d.ts b/cypress/cypress.d.ts index 05ad829cea..e4bd25c5bf 100644 --- a/cypress/cypress.d.ts +++ b/cypress/cypress.d.ts @@ -14,8 +14,14 @@ declare global { interface Chainable { selection(subject: string, fn: any): Chainable; setSelection(subject: string, query?: string | object, endQuery?: any[]): Chainable; - clearAndType(selector: string, value: string, options? = {}): Chainable; - addTimeLink(duration: number, label: string, index?: number): Chainable; + clearAndType(selector: string, value: string, options?): Chainable; + addTimeLink( + duration: number, + label: string, + index?: number, + seconds?: number, + minutes?: number + ): Chainable; blankState(): Chainable; getByTestId(id: string): Chainable; shouldNotBeActionable( @@ -26,6 +32,7 @@ declare global { ): Chainable; checkAccessibility(components: React.ReactNode[]); realDragAndDrop(subject: Chainable, target: Chainable): void; + waitForLegacyNotifications(); // setCursor(subject: string, options?: Partial): Chainable; // setCursorBefore(subject: string, options?: Partial): Chainable; // setCursorAfter(subject: string, options?: Partial): Chainable; diff --git a/cypress/e2e/__image_snapshots__/Entities Entity Metadata should have all the values correctly saved. #0.png b/cypress/e2e/__image_snapshots__/Entities Entity Metadata should have all the values correctly saved. #0.png new file mode 100644 index 0000000000..602d5cc314 Binary files /dev/null and b/cypress/e2e/__image_snapshots__/Entities Entity Metadata should have all the values correctly saved. #0.png differ diff --git a/cypress/e2e/__image_snapshots__/Entities Media properties should allow add timelinks to an existing entity media property #0.png b/cypress/e2e/__image_snapshots__/Entities Media properties should allow add timelinks to an existing entity media property #0.png new file mode 100644 index 0000000000..1a873a8af9 Binary files /dev/null and b/cypress/e2e/__image_snapshots__/Entities Media properties should allow add timelinks to an existing entity media property #0.png differ diff --git a/cypress/e2e/__image_snapshots__/Entities Media properties should render the player for internal media on library card and entity view #0.png b/cypress/e2e/__image_snapshots__/Entities Media properties should render the player for internal media on library card and entity view #0.png new file mode 100644 index 0000000000..bdbe0304b4 Binary files /dev/null and b/cypress/e2e/__image_snapshots__/Entities Media properties should render the player for internal media on library card and entity view #0.png differ diff --git a/cypress/e2e/__image_snapshots__/Entities Media properties should show an error for an invalid property and allow to replace it for a valid one #1.png b/cypress/e2e/__image_snapshots__/Entities Media properties should show an error for an invalid property and allow to replace it for a valid one #1.png new file mode 100644 index 0000000000..32d610b52b Binary files /dev/null and b/cypress/e2e/__image_snapshots__/Entities Media properties should show an error for an invalid property and allow to replace it for a valid one #1.png differ diff --git a/cypress/e2e/__image_snapshots__/Entities Media properties should show the external player on library card and entity view #0.png b/cypress/e2e/__image_snapshots__/Entities Media properties should show the external player on library card and entity view #0.png new file mode 100644 index 0000000000..bb5024a43a Binary files /dev/null and b/cypress/e2e/__image_snapshots__/Entities Media properties should show the external player on library card and entity view #0.png differ diff --git a/cypress/e2e/__image_snapshots__/Entities Metadata should have all the values correctly saved. #0.png b/cypress/e2e/__image_snapshots__/Entities Metadata should have all the values correctly saved. #0.png new file mode 100644 index 0000000000..268e0ab24e Binary files /dev/null and b/cypress/e2e/__image_snapshots__/Entities Metadata should have all the values correctly saved. #0.png differ diff --git a/cypress/e2e/__image_snapshots__/Entities Metadata should have all the values correctly saved. #1.png b/cypress/e2e/__image_snapshots__/Entities Metadata should have all the values correctly saved. #1.png new file mode 100644 index 0000000000..32d610b52b Binary files /dev/null and b/cypress/e2e/__image_snapshots__/Entities Metadata should have all the values correctly saved. #1.png differ diff --git a/cypress/e2e/__image_snapshots__/Entity with main documents should create a reference from main document #0.png b/cypress/e2e/__image_snapshots__/Entity with main documents should create a reference from main document #0.png new file mode 100644 index 0000000000..6e33f8614d Binary files /dev/null and b/cypress/e2e/__image_snapshots__/Entity with main documents should create a reference from main document #0.png differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should allow add timelinks to an existing entity media property #0.png b/cypress/e2e/__image_snapshots__/Media metadata should allow add timelinks to an existing entity media property #0.png deleted file mode 100644 index 26399d8d8b..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should allow add timelinks to an existing entity media property #0.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should allow add timelinks to an existing entity media property #1.png b/cypress/e2e/__image_snapshots__/Media metadata should allow add timelinks to an existing entity media property #1.png deleted file mode 100644 index abee2ec107..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should allow add timelinks to an existing entity media property #1.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should allow edit media created with timelinks #0.png b/cypress/e2e/__image_snapshots__/Media metadata should allow edit media created with timelinks #0.png deleted file mode 100644 index ff3daa0549..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should allow edit media created with timelinks #0.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should allow media selection on entity creation #0.png b/cypress/e2e/__image_snapshots__/Media metadata should allow media selection on entity creation #0.png deleted file mode 100644 index 5848fdf625..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should allow media selection on entity creation #0.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should allow media selection on entity creation #1.png b/cypress/e2e/__image_snapshots__/Media metadata should allow media selection on entity creation #1.png deleted file mode 100644 index e9e520e0d0..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should allow media selection on entity creation #1.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should allow media selection with timelinks on entity creation #0.png b/cypress/e2e/__image_snapshots__/Media metadata should allow media selection with timelinks on entity creation #0.png deleted file mode 100644 index fed5f53253..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should allow media selection with timelinks on entity creation #0.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should allow remove a timelink from a media property #0.png b/cypress/e2e/__image_snapshots__/Media metadata should allow remove a timelink from a media property #0.png deleted file mode 100644 index b340226bdb..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should allow remove a timelink from a media property #0.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should allow set an external link from a media property #0.png b/cypress/e2e/__image_snapshots__/Media metadata should allow set an external link from a media property #0.png deleted file mode 100644 index eb1fe44bb7..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should allow set an external link from a media property #0.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should show an error for an invalid property and allow to replace it for a valid one #0.png b/cypress/e2e/__image_snapshots__/Media metadata should show an error for an invalid property and allow to replace it for a valid one #0.png deleted file mode 100644 index 5848fdf625..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should show an error for an invalid property and allow to replace it for a valid one #0.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata should show an error for an invalid property and allow to replace it for a valid one #1.png b/cypress/e2e/__image_snapshots__/Media metadata should show an error for an invalid property and allow to replace it for a valid one #1.png deleted file mode 100644 index e9e520e0d0..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata should show an error for an invalid property and allow to replace it for a valid one #1.png and /dev/null differ diff --git a/cypress/e2e/__image_snapshots__/Media metadata thumbnails should render a generic thumbnail for internal media #0.png b/cypress/e2e/__image_snapshots__/Media metadata thumbnails should render a generic thumbnail for internal media #0.png deleted file mode 100644 index 264a9024f4..0000000000 Binary files a/cypress/e2e/__image_snapshots__/Media metadata thumbnails should render a generic thumbnail for internal media #0.png and /dev/null differ diff --git a/cypress/e2e/entity.cy.ts b/cypress/e2e/entity.cy.ts index 8670c12991..a6d5be9083 100644 --- a/cypress/e2e/entity.cy.ts +++ b/cypress/e2e/entity.cy.ts @@ -1,17 +1,7 @@ -/* eslint-disable max-statements */ -/* eslint-disable max-lines */ import { clearCookiesAndLogin } from './helpers/login'; -import { changeLanguage } from './helpers/language'; -import { - clickOnCreateEntity, - clickOnEditEntity, - saveEntity, - selectRestrictedEntities, -} from './helpers'; +import { changeLanguage, clickOnEditEntity, saveEntity } from './helpers'; -const filesAttachments = ['./cypress/test_files/valid.pdf', './cypress/test_files/batman.jpg']; - -const entityTitle = 'Entity with supporting files'; +const entityTitle = 'Entity with all props'; const textWithHtml = `

The title

I am a link to an external site @@ -25,9 +15,102 @@ const textWithHtml = `

The title

  • List item 2
  • `; -const webAttachments = { - name: 'Resource from web', - url: 'https://fonts.googleapis.com/icon?family=Material+Icons', +const clickMediaAction = (field: string, action: string) => { + cy.contains(`.form-group.${field.toLowerCase()}`, field).contains('button', action).focus(); + cy.contains(`.form-group.${field.toLowerCase()}`, field) + .contains('button', action) + .click({ force: true }); +}; + +const addVideo = (action: string, local: boolean = true) => { + if (action) { + clickMediaAction('Media', action); + } + cy.contains('Select from computer'); + if (local) { + cy.get('.upload-button input[type=file]') + .last() + .selectFile('./cypress/test_files/short-video.mp4', { + force: true, + }); + } else { + cy.get('input[name="urlForm.url"]').type( + 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/Sintel.mp4', + { delay: 0 } + ); + cy.contains('button', 'Add from URL').click(); + } + + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(2000); + cy.contains('.form-group.media', 'Media').scrollIntoView(); + cy.contains('.form-group.media', 'Media').within(() => { + cy.get('video').should('be.visible'); + }); +}; + +const addImage = () => { + clickMediaAction('Image', 'Add file'); + cy.contains('button', 'Select from computer'); + cy.get('.upload-button input[type=file]').first().selectFile('./cypress/test_files/batman.jpg', { + force: true, + }); + // wait for image + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(200); + cy.contains('.form-group.image', 'Image').scrollIntoView(); + cy.contains('.form-group.image', 'Image').within(() => { + cy.get('img').should('be.visible'); + }); +}; + +const addInvalidVideoFile = (field: string) => { + cy.contains(`.form-group.${field.toLowerCase()}`, field).contains('button', 'Add file').click(); + cy.contains('button', 'Select from computer'); + cy.get('.upload-button input[type=file]').first().selectFile('./cypress/test_files/sample.pdf', { + force: true, + }); + cy.contains(field) + .parentsUntil('.form-group') + .contains('This file type is not supported on media fields') + .scrollIntoView(); + cy.contains(field) + .parentsUntil('.form-group') + .contains('This file type is not supported on media fields') + .should('be.visible'); +}; + +const addInvalidImageFile = (field: string) => { + cy.contains(`.form-group.${field.toLowerCase()}`, field).contains('button', 'Add file').click(); + cy.contains('button', 'Select from computer'); + cy.get('.upload-button input[type=file]').first().selectFile('./cypress/test_files/sample.pdf', { + force: true, + }); + cy.contains(field) + .parentsUntil('.form-group') + .contains('Error loading your image') + .scrollIntoView(); + cy.contains(field) + .parentsUntil('.form-group') + .contains('Error loading your image') + .should('be.visible'); +}; + +const checkMediaSnapshots = (selector: string, options = {}) => { + cy.get(selector).scrollIntoView({ offset: { top: -30, left: 0 } }); + cy.get(selector).toMatchImageSnapshot({ + ...options, + disableTimersAndAnimations: true, + threshold: 0.08, + }); +}; + +const checkExternalMedia = () => { + cy.get('video').should( + 'have.attr', + 'src', + 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/Sintel.mp4' + ); }; describe('Entities', () => { @@ -35,383 +118,432 @@ describe('Entities', () => { const env = { DATABASE_NAME: 'uwazi_e2e', INDEX_NAME: 'uwazi_e2e' }; cy.exec('yarn e2e-fixtures', { env }); clearCookiesAndLogin(); + cy.intercept('GET', 'api/files/*').as('getFile'); }); - it('Should create new entity', () => { - clickOnCreateEntity(); - cy.get('[name="library.sidepanel.metadata.title"]').click(); - cy.get('[name="library.sidepanel.metadata.title"]').type('Test entity', { delay: 0 }); - saveEntity(); - }); + describe('Template Medatada', () => { + it('should log in as admin then click the settings nav button.', () => { + cy.contains('a', 'Settings').click(); + cy.url().should('include', '/en/settings/account'); + }); - describe('Rich text fields', () => { - it('should create an entity with HTML on a rich text field', () => { - clickOnCreateEntity(); - cy.get('[name="library.sidepanel.metadata.title"]').click(); - cy.get('[name="library.sidepanel.metadata.title"]').type('Entity with HTML', { delay: 0 }); - cy.get('#metadataForm').find('select').select('Reporte', { timeout: 100 }); + it('should test number of available properties.', () => { + cy.get('a').contains('Templates').click(); + cy.get('a').contains('Add template').click(); + cy.get('.property-options-list li').should('have.length', 13); + }); - cy.get('#tabpanel-edit > textarea').type(textWithHtml, { delay: 0 }); - saveEntity(); + it('should create a template with all the properties', () => { + cy.get('a').contains('Templates').click(); + cy.get('a').contains('Add template').click(); + cy.get('input[name="template.data.name"]').type('All props', { delay: 0 }); + + cy.get('.property-options-list li button').each(($btn, index) => { + //intentionaly leaving the last fields out of the test: violated articles (nested), generated id. + if (index < 11) { + cy.wrap($btn).click(); + } + }); + cy.contains('.metadataTemplate span', /^Date$/) + .siblings() + .contains('button', 'Edit') + .click(); + cy.clearAndType('#property-label', 'Single Date', { delay: 0 }); + + cy.contains('.metadataTemplate span', 'Relationship') + .siblings() + .contains('button', 'Edit') + .click(); + cy.contains('Any entity or document'); + cy.contains('.metadataTemplate', 'Relationship').get('select').eq(1).select(1); + cy.contains('span', 'Media').siblings().contains('button', 'Edit').click(); + cy.contains('span', 'Show in cards').click(); }); - it('should check that the HTML is show as expected', () => { - cy.contains('h1', 'The title').should('exist'); - cy.contains('a', 'I am a link to an external site').should('exist'); - cy.contains('.someClass > li:nth-child(1)', 'List item 1').should('exist'); - cy.contains('.someClass > li:nth-child(2)', 'List item 2').should('exist'); + it('should add another select of type multiselect', () => { + cy.get('li.list-group-item:nth-child(3) > button:nth-child(1)').click(); + cy.get( + '.metadataTemplate-list > li:nth-child(15) > div:nth-child(1) > div:nth-child(2) > button' + ) + .contains('Edit') + .click(); + cy.clearAndType('#property-label', 'Multiselect', { delay: 0 }); + cy.get('#property-type').select('Multiple select'); }); - it('should navigate to an entity via the rich text field link', () => { - cy.contains('a', 'I am a link to the Tracy Robinson entity').click(); - cy.contains('.content-header-title > h1:nth-child(1)', 'Tracy Robinson').should('exist'); + it('should add multidate, date range and multidate range', () => { + for (let index = 0; index < 4; index += 1) { + cy.get('li.list-group-item:nth-child(5) > button:nth-child(1)').click(); + } + + cy.get('.metadataTemplate-list > li:nth-child(10)').scrollIntoView(); + cy.contains('.metadataTemplate-list > li:nth-child(16) span', 'Date').scrollIntoView(); + cy.contains('.metadataTemplate-list > li:nth-child(16) span', 'Date') + .siblings() + .contains('button', 'Edit') + .click(); + cy.clearAndType('#property-label', 'Multi Date', { delay: 0 }); + cy.get('#property-type').select('Multiple date'); + + cy.contains('.metadataTemplate-list > li:nth-child(17) span', 'Date') + .siblings() + .contains('button', 'Edit') + .click(); + cy.clearAndType('#property-label', 'Date Range', { delay: 0 }); + cy.get('#property-type').select('Single date range'); + + cy.contains('.metadataTemplate-list > li:nth-child(18) span', 'Date') + .siblings() + .contains('button', 'Edit') + .click(); + cy.clearAndType('#property-label', 'Multi Date Range', { delay: 0 }); + cy.get('#property-type').select('Multiple date range'); + + cy.get('button').contains('Save').click(); + cy.get('div.alert-success').should('exist'); + }); + + it('should not allow duplicated properties', () => { + cy.get('.property-options-list li:first-child button').click(); + cy.get('button').contains('Save').click(); + cy.get('.alert.alert-danger').should('exist'); }); }); - describe('Entity with files in metadata fields', () => { - it('should create and entity with and image in a metadata field', () => { + describe('Entity Metadata', () => { + it('should create an entity filling all the props.', () => { cy.contains('a', 'Library').click(); - selectRestrictedEntities(); - clickOnCreateEntity(); - cy.get('[name="library.sidepanel.metadata.title"]').click(); - cy.get('[name="library.sidepanel.metadata.title"]').type('Entity with media files', { - delay: 0, + cy.get('button').contains('Create entity').click(); + cy.get('textarea[name="library.sidepanel.metadata.title"]').should('not.be.disabled'); + cy.get('textarea[name="library.sidepanel.metadata.title"]').type(entityTitle, { delay: 0 }); + cy.contains('#metadataForm', 'Type').get('select').eq(0).select('All props'); + cy.get('select:first-of-type').select('All props'); + cy.get('.form-group.text input').type('demo text', { delay: 0 }); + cy.get('.form-group.numeric input').type('42', { delay: 0 }); + + cy.contains('.form-group.select', 'Select').within(() => { + cy.get('select').select('Activo'); }); - cy.get('#metadataForm').find('select').select('Reporte', { force: true }); - cy.get('#tabpanel-edit > textarea').type('A description of the report', { delay: 0 }); - cy.get( - '#metadataForm > div:nth-child(3) > div:nth-child(4) > ul > li.wide > div > div > div > button' - ).click(); - cy.get('input[aria-label=fileInput]').first().selectFile('./cypress/test_files/batman.jpg', { - force: true, + + cy.contains('.form-group.relationship', 'Relationship').within(() => { + cy.contains('19 Comerciantes').click(); }); - saveEntity(); - }); - it('should edit the entity to add a video on a metadata field', () => { - cy.contains('.item-document', 'Entity with media files').click(); - clickOnEditEntity(); + cy.contains('.form-group.date', 'Single Date').within(() => { + cy.get('input').type('08/09/1966', { delay: 0 }); + }); + + addImage(); + addVideo('Add file'); + cy.addTimeLink(1000, 'Second one'); + cy.get('.leaflet-container').click(200, 100); + cy.get('.leaflet-container').click(200, 100); + cy.get('.leaflet-marker-icon').should('have.length', 1); + + cy.contains('.form-group.multiselect', 'Multiselect').within(() => { + cy.contains('Activo').click(); + }); + + cy.get('.form-group.daterange div.DatePicker__From input').type('23/11/1963', { delay: 0 }); + cy.get('.form-group.daterange div.DatePicker__To input').type('12/09/1964', { delay: 0 }); + cy.get('.form-group.multidate button.btn.add').click(); + cy.get('.form-group.multidate .multidate-item:first-of-type input').type('23/11/1963', { + delay: 0, + }); + cy.get('.form-group.multidate .multidate-item:nth-of-type(2) input').type('12/09/1964', { + delay: 0, + }); + cy.get('.form-group.multidaterange button.btn.add').click(); + cy.get('.form-group.link #label').type('Huridocs', { delay: 0 }); + cy.get('.form-group.link #url').scrollIntoView(); + cy.get('.form-group.link #url').type('https://www.huridocs.org/', { delay: 0 }); cy.get( - '#metadataForm > div:nth-child(3) > div.form-group.media > ul > li.wide > div > div > div > button' - ).click(); - cy.contains('Select from computer'); - cy.get('input[aria-label=fileInput]') - .first() - .selectFile('./cypress/test_files/short-video.webm', { - force: true, - timeout: 1000, - }); - saveEntity('Entity updated'); - cy.get('.sidepanel-body.scrollable').scrollTo('top'); - cy.get('.metadata-sidepanel.is-active .closeSidepanel').click(); + '.form-group.multidaterange .multidate-item:first-of-type div.DatePicker__From input' + ).type('23/11/1963', { delay: 0 }); + cy.get( + '.form-group.multidaterange .multidate-item:first-of-type div.DatePicker__To input' + ).type('12/09/1964', { delay: 0 }); + cy.get( + '.form-group.multidaterange .multidate-item:nth-of-type(2) div.DatePicker__From input' + ).type('23/11/1963', { delay: 0 }); + cy.get( + '.form-group.multidaterange .multidate-item:nth-of-type(2) div.DatePicker__To input' + ).type('12/09/1964', { delay: 0 }); + cy.get('.form-group.markdown textarea').type(textWithHtml, { delay: 0 }); + saveEntity(); + cy.waitForLegacyNotifications(); }); - it('should check the entity', () => { - cy.contains('.item-name span', 'Entity with media files').click(); - cy.get('.metadata-name-descripci_n > dd > div > p').should( + it('should have all the values correctly saved.', () => { + cy.contains('.item-document:nth-child(1) span', 'Entity with all props').click(); + cy.get('.metadata-type-text').should('contain.text', 'demo text'); + cy.get('.metadata-type-numeric').should('contain.text', '42'); + cy.get('.metadata-type-select').should('contain.text', 'Activo'); + cy.get('.metadata-type-multiselect').should('contain.text', 'Activo'); + cy.get('.metadata-type-relationship').should('contain.text', '19 Comerciantes'); + cy.get('.metadata-type-date').should('contain.text', 'Sep 8, 1966'); + cy.get('.metadata-type-daterange').should( 'contain.text', - 'A description of the report' + 'Date RangeNov 23, 1963 ~ Sep 12, 1964' ); - cy.get('.metadata-name-fotograf_a > dd > img') + cy.get('.metadata-type-multidate').should( + 'contain.text', + 'Multi DateNov 23, 1963Sep 12, 1964' + ); + cy.contains('.metadata-type-multidaterange', 'Multi Date RangeNov 23, 1963 ~ Sep 12, 1964'); + cy.get('.metadata-type-link a') + .should('have.text', 'Huridocs') + .and('have.attr', 'href', 'https://www.huridocs.org/'); + cy.get('.side-panel.is-active .sidepanel-body.scrollable').scrollTo(0, 1300); + checkMediaSnapshots('#tabpanel-metadata .metadata-type-multimedia.metadata-name-media'); + cy.get('.leaflet-container').scrollIntoView(); + cy.get('.leaflet-marker-icon').should('have.length', 1); + }); + + it('should check that the HTML is show as expected', () => { + cy.contains('h1', 'The title').should('exist'); + cy.contains('a', 'I am a link to an external site').should('exist'); + cy.contains('.someClass > li:nth-child(1)', 'List item 1').should('exist'); + cy.contains('.someClass > li:nth-child(2)', 'List item 2').should('exist'); + }); + + it('should check the media properties', () => { + cy.get('.metadata-name-image > dd > img') .should('have.prop', 'src') .and('match', /\w+\/api\/files\/\w+\.jpg$/); - cy.get('.metadata-sidepanel .sidepanel-body').scrollTo('bottom'); - cy.contains('.metadata-name-video', 'Video').within(() => { + cy.contains('#tabpanel-metadata .metadata-name-media', 'Media').scrollIntoView(); + cy.contains('#tabpanel-metadata .metadata-name-media', 'Media').within(() => { cy.get('video') .should('have.prop', 'src') .and('match', /^blob:http:\/\/localhost:3000\/[\w-]+$/); }); - const expectedNewEntityFiles = ['batman.jpg', 'short-video.webm']; + const expectedNewEntityFiles = ['batman.jpg', 'short-video.mp4']; cy.get('.attachment-name span:not(.attachment-size)').each((element, index) => { const content = element.text(); cy.wrap(content).should('eq', expectedNewEntityFiles[index]); }); }); + + it('should navigate to an entity via the rich text field link', () => { + cy.contains('a', 'I am a link to the Tracy Robinson entity').click(); + cy.contains('.content-header-title > h1:nth-child(1)', 'Tracy Robinson').should('exist'); + }); }); - describe('supporting files and main documents', () => { - describe('Entity with supporting files', () => { - it('Should create a new entity with supporting files', () => { - cy.get('.metadata-sidepanel.is-active .closeSidepanel').click(); - cy.contains('a', 'Library').click(); - selectRestrictedEntities(); - clickOnCreateEntity(); - cy.contains('button', 'Add file').click(); - cy.get('#tab-uploadComputer').click(); - cy.get('input[aria-label="fileInput"]').first().selectFile(filesAttachments[0], { - force: true, - }); - cy.contains('button', 'Add file').click(); - cy.get('#tab-uploadComputer').click(); - cy.get('input[aria-label="fileInput"]').first().selectFile(filesAttachments[1], { - force: true, - }); - clickOnCreateEntity(); - cy.get('[name="library.sidepanel.metadata.title"]').click(); - cy.get('[name="library.sidepanel.metadata.title"]').type(entityTitle, { - delay: 0, - }); - cy.contains('button', 'Add file').click(); - cy.get('#tab-uploadComputer').click(); - cy.get('input[aria-label="fileInput"]').first().selectFile(filesAttachments[0], { - force: true, - }); - cy.contains('button', 'Add file').click(); - cy.get('#tab-uploadComputer').click(); - cy.get('input[aria-label="fileInput"]').first().selectFile(filesAttachments[1], { - force: true, - }); - cy.contains('button', 'Add file').click(); - cy.contains('.tab-link', 'Add from web').click(); - cy.get('.web-attachment-url').click(); - cy.get('.web-attachment-url').type(webAttachments.url, { delay: 0 }); - cy.get('.web-attachment-name').click(); - cy.get('.web-attachment-name').type(webAttachments.name, { delay: 0 }); - cy.contains('button', 'Add from URL').click(); - - cy.contains('button', 'Save').click(); - cy.contains('.item-document', entityTitle).click(); - const expectedNewFiles = ['batman.jpg', 'Resource from web', 'valid.pdf']; - cy.get('.attachment-name span:not(.attachment-size)').each((element, index) => { - const content = element.text(); - cy.wrap(content).should('eq', expectedNewFiles[index]); - }); - }); + describe('Media properties', () => { + it('should allow add timelinks to an existing entity media property', () => { + cy.contains('a', 'Library').click(); + cy.contains('.item-document:nth-child(1) span', 'Entity with all props').click(); + cy.contains('Text'); + cy.intercept('GET', 'api/files/*').as('getFile'); + clickOnEditEntity(); + cy.wait('@getFile'); + cy.get('.side-panel.is-active .sidepanel-body.scrollable').scrollTo(0, 1000); + cy.addTimeLink(1000, 'Control point', 1, 12, 0); + saveEntity('Entity updated'); + cy.waitForLegacyNotifications(); + checkMediaSnapshots('#tabpanel-metadata .video-container > div:nth-child(2)'); + }); - it('should rename a supporting file', () => { - cy.contains('.item-document', entityTitle).click(); - clickOnEditEntity(); - cy.get('input[name="library.sidepanel.metadata.attachments.2.originalname"]').clear(); - cy.get('input[name="library.sidepanel.metadata.attachments.2.originalname"]').type( - 'My PDF.pdf', - { delay: 0 } - ); - cy.contains('button', 'Save').click(); - cy.contains('.item-document', entityTitle).click(); - const expectedRenamedFiles = ['batman.jpg', 'My PDF.pdf', 'Resource from web']; - cy.get('.attachment-name span:not(.attachment-size)').each((element, index) => { - const content = element.text(); - cy.wrap(content).should('eq', expectedRenamedFiles[index]); - }); + it('should render the player for internal media on library card and entity view', () => { + cy.contains('.item-document:nth-child(1)', 'Entity with all props').toMatchImageSnapshot(); + cy.contains('.item-document:nth-child(1)', 'Entity with all props').contains('View').click(); + cy.contains('h1', 'Entity with all props'); + cy.get('.react-player').within(() => { + cy.get('video', { timeout: 1000 }); }); + }); - it('should delete the first supporting file', () => { - cy.contains('.item-document', entityTitle).click(); - clickOnEditEntity(); - cy.get('.delete-supporting-file').eq(0).click(); - cy.contains('button', 'Save').click(); - cy.contains('.item-document', entityTitle).click(); - const expectedSupportingFiles = ['My PDF.pdf', 'Resource from web']; - cy.get('.attachment-name span:not(.attachment-size)').each((element, index) => { - const content = element.text(); - cy.wrap(content).should('eq', expectedSupportingFiles[index]); - }); - }); + it('should allow set an external link from a media property', () => { + cy.contains('a', 'Library').click(); + cy.intercept('GET', 'api/files/*').as('getFile'); + cy.contains('.item-document:nth-child(1) span', 'Entity with all props').click(); + clickOnEditEntity(); + cy.get('.side-panel.is-active .sidepanel-body.scrollable').scrollTo(0, 1500); + cy.contains('Update'); + cy.wait('@getFile'); + cy.wait('@getFile'); + clickMediaAction('Media', 'Update'); + addVideo('', false); + cy.contains('button', 'Add timelink').click(); + cy.clearAndType('input[name="timelines.0.timeMinutes"]', '09', { delay: 0 }); + cy.clearAndType('input[name="timelines.0.timeSeconds"]', '57', { delay: 0 }); + cy.clearAndType('input[name="timelines.0.label"]', 'Dragon', { delay: 0 }); + saveEntity('Entity updated'); + checkExternalMedia(); }); - describe('Entity with main documents', () => { - it('Should create a new entity with a main documents', () => { - cy.get('.metadata-sidepanel.is-active .closeSidepanel').click(); - cy.contains('a', 'Library').click(); - selectRestrictedEntities(); - clickOnCreateEntity(); - cy.get('textarea[name="library.sidepanel.metadata.title"]').click(); - cy.get('textarea[name="library.sidepanel.metadata.title"]').type( - 'Entity with main documents', - { delay: 0 } - ); - cy.get('input[name="library.sidepanel.metadata.metadata.resumen"]').click(); - cy.get('input[name="library.sidepanel.metadata.metadata.resumen"]').type( - 'An entity with main documents', - { delay: 0 } - ); - cy.get('.document-list-parent > input') - .first() - .selectFile('./cypress/test_files/valid.pdf', { - force: true, - }); - saveEntity(); - }); + it('should show the external player on library card and entity view', () => { + cy.contains('.item-document:nth-child(1)', 'Entity with all props').toMatchImageSnapshot(); + cy.contains('.item-document:nth-child(1)', 'Entity with all props').contains('View').click(); + cy.contains('h1', 'Entity with all props'); + checkExternalMedia(); + }); - it('should create a reference from main document', () => { - cy.contains('a', 'Library').click(); - cy.contains('.item-document', 'Entity with main documents').within(() => { - cy.get('.view-doc').click(); - }); - cy.contains('span', 'La Sentencia de fondo'); - cy.get('#p3R_mc24 > span:nth-child(2)').realClick({ clickCount: 3 }); - cy.get('.fa-file', { timeout: 5000 }).then(() => { - cy.get('.fa-file').realClick(); - }); - cy.contains('.create-reference', 'Relacionado a').should('be.visible'); - cy.contains('li.multiselectItem', 'Relacionado a').realClick(); - cy.get('aside.create-reference input').type('Patrick Robinson', { timeout: 5000 }); - cy.contains('Tracy Robinson', { timeout: 5000 }); - cy.contains('.item-name', 'Patrick Robinson', { timeout: 5000 }).realClick(); - cy.contains('aside.create-reference .btn-success', 'Save', { timeout: 5000 }).click({ - timeout: 5000, - }); - cy.contains('Saved successfully.'); - cy.get('#p3R_mc0').scrollIntoView(); - cy.get('.row').toMatchImageSnapshot(); - }); + it('should show an error for an invalid property and allow to replace it for a valid one', () => { + cy.contains('a', 'Library').click(); + cy.contains('.item-document:nth-child(1) span', 'Entity with all props').click(); + clickOnEditEntity(); + clickMediaAction('Image', 'Unlink'); + addInvalidImageFile('Image'); + clickMediaAction('Media', 'Unlink'); + addInvalidVideoFile('Media'); - it('should edit the entity and the documents', () => { - cy.contains('a', 'Library').click(); - cy.contains('.item-document', 'Entity with main documents').click(); - cy.contains('.metadata-type-text', 'An entity with main documents').click(); - clickOnEditEntity(); - cy.get('input[name="library.sidepanel.metadata.documents.0.originalname"]').click(); - cy.get('input[name="library.sidepanel.metadata.documents.0.originalname"]').clear(); - cy.get('input[name="library.sidepanel.metadata.documents.0.originalname"]').type( - 'Renamed file.pdf', - { delay: 0 } - ); - cy.get('.document-list-parent > input') - .first() - .selectFile('./cypress/test_files/invalid.pdf', { - force: true, - }); - saveEntity('Entity updated'); - cy.contains('.item-document', 'Entity with main documents').click(); - cy.contains('.file-originalname', 'Renamed file.pdf').should('exist'); - cy.contains('.file-originalname', 'invalid.pdf').should('exist'); + clickMediaAction('Image', 'Unlink'); + addImage(); + clickMediaAction('Media', 'Unlink'); + addVideo('Add file'); + saveEntity('Entity updated'); + + cy.get('.metadata-name-image > dd > img') + .should('have.prop', 'src') + .and('match', /\w+\/api\/files\/\w+\.jpg$/); + cy.contains('#tabpanel-metadata .metadata-name-media', 'Media').scrollIntoView(); + cy.contains('#tabpanel-metadata .metadata-name-media', 'Media').within(() => { + cy.get('video') + .should('have.prop', 'src') + .and('match', /^blob:http:\/\/localhost:3000\/[\w-]+$/); }); + }); - it('should delete the invalid document', () => { - clickOnEditEntity(); - cy.get('.attachments-list > .attachment:nth-child(2) > button').click(); - cy.contains('button', 'Save').click(); - cy.contains('Entity updated').as('successMessage'); - cy.get('@successMessage').should('not.exist'); - cy.contains('.item-document', 'Entity with main documents').click(); - cy.contains('.file-originalname', 'Renamed file.pdf').should('exist'); - cy.contains('.file-originalname', 'invalid.pdf').should('not.exist'); + it('should allow unlink the value of a media property', () => { + clickOnEditEntity(); + clickMediaAction('Image', 'Unlink'); + clickMediaAction('Media', 'Unlink'); + saveEntity('Entity updated'); + cy.waitForLegacyNotifications(); + }); + }); + + describe('Thesauri values shortcut', () => { + it('should add a thesauri value on a single select field and select it', () => { + cy.contains('.item-document:nth-child(1) span', 'Entity with all props').click(); + clickOnEditEntity(); + // wait for the thesauri values to load + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(200); + cy.contains('Type'); + cy.contains( + '#metadataForm > div:nth-child(3) > .form-group.select > ul > .wide > div > div > button > span', + 'add value' + ).click(); + cy.contains('.modal-content', 'Add thesaurus value'); + cy.get('input[name=value]#newThesauriValue').focus(); + cy.get('input[name=value]#newThesauriValue').type('New Single Value', { + delay: 0, }); + cy.contains('.confirm-button', 'Save').click(); + cy.contains('Thesaurus saved'); + cy.waitForLegacyNotifications(); + }); - it('should keep searched text between tabs', () => { - cy.clearAndType( - 'input[aria-label="Type something in the search box to get some results."]', - '"4 de julio de 2006"', - { delay: 0 } - ); - cy.get('svg[aria-label="Search button"]').click(); - cy.contains('.item-snippet', '4 de julio de 2006').should('have.length', 1); - cy.contains('.item-document .item-actions a', 'View').click(); - cy.contains('VISTO'); - cy.get('.snippet-text').should('have.length', 2); - cy.get('#tab-metadata').click(); - cy.get('.entity-sidepanel-tab-link').then(element => { - expect(element.attr('href')).to.contain('searchTerm=%224%20de%20julio%20de%202006%22'); - }); - cy.contains('a', 'Library').click(); - cy.get('svg[aria-label="Reset Search input"]').click(); + it('should add a thesauri value on a multiselect field and select it', () => { + cy.get('.side-panel.is-active .sidepanel-body.scrollable').scrollTo(0, 1300); + cy.contains( + '#metadataForm > div:nth-child(3) > .form-group.multiselect > ul > .wide > div > div > button > span', + 'add value' + ).click(); + cy.contains('.modal-content', 'Add thesaurus value'); + cy.get('input[name=value]#newThesauriValue').type('New Value', { + delay: 0, }); + cy.contains('.confirm-button', 'Save').click(); + cy.contains('Thesaurus saved'); + cy.waitForLegacyNotifications(); + saveEntity('Entity updated'); + cy.get('.metadata-type-select').should('contain.text', 'New Single Value'); + cy.get('.metadata-type-multiselect').should('contain.text', 'MultiselectActivoNew Value'); }); }); - - describe('Languages', () => { + describe('Entity Translations', () => { it('should change the entity in Spanish', () => { changeLanguage('Español'); - cy.contains('.item-document', 'Test entity').click(); + cy.contains('.item-document:nth-child(1) span', 'Entity with all props').click(); clickOnEditEntity('Editar'); cy.get('textarea[name="library.sidepanel.metadata.title"]').click(); - cy.clearAndType('textarea[name="library.sidepanel.metadata.title"]', 'Título de prueba', { - delay: 0, - }); - cy.get('input[name="library.sidepanel.metadata.metadata.resumen"]').click(); cy.clearAndType( - 'input[name="library.sidepanel.metadata.metadata.resumen"]', - 'Resumen en español', + 'textarea[name="library.sidepanel.metadata.title"]', + 'Entidad con todas las propiedades', + { + delay: 0, + } + ); + cy.get('input[name="library.sidepanel.metadata.metadata.text"]').click(); + cy.clearAndType( + 'input[name="library.sidepanel.metadata.metadata.text"]', + 'Texto de prueba en Español', { delay: 0 } ); - cy.contains('.multiselectItem-name', 'Argentina').click(); cy.contains('button', 'Guardar').click(); }); it('should check the values for the entity in Spanish', () => { - cy.contains('.item-document', 'Título de prueba').click(); - cy.contains('h1.item-name', 'Título de prueba').should('exist'); - cy.contains('.metadata-type-text > dd', 'Resumen en español').should('exist'); - cy.contains('.multiline > .item-value > a', 'Argentina').should('exist'); + cy.contains('.item-document', 'Entidad con todas las propiedades').click(); + cy.contains('h1.item-name', 'Entidad con todas las propiedades').should('exist'); + cy.get('.metadata-type-text').should('contain.text', 'Texto de prueba en Español'); }); it('should edit the text field in English', () => { changeLanguage('English'); - cy.contains('.item-document', 'Test entity').click(); + cy.contains('.item-document', 'Entity with all props').click(); clickOnEditEntity(); - cy.get('input[name="library.sidepanel.metadata.metadata.resumen"]').click(); - cy.get('input[name="library.sidepanel.metadata.metadata.resumen"]').type('Brief in English', { - delay: 0, - }); - cy.contains('button', 'Save').click(); - cy.contains('Entity updated'); - cy.contains('.item-document', 'Test entity').click(); - cy.contains('.metadata-type-text > dd', 'Brief in English').should('exist'); - cy.contains('.multiline > .item-value > a', 'Argentina').should('exist'); + cy.get('input[name="library.sidepanel.metadata.metadata.text"]').click(); + cy.clearAndType( + 'input[name="library.sidepanel.metadata.metadata.text"]', + 'Demo text in english', + { delay: 0 } + ); + saveEntity('Entity updated'); + cy.waitForLegacyNotifications(); + cy.contains('.item-document', 'Entity with all props').click(); + cy.contains('h1.item-name', 'Entity with all props').should('exist'); + cy.get('.metadata-type-text').should('contain.text', 'Demo text in english'); }); it('should not affect the text field in Spanish', () => { + cy.intercept('GET', 'es/library/*').as('getLibrary'); changeLanguage('Español'); - cy.contains('.item-document', 'Título de prueba').click(); - cy.contains('.metadata-type-text > dd', 'Resumen en español').should('exist'); + cy.wait('@getLibrary'); + cy.contains('Configuración de filtros'); + cy.contains('.item-document:nth-child(1) span', 'Entidad con todas las propiedades').click(); + cy.contains('.metadata-type-text > dd', 'Texto de prueba en Español').should('exist'); }); }); - - describe('new thesauri values shortcut', () => { - before(() => { + describe('Empty properties', () => { + it('should be able to remove all the values from properties.', () => { changeLanguage('English'); - cy.get('li[title=Published]').click(); - cy.contains( - 'Artavia Murillo y otros. Resolución de la Corte IDH de 31 de marzo de 2014' - ).click(); + cy.contains('.item-document:nth-child(1) span', 'Entity with all props').click(); clickOnEditEntity(); - }); + cy.contains('Type'); + cy.get('.form-group.text input').clear({ force: true }); + cy.get('.form-group.numeric input').clear({ force: true }); + cy.get('.form-group.select select').select('Select...', { force: true }); + cy.get('.form-group.multiselect li.multiselectItem').contains('Activo').click(); + cy.get('.form-group.multiselect li.multiselectItem').contains('New Value').click(); + cy.get('.form-group.relationship li.multiselectItem').contains('19 Comerciantes').click(); - it('should add a thesauri value on a multiselect field and select it', () => { - cy.get( - '#metadataForm > div:nth-child(3) > .form-group.multiselect > ul > .wide > div > div > button > span' - ).scrollIntoView(); - cy.contains( - '#metadataForm > div:nth-child(3) > .form-group.multiselect > ul > .wide > div > div > button > span', - 'add value' - ) - .parent() - .click(); - cy.contains('.modal-content', 'Add thesaurus value'); - cy.get('input[name=value]#newThesauriValue').type('New Value', { - delay: 0, - }); - cy.contains('.file-form button.confirm-button', 'Save').click(); - cy.contains( - '#metadataForm > div:nth-child(3) > .form-group.multiselect > ul > .wide > div > ul > li:nth-child(4) > label > .multiselectItem-name', - 'New Value' - ).should('exist'); - const expectedMultiselect = [ - 'De asunto', - 'Medidas Provisionales', - 'New Value', - 'Excepciones Preliminares', - 'Fondo', - ]; - cy.get( - '#metadataForm > div:nth-child(3) > .form-group.multiselect > ul > li.wide > div > ul > li > label > .multiselectItem-name' - ).each((element, index) => { - const content = element.text(); - cy.wrap(content).should('eq', expectedMultiselect[index]); - }); + cy.get('.form-group.date input').eq(0).scrollIntoView(); + cy.get('.form-group.date input').eq(0).clear(); + cy.get('.form-group.daterange div.DatePicker__From input').clear(); + cy.get('.form-group.daterange div.DatePicker__To input').clear(); + cy.get('.form-group.multidate .multidate-item:nth-of-type(2) > button').click(); + cy.get('.form-group.multidate .multidate-item:first-of-type > button').click(); + cy.get('div.form-group.multidaterange .multidate-item:nth-child(2) > div > button').click(); + cy.get('div.form-group.multidaterange .multidate-item:nth-child(1) > div > button').click(); + cy.get('.form-group.markdown textarea').scrollIntoView(); + cy.get('.form-group.markdown textarea').clear(); + cy.get('.form-group.link #label').clear(); + cy.get('.form-group.link #url').clear(); + + cy.get('.form-group #lat').scrollIntoView(); + cy.get('.form-group #lat').clear(); + cy.get('.form-group #lon').clear(); + + saveEntity('Entity updated'); }); - it('should add a thesauri value on a single select field and select it', () => { - cy.contains( - '#metadataForm > div:nth-child(3) > .form-group.select > ul > .wide > div > div > button > span', - 'add value' - ).click(); - cy.get('input[name=value]#newThesauriValue').click(); - cy.get('input[name=value]#newThesauriValue').type('New Value', { - delay: 0, - }); - cy.contains('.confirm-button', 'Save').click(); + it('should not have metadata.', () => { + cy.get('div.metadata.tab-content-visible div.view > dl > div').should('have.length', 0); }); }); }); diff --git a/cypress/e2e/main-document-and-references.cy.ts b/cypress/e2e/main-document-and-references.cy.ts new file mode 100644 index 0000000000..4dedde9248 --- /dev/null +++ b/cypress/e2e/main-document-and-references.cy.ts @@ -0,0 +1,239 @@ +import { + clearCookiesAndLogin, + clickOnCreateEntity, + clickOnEditEntity, + saveEntity, + selectRestrictedEntities, +} from './helpers'; + +describe('text references', () => { + before(() => { + const env = { DATABASE_NAME: 'uwazi_e2e', INDEX_NAME: 'uwazi_e2e' }; + cy.exec('yarn e2e-fixtures', { env }); + clearCookiesAndLogin(); + }); + + it('should navigate to a document', () => { + cy.contains( + '.item-document', + 'Artavia Murillo et al. Preliminary Objections, Merits, Reparations and Costs. Judgment. November 28, 2012' + ) + .contains('View') + .click(); + cy.contains('Previous'); + }); + + it('should select the title and create a reference to another paragraph', () => { + cy.contains('span[role="presentation"]', 'The Amazing Spider-Man').setSelection( + 'The Amazing Spider-Man' + ); + + cy.get('.connect-to-p').click(); + + cy.get('.create-reference.is-active').within(() => { + cy.contains('Relacionado a').click(); + cy.get('input').type( + 'Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016\u000d', + { delay: 0 } + ); + cy.contains( + 'Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016' + ).click(); + cy.get('.btn-success').click(); + }); + + cy.contains('span[role="presentation"]', 'What is Lorem Ipsum?').setSelection( + 'What is Lorem Ipsum?' + ); + + cy.get('.ContextMenu > .btn').click(); + }); + + it('should verify the reference and navigate to the connected paragraph', () => { + cy.get('.metadata-sidepanel.is-active').within(() => { + cy.contains( + 'Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016' + ).click(); + + cy.get('.item-shortcut.btn-default').eq(1).click(); + }); + + cy.contains('Lorem Ipsum'); + }); + + it('should create a reference to another entity', () => { + cy.contains('span[role="presentation"]', 'Why do we use it?').setSelection('Why do we use it?'); + + cy.get('.connect-to-d').click(); + + cy.get('.create-reference.is-active').within(() => { + cy.contains('Paises').click(); + cy.get('input').type('Chile\u000d', { delay: 0 }); + cy.contains('Chile').click(); + cy.contains('button', 'Save').click(); + }); + }); + + it('should verify the reference to an entity', () => { + cy.get('.metadata-sidepanel.is-active').within(() => { + cy.contains( + 'Artavia Murillo et al. Preliminary Objections, Merits, Reparations and Costs. Judgment. November 28, 2012' + ); + cy.contains('Chile'); + }); + }); + + it('should display relationships on the sidepanel', () => { + cy.contains('a', 'Library').click(); + cy.contains( + '.item-document:nth-child(1)', + 'Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016' + ).click(); + cy.get('#tab-relationships').click(); + cy.contains('#tabpanel-relationships', 'Relacionado a'); + cy.contains( + '.sidepanel-relationship-right-entity', + 'Artavia Murillo et al. Preliminary Objections, Merits, Reparations and Costs. Judgment. November 28, 2012' + ); + cy.contains('.sidepanel-relationship-right-entity', 'Chile'); + cy.get('.metadata-sidepanel.is-active .closeSidepanel').eq(0).click(); + }); + + it('should display entity relationship page', () => { + cy.contains( + '.item-document:nth-child(1)', + 'Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016' + ) + .contains('View') + .click(); + cy.get('#tab-relationships').click(); + cy.contains( + 'div.relationshipsHub:nth-child(1)', + 'Artavia Murillo et al. Preliminary Objections, Merits, Reparations and Costs. Judgment. November 28, 2012' + ); + cy.contains('div.relationshipsHub:nth-child(5)', 'Chile'); + }); + + it('should display the related entity on the sidepanel', () => { + cy.get('#tab-references').click(); + cy.contains( + 'aside.side-panel', + 'Artavia Murillo et al. Preliminary Objections, Merits, Reparations and Costs. Judgment. November 28, 2012' + ).should('be.visible'); + cy.contains('aside.side-panel', 'Chile').should('be.visible'); + }); + + it('should delete the reference to the entity', () => { + cy.contains('aside.side-panel', 'Chile').click(); + cy.contains('.relationship-active', 'Chile').within(() => { + cy.get('.btn.delete').click(); + }); + + cy.contains('Confirm delete connection'); + cy.get('[data-testid=modal]').within(() => { + cy.contains('Accept').click(); + }); + + cy.waitForLegacyNotifications(); + + cy.get('.metadata-sidepanel.is-active').within(() => { + cy.contains('Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016'); + cy.contains('Chile').should('not.exist'); + }); + }); +}); + +describe('Entity with main documents', () => { + it('Should create a new entity with a main documents', () => { + cy.get('.metadata-sidepanel.is-active .closeSidepanel').eq(0).click(); + cy.contains('a', 'Library').click(); + cy.contains('Filters'); + selectRestrictedEntities(); + clickOnCreateEntity(); + cy.get('textarea[name="library.sidepanel.metadata.title"]').click(); + cy.get('textarea[name="library.sidepanel.metadata.title"]').type('Entity with main documents', { + delay: 0, + }); + cy.get('input[name="library.sidepanel.metadata.metadata.resumen"]').click(); + cy.get('input[name="library.sidepanel.metadata.metadata.resumen"]').type( + 'An entity with main documents', + { delay: 0 } + ); + cy.get('.document-list-parent > input').first().selectFile('./cypress/test_files/valid.pdf', { + force: true, + }); + saveEntity(); + cy.waitForLegacyNotifications(); + }); + + it('should create a reference from main document', () => { + cy.contains('.item-document', 'Entity with main documents').contains('View').click(); + cy.contains('span', 'La Sentencia de fondo'); + cy.get('#p3R_mc24 > span:nth-child(2)').realClick({ clickCount: 3 }); + cy.get('.fa-file', { timeout: 5000 }).then(() => { + cy.get('.fa-file').realClick(); + }); + cy.contains('.create-reference', 'Relacionado a').should('be.visible'); + cy.contains('li.multiselectItem', 'Relacionado a').realClick(); + cy.get('aside.create-reference input').type('Patrick Robinson', { timeout: 5000 }); + cy.contains('Tracy Robinson', { timeout: 5000 }); + cy.contains('.item-name', 'Patrick Robinson', { timeout: 5000 }).realClick(); + cy.contains('aside.create-reference .btn-success', 'Save', { timeout: 5000 }).click({ + timeout: 5000, + }); + cy.contains('Saved successfully.'); + cy.get('#p3R_mc0').scrollIntoView(); + cy.get('.row').toMatchImageSnapshot(); + }); + + it('should edit the entity and the documents', () => { + cy.contains('a', 'Library').click(); + cy.contains('.item-document', 'Entity with main documents').click(); + cy.contains('.metadata-type-text', 'An entity with main documents').click(); + clickOnEditEntity(); + cy.get('input[name="library.sidepanel.metadata.documents.0.originalname"]').click(); + cy.get('input[name="library.sidepanel.metadata.documents.0.originalname"]').clear(); + cy.get('input[name="library.sidepanel.metadata.documents.0.originalname"]').type( + 'Renamed file.pdf', + { delay: 0 } + ); + cy.get('.document-list-parent > input').first().selectFile('./cypress/test_files/invalid.pdf', { + force: true, + }); + saveEntity('Entity updated'); + cy.waitForLegacyNotifications(); + cy.contains('.item-document', 'Entity with main documents').click(); + cy.contains('.file-originalname', 'Renamed file.pdf').should('exist'); + cy.contains('.file-originalname', 'invalid.pdf').should('exist'); + }); + + it('should delete the invalid document', () => { + clickOnEditEntity(); + cy.get('.attachments-list > .attachment:nth-child(2) > button').click(); + cy.contains('button', 'Save').click(); + cy.contains('Entity updated'); + cy.waitForLegacyNotifications(); + cy.contains('.item-document', 'Entity with main documents').click(); + cy.contains('.file-originalname', 'Renamed file.pdf').should('exist'); + cy.contains('.file-originalname', 'invalid.pdf').should('not.exist'); + }); + + it('should keep searched text between tabs', () => { + cy.clearAndType( + 'input[aria-label="Type something in the search box to get some results."]', + '"4 de julio de 2006"', + { delay: 0 } + ); + cy.get('svg[aria-label="Search button"]').click(); + cy.contains('.item-snippet', '4 de julio de 2006').should('have.length', 1); + cy.contains('.item-document .item-actions a', 'View').click(); + cy.contains('VISTO'); + cy.get('.snippet-text').should('have.length', 2); + cy.get('#tab-metadata').click(); + cy.get('.entity-sidepanel-tab-link').then(element => { + expect(element.attr('href')).to.contain('searchTerm=%224%20de%20julio%20de%202006%22'); + }); + cy.contains('a', 'Library').click(); + cy.get('svg[aria-label="Reset Search input"]').click(); + }); +}); diff --git a/cypress/e2e/media-metadata.cy.ts b/cypress/e2e/media-metadata.cy.ts deleted file mode 100644 index fd103b815b..0000000000 --- a/cypress/e2e/media-metadata.cy.ts +++ /dev/null @@ -1,283 +0,0 @@ -/* eslint-disable max-lines */ -import { clickOnCreateEntity, clickOnEditEntity } from './helpers/entities'; -import { clearCookiesAndLogin } from './helpers/login'; - -describe('Media metadata', { defaultCommandTimeout: 5000 }, () => { - before(() => { - const env = { DATABASE_NAME: 'uwazi_e2e', INDEX_NAME: 'uwazi_e2e' }; - cy.exec('yarn e2e-fixtures', { env }); - clearCookiesAndLogin(); - }); - - beforeEach(() => { - cy.intercept('POST', 'api/entities').as('saveEntity'); - }); - - const clickMediaAction = (field: string, action: string) => { - cy.contains(field).parentsUntil('.form-group').contains('button', action).scrollIntoView(); - cy.contains(field).parentsUntil('.form-group').contains('button', action).click(); - }; - - const addEntity = (title: string) => { - clickOnCreateEntity(); - cy.get('#metadataForm') - .contains('Type') - .parentsUntil('.form-group') - .find('select') - .select('Reporte'); - cy.contains('Descriptor').parentsUntil('.form-group').find('select').select('Familia'); - cy.get('textarea[name="library.sidepanel.metadata.title"]').type(title, { delay: 0 }); - }; - - const addVideo = (local: boolean = true) => { - clickMediaAction('Video', 'Add file'); - if (local) { - cy.get('.upload-button input[type=file]') - .last() - .selectFile('./cypress/test_files/short-video.mp4', { - force: true, - }); - } else { - cy.get('input[name="urlForm.url"]').type( - 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/Sintel.mp4', - { delay: 0 } - ); - cy.contains('button', 'Add from URL').click(); - } - - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(2000); - cy.contains('.form-group.media', 'Video').scrollIntoView(); - cy.contains('.form-group.media', 'Video').within(() => { - cy.get('video').should('be.visible'); - }); - }; - - const addImage = () => { - clickMediaAction('Fotografía', 'Add file'); - cy.contains('button', 'Select from computer'); - cy.get('.upload-button input[type=file]') - .first() - .selectFile('./cypress/test_files/batman.jpg', { - force: true, - }); - // wait for image - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(200); - cy.contains('.form-group.image', 'Fotografía').scrollIntoView(); - cy.contains('.form-group.image', 'Fotografía').within(() => { - cy.get('img').should('be.visible'); - }); - }; - - const addInvalidVideoFile = (field: string) => { - cy.contains(field).parentsUntil('.form-group').contains('button', 'Add file').scrollIntoView(); - cy.contains(field).parentsUntil('.form-group').contains('button', 'Add file').click(); - cy.contains('button', 'Select from computer'); - cy.get('.upload-button input[type=file]') - .first() - .selectFile('./cypress/test_files/sample.pdf', { - force: true, - }); - cy.contains(field) - .parentsUntil('.form-group') - .contains('This file type is not supported on media fields') - .scrollIntoView(); - cy.contains(field) - .parentsUntil('.form-group') - .contains('This file type is not supported on media fields') - .should('be.visible'); - }; - - const addInvalidImageFile = (field: string) => { - cy.contains(field).parentsUntil('.form-group').contains('button', 'Add file').scrollIntoView(); - cy.contains(field).parentsUntil('.form-group').contains('button', 'Add file').click(); - cy.contains('button', 'Select from computer'); - cy.get('.upload-button input[type=file]') - .first() - .selectFile('./cypress/test_files/sample.pdf', { - force: true, - }); - cy.contains(field) - .parentsUntil('.form-group') - .contains('Error loading your image') - .scrollIntoView(); - cy.contains(field) - .parentsUntil('.form-group') - .contains('Error loading your image') - .should('be.visible'); - }; - - const checkMediaSnapshots = (selector: string) => { - cy.get(selector).scrollIntoView({ offset: { top: -30, left: 0 } }); - cy.get(selector).toMatchImageSnapshot({ disableTimersAndAnimations: true, threshold: 0.08 }); - }; - - const saveEntity = (message = 'Entity created') => { - cy.contains('button', 'Save').click(); - cy.wait('@saveEntity'); - cy.contains(message).as('successMessage'); - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(2000); - - // waiting for video - cy.get('aside video', { timeout: 5000 }).then(async $video => { - const readyState = new Promise(resolve => { - $video[0].removeAttribute('controls'); - const interval = setInterval(() => { - const videoElement = $video[0] as HTMLVideoElement; - if (videoElement.readyState >= 3) { - clearInterval(interval); - resolve($video); - } - }, 10); - cy.get('@successMessage').should('not.exist'); - }); - await readyState; - }); - }; - - it('should allow media selection on entity creation', () => { - addEntity('Reporte audiovisual'); - addImage(); - addVideo(); - saveEntity(); - - checkMediaSnapshots('.metadata-type-multimedia.metadata-name-fotograf_a'); - checkMediaSnapshots('.metadata-type-multimedia.metadata-name-video'); - }); - - it('should allow add timelinks to an existing entity media property', () => { - cy.contains('h2', 'Reporte audiovisual').click(); - cy.contains('button', 'Edit').should('be.visible'); - clickOnEditEntity(); - cy.addTimeLink(2000, 'Control point'); - saveEntity('Entity updated'); - checkMediaSnapshots('.metadata-type-multimedia.metadata-name-fotograf_a'); - checkMediaSnapshots('.metadata-type-multimedia.metadata-name-video'); - }); - - it('should allow media selection with timelinks on entity creation', () => { - addEntity('Reporte audiovisual con lineas de tiempo'); - addImage(); - addVideo(); - cy.addTimeLink(2000, 'Second one'); - saveEntity(); - }); - - // eslint-disable-next-line max-statements - it('should allow set an external link from a media property', () => { - addEntity('Reporte con contenido externo'); - addImage(); - addVideo(false); - cy.contains('button', 'Add timelink').scrollIntoView(); - cy.contains('button', 'Add timelink').should('be.visible').click(); - cy.clearAndType('input[name="timelines.0.timeMinutes"]', '09'); - cy.clearAndType('input[name="timelines.0.timeSeconds"]', '57'); - cy.clearAndType('input[name="timelines.0.label"]', 'Dragon'); - saveEntity(); - checkMediaSnapshots('.metadata-type-multimedia.metadata-name-video'); - }); - - // eslint-disable-next-line max-statements - it('should show an error for an invalid property and allow to replace it for a valid one', () => { - addEntity('Reporte con propiedades audiovisuales corregidas'); - addInvalidImageFile('Fotografía'); - addInvalidVideoFile('Video'); - clickMediaAction('Fotografía', 'Unlink'); - addImage(); - clickMediaAction('Video', 'Unlink'); - addVideo(); - saveEntity(); - checkMediaSnapshots('.metadata-type-multimedia.metadata-name-fotograf_a'); - checkMediaSnapshots('.metadata-type-multimedia.metadata-name-video'); - }); - - it('should allow unlink the value of a media property', () => { - cy.contains('h2', 'Reporte con propiedades audiovisuales corregidas').click(); - cy.contains('button', 'Edit').should('be.visible'); - clickOnEditEntity(); - clickMediaAction('Video', 'Unlink'); - cy.contains('button', 'Save').click(); - cy.wait('@saveEntity'); - cy.contains('Entity updated').as('successMessage'); - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000); - cy.get('@successMessage').should('not.exist'); - }); - - describe('thumbnails', () => { - const checkExternalMedia = () => { - cy.get('video').should( - 'have.attr', - 'src', - 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/Sintel.mp4' - ); - }; - - it('should mark media fields as visible on cards', () => { - cy.contains('a', 'Settings').click(); - cy.contains('a', 'Templates').click(); - cy.contains('a', 'Reporte').click(); - cy.contains('span', 'Video').siblings().contains('button', 'Edit').click(); - cy.contains('span', 'Show in cards').click(); - cy.contains('button', 'Save').click(); - cy.contains('span', 'Saved successfully.').click(); - cy.contains('a', 'Library').click(); - }); - - it('should display the external player for external media', () => { - cy.get('.item-group > :nth-child(2)').within(() => { - cy.contains('span', 'Reporte con contenido externo').click(); - cy.contains('Video').scrollIntoView({ - offset: { top: -10, left: 0 }, - }); - checkExternalMedia(); - }); - }); - - it('should show the external player on the sidepanel and entity view', () => { - cy.get('.item-group > :nth-child(2) > .item-info').click(); - cy.get('.side-panel.is-active').within(() => { - cy.contains('h1', 'Reporte con contenido externo'); - cy.get('.metadata-type-multimedia.metadata-name-video').scrollIntoView({ - offset: { top: -30, left: 0 }, - }); - checkExternalMedia(); - }); - - cy.get('.item-group > :nth-child(2)').within(() => { - cy.contains('a', 'View').click(); - }); - - cy.contains('h1', 'Reporte con contenido externo'); - checkExternalMedia(); - }); - - it('should render a generic thumbnail for internal media', () => { - cy.contains('a', 'Library').click(); - cy.contains('Video'); - cy.get('.item-group > :nth-child(3)').toMatchImageSnapshot(); - }); - - it('should render the player for internal media on the sidepanel and entity view', () => { - cy.get('.item-group > :nth-child(3) > .item-info').click(); - cy.get('.side-panel.is-active').within(() => { - cy.contains('h1', 'Reporte audiovisual con lineas de tiempo'); - cy.get('.react-player').within(() => { - cy.get('video', { timeout: 2000 }); - }); - }); - - cy.get('.item-group > :nth-child(3)').within(() => { - cy.contains('a', 'View').click(); - }); - - cy.contains('h1', 'Reporte audiovisual con lineas de tiempo'); - - cy.get('.react-player').within(() => { - cy.get('video', { timeout: 2000 }); - }); - }); - }); -}); diff --git a/cypress/e2e/references.cy.ts b/cypress/e2e/references.cy.ts deleted file mode 100644 index 2717b5e70f..0000000000 --- a/cypress/e2e/references.cy.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { clearCookiesAndLogin } from './helpers'; - -describe('text references', () => { - before(() => { - const env = { DATABASE_NAME: 'uwazi_e2e', INDEX_NAME: 'uwazi_e2e' }; - cy.exec('yarn e2e-fixtures', { env }); - clearCookiesAndLogin(); - }); - - it('should navigate to a document', () => { - cy.contains( - 'h2', - 'Artavia Murillo et al. Preliminary Objections, Merits, Reparations and Costs. Judgment. November 28, 2012' - ) - .parentsUntil('.item-document') - .parent() - .contains('a', 'View') - .click(); - }); - - it('should select the title and create a reference to another paragraph', () => { - cy.contains('span[role="presentation"]', 'The Amazing Spider-Man').setSelection( - 'The Amazing Spider-Man' - ); - - cy.get('.connect-to-p').click(); - - cy.get('.create-reference.is-active').within(() => { - cy.contains('Relacionado a').click(); - cy.get('input').type( - 'Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016\u000d', - { delay: 0 } - ); - cy.contains( - 'Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016' - ).click(); - cy.get('.btn-success').click(); - }); - - cy.contains('span[role="presentation"]', 'What is Lorem Ipsum?').setSelection( - 'What is Lorem Ipsum?' - ); - - cy.get('.ContextMenu > .btn').click(); - }); - - it('should verify the reference and navigate to the connected paragraph', () => { - cy.get('.metadata-sidepanel.is-active').within(() => { - cy.contains( - 'Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016' - ).click(); - - cy.get('.item-shortcut.btn-default').eq(1).click(); - }); - - cy.contains('Lorem Ipsum'); - }); - - it('should create a reference to another entity', () => { - cy.contains('span[role="presentation"]', 'Why do we use it?').setSelection('Why do we use it?'); - - cy.get('.connect-to-d').click(); - - cy.get('.create-reference.is-active').within(() => { - cy.contains('Paises').click(); - cy.get('input').type('Chile\u000d', { delay: 0 }); - cy.contains('Chile').click(); - cy.contains('button', 'Save').click(); - }); - }); - - it('should verify the reference to an entity', () => { - cy.get('.metadata-sidepanel.is-active').within(() => { - cy.contains('Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016'); - cy.contains('Chile'); - }); - }); - - it('should delete the reference to the entity', () => { - cy.contains('.relationship-active', 'Chile').within(() => { - cy.get('.btn.delete').click(); - }); - - cy.contains('Confirm delete connection'); - cy.get('[data-testid=modal]').within(() => { - cy.contains('Accept').click(); - }); - - cy.get('.metadata-sidepanel.is-active').within(() => { - cy.contains('Artavia Murillo y otros. Resolución de la CorteIDH de 26 de febrero de 2016'); - cy.contains('Chile').should('not.exist'); - }); - }); -}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index ba0b1dd160..03419af35b 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -150,9 +150,9 @@ Cypress.on('window:before:load', window => { ); }); -Cypress.Commands.add('clearAndType', (selector, value) => { - cy.get(selector).clear(); - cy.get(selector).type(value); +Cypress.Commands.add('clearAndType', (selector, value, options) => { + cy.get(selector).clear(options); + cy.get(selector).type(value, options); }); // eslint-disable-next-line prefer-arrow-callback @@ -161,7 +161,7 @@ Cypress.Commands.addQuery('getByTestId', function getByTestId(id) { return subject => getFn(subject); }); -Cypress.Commands.add('addTimeLink', (duration, label, index = 0) => { +Cypress.Commands.add('addTimeLink', (duration, label, index = 0, seconds = -1, minutes = -1) => { cy.get('.timelinks-form').scrollIntoView(); cy.get('video', { timeout: 2000 }).then(async $video => { await $video[0].play(); @@ -174,6 +174,11 @@ Cypress.Commands.add('addTimeLink', (duration, label, index = 0) => { cy.contains('button', 'Add timelink').should('be.visible').click(); const timeLinkSelector = `input[name="timelines.${index}.label"`; + + if (seconds !== -1) { + cy.clearAndType(`input[name="timelines.${index}.timeMinutes"`, seconds, { delay: 0 }); + cy.clearAndType(`input[name="timelines.${index}.timeSeconds"`, minutes, { delay: 0 }); + } cy.get(timeLinkSelector).type(label); }); @@ -194,4 +199,10 @@ Cypress.Commands.add('realDragAndDrop', (subject, target) => { target.realMouseMove(0, 0, { position: 'center' }).realMouseUp().wait(100); }); +Cypress.Commands.add('waitForLegacyNotifications', () => { + cy.get('.alert-wrapper').each(element => { + cy.wrap(element).should('be.empty'); + }); +}); + export {}; diff --git a/e2e/regression_suites/entities.test.ts b/e2e/regression_suites/entities.test.ts deleted file mode 100644 index 7f4bd92165..0000000000 --- a/e2e/regression_suites/entities.test.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { host } from '../config'; -import disableTransitions from '../helpers/disableTransitions'; -import insertFixtures from '../helpers/insertFixtures'; -import { adminLogin, logout } from '../helpers/login'; -import proxyMock from '../helpers/proxyMock'; -import { scrollTo } from '../helpers/formActions'; -import { prepareToMatchImageSnapshot, testSelectorShot } from '../helpers/regression'; - -prepareToMatchImageSnapshot(); - -describe('Homepage entities', () => { - beforeAll(async () => { - await insertFixtures(); - await proxyMock(); - await adminLogin(); - }); - - beforeEach(async () => { - await disableTransitions(); - }); - - it('should display entities in homepage', async () => { - await testSelectorShot('.row.panels-layout', { threshold: 0.08 }); - }); - - it('should display entity details', async () => { - await expect(page).toClick('div.item-document:first-child'); - await page.waitForNetworkIdle(); - await page.waitForSelector('.metadata.tab-content-visible'); - await testSelectorShot('.metadata-sidepanel', { threshold: 0.08 }); - }); - - it('should display relationships on the sidepanel', async () => { - await expect(page).toClick('div.item-document:first-child'); - await expect(page).toClick('#tab-relationships'); - await page.waitForSelector('#tabpanel-relationships'); - await testSelectorShot('.metadata-sidepanel', { threshold: 0.08 }); - }); - - it('should display entity view page', async () => { - await page.goto(`${host}/entity/oiejku12qn0zfr`); - await testSelectorShot('main.app-content', { threshold: 0.08 }); - }); - - it('should display entity edit page', async () => { - await expect(page).toClick('span', { text: 'Edit' }); - await testSelectorShot('main.app-content', { threshold: 0.08 }); - }); - - it('should display entity relationship page', async () => { - await page.goto(`${host}/entity/aw6ok8moyjru23xr`); - await disableTransitions(); - await page.waitForSelector('div.content-header-entity'); - await page.waitForSelector('#tab-relationships'); - await expect(page).toClick('div[aria-label="Relationships"]'); - await page.waitForSelector('.relationship-toolbar'); - await testSelectorShot('main.app-content', { threshold: 0.08 }); - }); - - it('should display the related entity on the sidepanel', async () => { - await page.goto(`${host}/entity/7ycel666l65vobt9`); - await expect(page).toClick('div[aria-label="Relationships"]'); - await page.waitForSelector('.relationships-graph'); - await expect(page).toClick('.item-name', { - text: 'Artavia Murillo y otros. Resolución de la Corte IDH de 31 de marzo de 2014', - }); - await page.waitForSelector('aside.side-panel > .sidepanel-body > .view > .item-info'); - await testSelectorShot('aside.side-panel > .sidepanel-body', { threshold: 0.08 }); - }); - - it('should display the supporting files of the related entity on the sidepanel', async () => { - await scrollTo('aside.side-panel > .sidepanel-body > .attachments-list-parent'); - await testSelectorShot('aside.side-panel > .sidepanel-body', { threshold: 0.08 }); - }); - - afterAll(async () => { - await logout(); - }); -}); diff --git a/e2e/suite1/metadataprops.test.ts b/e2e/suite1/metadataprops.test.ts deleted file mode 100644 index c8d64d5d8d..0000000000 --- a/e2e/suite1/metadataprops.test.ts +++ /dev/null @@ -1,237 +0,0 @@ -/* eslint-disable max-statements */ - -import { adminLogin, logout } from '../helpers/login'; -import { host } from '../config'; -import proxyMock from '../helpers/proxyMock'; -import insertFixtures from '../helpers/insertFixtures'; -import { clearInput, selectDate, scrollTo, waitForNavigation } from '../helpers/formActions'; -import { goToRestrictedEntities } from '../helpers/publishedFilter'; -import { mouseClick } from '../helpers/selectorUtils'; - -describe('Metadata Properties', () => { - beforeAll(async () => { - await insertFixtures(); - await proxyMock(); - }); - - it('should log in as admin then click the settings nav button.', async () => { - await adminLogin(); - await waitForNavigation(expect(page).toClick('a', { text: 'Settings' })); - expect(page.url()).toBe(`${host}/en/settings/account`); - }); - - it('should test number of available properties.', async () => { - await expect(page).toClick('a', { text: 'Templates' }); - await expect(page).toClick('a', { text: 'Add template' }); - const propertyList = await page.$$('.property-options-list li'); - expect(propertyList.length).toBe(13); - }); - - describe('create template with all properties', () => { - it('should create a template with all the properties', async () => { - await expect(page).toClick('a', { text: 'Templates' }); - await expect(page).toClick('a', { text: 'Add template' }); - await expect(page).toFill('input[name="template.data.name"]', 'All props'); - - const propertyAddButtons = await page.$$('.property-options-list li button'); - //intentionaly leaving the last fields out of the test: violated articles (nested), generated id. - for (let propIndex = 0; propIndex < 11; propIndex += 1) { - // eslint-disable-next-line no-await-in-loop - await propertyAddButtons[propIndex].click(); - } - - const propertiesInMetadata = await page.$$('.metadataTemplate li'); - await expect(propertiesInMetadata[6]).toClick('button', { text: 'Edit' }); - await expect(propertiesInMetadata[6]).toSelect('select:first-of-type', 'Relacionado a'); - await expect(page).toClick('button', { text: 'Save' }); - await expect(page).toClick('div.alert-success'); - }); - - it('should add another select of type multiselect', async () => { - await expect(page).toClick('li.list-group-item:nth-child(3) > button:nth-child(1)'); - await expect(page).toClick( - '.metadataTemplate-list > li:nth-child(15) > div:nth-child(1) > div:nth-child(2) > button', - { text: 'Edit' } - ); - await expect(page).toFill('#property-label', 'Multiselect'); - await expect(page).toSelect('#property-type', 'Multiple select'); - await expect(page).toClick('button', { text: 'Save' }); - await expect(page).toClick('div.alert-success'); - }); - - it('should add multidate, date range and multidate range', async () => { - for (let index = 0; index < 3; index += 1) { - // eslint-disable-next-line no-await-in-loop - await expect(page).toClick('li.list-group-item:nth-child(5) > button:nth-child(1)'); - } - - await expect(page).toClick( - '.metadataTemplate-list > li:nth-child(16) > div:nth-child(1) > div:nth-child(2) > button', - { text: 'Edit' } - ); - await expect(page).toFill('#property-label', 'Multi Date'); - await expect(page).toSelect('#property-type', 'Multiple date'); - - await expect(page).toClick( - '.metadataTemplate-list > li:nth-child(17) > div:nth-child(1) > div:nth-child(2) > button', - { text: 'Edit' } - ); - await expect(page).toFill('#property-label', 'Date Range'); - await expect(page).toSelect('#property-type', 'Single date range'); - - await expect(page).toClick( - '.metadataTemplate-list > li:nth-child(18) > div:nth-child(1) > div:nth-child(2) > button', - { text: 'Edit' } - ); - - await expect(page).toFill('#property-label', 'Multi Date Range'); - await expect(page).toSelect('#property-type', 'Multiple date range'); - - await expect(page).toClick('button', { text: 'Save' }); - await expect(page).toClick('div.alert-success'); - }); - - it('should not allow duplicated properties', async () => { - await expect(page).toClick('.property-options-list li:first-child button'); - await expect(page).toClick('button', { text: 'Save' }); - await expect(page).toClick('.alert.alert-danger'); - }); - }); - - it('should create an entity filling all the props.', async () => { - await goToRestrictedEntities(); - await expect(page).toClick('button', { text: 'Create entity' }); - await page.waitForNetworkIdle(); - await expect(page).toFill( - 'textarea[name="library.sidepanel.metadata.title"]', - 'Entity with all props' - ); - await expect(page).toSelect('select:first-of-type', 'All props'); - - await expect(page).toFill('.form-group.text input', 'demo text'); - await expect(page).toFill('.form-group.numeric input', '42'); - await expect(page).toSelect('.form-group.select select', 'Activo'); - await scrollTo('.form-group.multiselect li.multiselectItem'); - await expect(page).toClick('.form-group.multiselect li.multiselectItem', { - text: 'Activo', - }); - await expect(page).toClick('.form-group.relationship li.multiselectItem', { - text: '19 Comerciantes', - }); - - await mouseClick('.leaflet-container', 200, 100); - await mouseClick('.leaflet-container', 200, 100); - const marker = await page.$$('.leaflet-marker-icon'); - expect(marker.length).toBe(1); - await mouseClick('.leaflet-container', -5, -5); - await scrollTo('.form-group.date'); - await selectDate('.form-group.date input', '08/09/1966'); - await selectDate('.form-group.daterange div.DatePicker__From input', '23/11/1963'); - await selectDate('.form-group.daterange div.DatePicker__To input', '12/09/1964'); - await expect(page).toClick('.form-group.multidate button.btn.add'); - await selectDate('.form-group.multidate .multidate-item:first-of-type input', '23/11/1963'); - await selectDate('.form-group.multidate .multidate-item:nth-of-type(2) input', '12/09/1964'); - await expect(page).toClick('.form-group.multidaterange button.btn.add'); - await expect(page).toFill('.form-group.link #label', 'Huridocs'); - await scrollTo('.form-group.link #url'); - await expect(page).toFill('.form-group.link #url', 'https://www.huridocs.org/'); - await selectDate( - '.form-group.multidaterange .multidate-item:first-of-type div.DatePicker__From input', - '23/11/1963' - ); - await selectDate( - '.form-group.multidaterange .multidate-item:first-of-type div.DatePicker__To input', - '12/09/1964' - ); - await selectDate( - '.form-group.multidaterange .multidate-item:nth-of-type(2) div.DatePicker__From input', - '23/11/1963' - ); - await selectDate( - '.form-group.multidaterange .multidate-item:nth-of-type(2) div.DatePicker__To input', - '12/09/1964' - ); - await expect(page).toFill('.form-group.markdown textarea', '***smile***'); - - await expect(page).toClick('button', { text: 'Save' }); - await expect(page).toClick('div.alert-success'); - }); - - it('should have all the values correctly saved.', async () => { - await expect(page).toMatchElement('.metadata-type-text', { text: 'demo text' }); - await expect(page).toMatchElement('.metadata-type-numeric', { text: '42' }); - await expect(page).toMatchElement('.metadata-type-select', { text: 'Activo' }); - await expect(page).toMatchElement('.metadata-type-multiselect', { text: 'Activo' }); - await expect(page).toMatchElement('.metadata-type-relationship', { text: '19 Comerciantes' }); - await expect(page).toMatchElement('.metadata-type-date', { text: 'Sep 8, 1966' }); - await expect(page).toMatchElement('.metadata-type-daterange', { - text: 'Date RangeNov 23, 1963 ~ Sep 12, 1964', - }); - - await expect(page).toMatchElement('.metadata-type-multidate', { - text: 'Multi DateNov 23, 1963Sep 12, 1964', - }); - await expect(page).toMatchElement('.metadata-type-multidaterange', { - text: 'Multi Date RangeNov 23, 1963 ~ Sep 12, 1964 2', - }); - await expect(page).toMatchElement('.metadata-type-markdown strong', { text: 'smile' }); - const linkMetaData = await page.$('.metadata-type-link a'); - const linkText = await (await linkMetaData?.getProperty('text'))?.jsonValue(); - const link = await (await linkMetaData?.getProperty('href'))?.jsonValue(); - expect(linkText).toBe('Huridocs'); - expect(link).toBe('https://www.huridocs.org/'); - - await scrollTo('.leaflet-container'); - const marker = await page.$$('.leaflet-marker-icon'); - expect(marker.length).toBe(1); - }); - - //temporarly commented until identify the problem - xit('should be able to remove all the values from properties.', async () => { - await expect(page).toClick('button.edit-metadata.btn svg'); - - await clearInput('.form-group.text input'); - await clearInput('.form-group.numeric input'); - await expect(page).toSelect('.form-group.select select', 'Select...'); - await scrollTo('.form-group.multiselect li.multiselectItem'); - await expect(page).toClick('.form-group.multiselect li.multiselectItem', { - text: 'Activo', - }); - await expect(page).toClick('.form-group.relationship li.multiselectItem', { - text: '19 Comerciantes', - }); - - await scrollTo('.form-group.date input'); - await expect(page).toClick('.form-group.date button'); - await expect(page).toClick('.form-group.daterange div.DatePicker__From button'); - await expect(page).toClick('.form-group.daterange div.DatePicker__To button'); - await expect(page).toClick('.form-group.multidate .multidate-item:nth-of-type(2) > button'); - await expect(page).toClick('.form-group.multidate .multidate-item:first-of-type > button'); - await expect(page).toClick( - 'div.form-group.multidaterange .multidate-item:nth-child(2) > div > button' - ); - await expect(page).toClick( - 'div.form-group.multidaterange .multidate-item:nth-child(1) > div > button' - ); - await scrollTo('.form-group.markdown'); - await clearInput('.form-group.markdown textarea'); - await clearInput('.form-group.link #label'); - await clearInput('.form-group.link #url'); - - await scrollTo('.form-group #lat'); - await clearInput('.form-group #lat'); - await clearInput('.form-group #lon'); - - await expect(page).toClick('button', { text: 'Save' }); - await expect(page).toClick('div.alert-success'); - }); - - xit('should not have metadata.', async () => { - const metadataDivs = await page.$$('div.metadata.tab-content-visible div.view > dl > div'); - expect(metadataDivs.length).toBe(0); - }); - - afterAll(async () => { - await logout(); - }); -}); diff --git a/package.json b/package.json index 5669598ae8..4a9f538a53 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "update-translations-csv": "node --no-experimental-fetch ./scripts/updateTranslationsCSV.mjs", "describe-database": "node --no-experimental-fetch ./scripts/describeDatabase.mjs", "tailwind-watch": "yarn run tailwind --watch", - "tailwind": " npx tailwindcss -i ./app/react/App/styles/main.css -o ./app/react/App/styles/globals.css", + "tailwind": " touch ./app/react/App/styles/globals.css && npx tailwindcss -i ./app/react/App/styles/main.css -o ./app/react/App/styles/globals.css", "hot": "export HOT=true; export BABEL_ENV=debug; yarn run watch-types & yarn tailwind-watch & yarn run dev-server & yarn run webpack-server", "hot-e2e": "DATABASE_NAME=uwazi_e2e INDEX_NAME=uwazi_e2e EXTERNAL_SERVICES=true yarn hot", "run-e2e": "DATABASE_NAME=uwazi_e2e INDEX_NAME=uwazi_e2e EXTERNAL_SERVICES=true yarn run-production", @@ -396,4 +396,4 @@ "engines": { "node": ">=20.9.0" } -} +} \ No newline at end of file