diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 03f31d2a3..8f8956282 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -128,15 +128,36 @@ jobs: ansible-playbook icat-ansible/icat_test_hosts.yml -i icat-ansible/hosts --vault-password-file icat-ansible/vault_pass.txt -vv # Fixes on ICAT components needed for e2e tests - - name: Add anon user to rootUserNames + - name: Removing authenticator prefix for simple auth run: | - awk -F" =" '/rootUserNames/{$2="= simple/root anon/anon";print;next}1' /home/runner/install/icat.server/run.properties > /home/runner/install/icat.server/run.properties.tmp + sed -i 's/mechanism = simple/!mechanism = simple/' /home/runner/install/authn.simple/run.properties + - name: Adding Chris481 user + run: | + sed -i '/user\.list/ s/$/ Chris481/' /home/runner/install/authn.simple/run.properties + - name: Adding Chris481 user password + run: | + echo "user.Chris481.password = pw" >> /home/runner/install/authn.simple/run.properties + - name: Reinstall authn.simple + run: | + cd /home/runner/install/authn.simple/ && ./setup -vv install + - name: Add anon, root (simple without prefix) and Chris481 users to rootUserNames + run: | + awk -F" =" '/rootUserNames/{$2="= root Chris481 anon/anon";print;next}1' /home/runner/install/icat.server/run.properties > /home/runner/install/icat.server/run.properties.tmp - name: Apply rootUserNames change run: | mv -f /home/runner/install/icat.server/run.properties.tmp /home/runner/install/icat.server/run.properties - name: Reinstall ICAT Server run: | cd /home/runner/install/icat.server/ && ./setup -vv install + - name: Add root (simple without prefix) to datagateway-download-api adminUserNames + run: | + awk -F" =" '/adminUserNames/{$2="= root";print;next}1' /home/runner/install/datagateway-download-api/run.properties > /home/runner/install/datagateway-download-api/run.properties.tmp + - name: Apply adminUserNames change + run: | + mv -f /home/runner/install/datagateway-download-api/run.properties.tmp /home/runner/install/datagateway-download-api/run.properties + - name: Reinstall datagateway-download-api + run: | + cd /home/runner/install/datagateway-download-api/ && python2 ./setup -vv install - name: Checkout datagateway-api uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 @@ -166,6 +187,16 @@ jobs: - name: Start API run: cd datagateway-api/; nohup poetry run python -m datagateway_api.src.main > api-output.txt & + # DOI minter setup + - name: Adding 'User-defined' DataPublicationType (needed for DOI minting api) + run: cd datagateway-api/; poetry run python ../.github/add_doi_datapublicationtype.py + + - name: 'Add password to env file' + run: echo DATACITE_PASSWORD=${{ secrets.DATACITE_PASSWORD }} >> ./.github/config.env + + - name: Run minting api + run: docker run --env-file ./.github/config.env -p 8000:8000 --add-host host.docker.internal:host-gateway -d harbor.stfc.ac.uk/icat/doi-mint-api + # E2E tests - name: Setup Node.js uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4 diff --git a/packages/datagateway-dataview/cypress/e2e/landing/dls/dataPublication.cy.ts b/packages/datagateway-dataview/cypress/e2e/landing/dls/dataPublication.cy.ts index 453673429..c88fcdac0 100644 --- a/packages/datagateway-dataview/cypress/e2e/landing/dls/dataPublication.cy.ts +++ b/packages/datagateway-dataview/cypress/e2e/landing/dls/dataPublication.cy.ts @@ -1,115 +1,283 @@ +export type MintResponse = Cypress.Response<{ + concept: { doi: string; data_publication: string }; + version: { doi: string; data_publication: string }; +}>; + describe('DLS - Data Publication Landing', () => { beforeEach(() => { - cy.login(); - cy.visit('/browse/dataPublication/45'); + cy.login( + { + username: 'Chris481', + password: 'pw', + mechanism: 'simple', + }, + 'Chris481' + ); + cy.seedUserGeneratedDataPublication().as('dataPublication1'); + cy.get('@dataPublication1') + .its('body.concept.data_publication') + .then((id) => cy.visit(`/browse/dataPublication/${id}`)); + cy.seedDownloadCart(['datafile 550']); + }); + + afterEach(() => { + cy.get('@dataPublication1').then((dp) => { + cy.clearUserGeneratedDataPublications([ + dp.body.concept.data_publication, + dp.body.version.data_publication, + ]); + }); + cy.clearDownloadCart(); }); it('should load correctly', () => { cy.title().should('equal', 'DataGateway DataView'); cy.get('#datagateway-dataview').should('be.visible'); - cy.contains('Consider author watch hot someone.').should('be.visible'); - cy.contains('Christina Kennedy').should('be.visible'); + cy.contains('Test DOI title').should('be.visible'); + cy.contains('Test DOI description').should('be.visible'); + cy.contains('Thomas Chambers').should('be.visible'); + + cy.get('@dataPublication1').then((dp) => { + cy.contains('a', dp.body.concept.doi); + + cy.contains('a', dp.body.version.doi); + }); }); it('should be able to click tab to see content and it works like a normal table', () => { cy.get('#datapublication-content-tab').first().click(); - cy.get('[aria-rowcount="3"]').should('exist'); - cy.get('[aria-rowindex="1"] [aria-colindex="3"]').contains('22'); + cy.contains('Datafiles').click(); + + cy.get('[aria-rowcount="2"]').should('exist'); + cy.get('[aria-rowindex="1"] [aria-colindex="3"]').contains('74'); // test sorting - cy.contains('Visit ID').click(); - cy.contains('Visit ID').click(); - cy.get('[aria-rowindex="1"] [aria-colindex="3"]').contains('65'); + cy.contains('Name').click(); + cy.get('[aria-rowindex="1"] [aria-colindex="3"]').contains('193'); // test filtering - cy.get('[aria-label="Filter by Visit ID"]').type('2'); + cy.get('[aria-label="Filter by Name"]').type('7'); cy.get('[aria-rowcount="1"]').should('exist'); - cy.get('[aria-rowindex="1"] [aria-colindex="3"]').contains('22'); + cy.get('[aria-rowindex="1"] [aria-colindex="3"]').contains('74'); }); it('should be able to click tab to see content and switch between entity types', () => { cy.get('#datapublication-content-tab').first().click(); cy.contains('Datasets').click(); - cy.get('[aria-rowcount="0"]').should('exist'); + cy.get('[aria-rowcount="1"]').should('exist'); cy.contains('Create Time').should('be.visible'); cy.contains('Location').should('not.exist'); cy.contains('Datafiles').click(); - cy.get('[aria-rowcount="0"]').should('exist'); + cy.get('[aria-rowcount="2"]').should('exist'); cy.contains('Location').should('be.visible'); cy.contains('Investigations').click(); cy.contains('Visit ID').should('be.visible'); - cy.get('[aria-rowcount="3"]').should('exist'); + cy.get('[aria-rowcount="0"]').should('exist'); }); - it('should be able to click a DOI render the correct webpage ', () => { - cy.contains('a', '0-515-25376-6').should( - 'have.attr', - 'href', - 'https://doi.org/0-515-25376-6' - ); + it('should be able to click a DOI & it renders the correct webpage ', () => { + cy.get('@dataPublication1').then((dp) => { + cy.contains('a', dp.body.concept.doi).should( + 'have.attr', + 'href', + `https://doi.org/${dp.body.concept.doi}` + ); + }); }); - it('should be able to use the citation formatter', () => { - cy.intercept('**/datapublications?*', [ - { - id: 101224979, - pid: '10.5286/ISIS.E.RB1810842', - }, - ]); - cy.intercept('**/text/x-bibliography/10.5286/ISIS.E.RB1810842?*', [ - '@misc{dr sabrina gaertner_mr vincent deguin_dr pierre ghesquiere_dr claire...}', - ]); + it('should let the user edit their data publication', () => { + cy.get('[aria-label="Edit Data Publication"]').click(); - cy.visit('/browseDataPublications/instrument/1/dataPublication/36'); - cy.get('#datagateway-dataview').should('be.visible'); - cy.contains('10.5286/ISIS.E.RB1810842').should('be.visible'); - cy.get('[data-testid="citation-formatter-citation"]').contains( - 'STFC ISIS Neutron and Muon Source, https://doi.org/10.5286/ISIS.E.RB1810842' - ); + cy.contains('Generate DOI').should('be.visible'); + + // edit metadata + cy.contains('DOI Title') + .parent() + .find('input') + .as('titleInput') + .should('have.value', 'Test DOI title'); + cy.contains('DOI Description') + .parent() + .find('textarea') + .first() + .as('descriptionInput') + .should('have.value', 'Test DOI description'); + + cy.get('@titleInput').clear(); + cy.get('@titleInput').type('New DOI title'); + + cy.get('@descriptionInput').clear(); + cy.get('@descriptionInput').type('New DOI description'); + + cy.contains('Username').parent().find('input').type('Michael222'); + cy.contains('button', 'Add Creator').click(); + + // DOI from https://support.datacite.org/docs/testing-guide + cy.contains(/^DOI$/).parent().find('input').type('10.17596/w76y-4s92'); + cy.contains('button', 'Add DOI').click(); + cy.contains('label', 'Resource Type').parent().click(); + cy.contains('Journal').click(); + cy.contains('label', 'Relationship').parent().click(); + cy.contains('IsCitedBy').click(); + + // edit content + cy.contains('Datafiles').click(); + cy.get('[aria-label="Edit data"]').click(); + + cy.contains('Datafile 550').click(); + cy.contains('>').click(); + + cy.contains('Datafile 193').click(); + cy.contains('<').click(); + + cy.contains('Done').click(); + + cy.contains('button', 'Generate DOI').click(); + + cy.contains('Mint Confirmation').should('be.visible'); + cy.contains('Mint was successful', { timeout: 10000 }).should('be.visible'); + cy.contains('View Data Publication').click(); - cy.get('#citation-formatter').click(); + // check data is updated + cy.contains('New DOI title').should('be.visible'); + cy.contains('New DOI description').should('be.visible'); + cy.contains('Randy Beasley').should('be.visible'); + + cy.get('[data-testid="landing-dataPublication-pid-link"]') + .first() + .invoke('text') + .as('newVersionDOI'); + + // visit concept DOI and check it's updated there + cy.get('@dataPublication1') + .its('body.concept.data_publication') + .then((id) => cy.visit(`/browse/dataPublication/${id}`)); + + cy.contains('New DOI title').should('be.visible'); + cy.contains('New DOI description').should('be.visible'); + cy.contains('Randy Beasley').should('be.visible'); + + cy.get('@newVersionDOI').then((doi) => { + cy.contains('Latest Version DOI') + .parent() + .next() + .should('contain.text', doi); + }); + + cy.get( + '#version-panel-content [data-testid="landing-dataPublication-pid-link"]' + ).should('have.length', 2); + }); + + it('should be able to use the citation formatters', () => { + cy.contains('Test DOI title').should('be.visible'); + + cy.get('@dataPublication1').then((response) => { + cy.intercept(`**/text/x-bibliography/${response.body.concept.doi}?*`, [ + '@misc{dr sabrina gaertner_mr vincent deguin_dr pierre ghesquiere_dr claire...}', + ]); + + cy.intercept(`**/text/x-bibliography/${response.body.version.doi}?*`, [ + '@misc{dr alice barrett_mr charlie deguin_dr elizabeth francis_dr gary...}', + ]); + + cy.get( + '[data-testid="Latest-Version-Data-Citation-citation-formatter-citation"]' + ) + .first() + .contains( + `STFC ISIS Neutron and Muon Source, https://doi.org/${response.body.version.doi}` + ); + cy.get( + '[data-testid="Concept-Data-Citation-citation-formatter-citation"]' + ) + .last() + .contains( + `STFC ISIS Neutron and Muon Source, https://doi.org/${response.body.concept.doi}` + ); + }); + + cy.get('#Concept-Data-Citation-citation-formatter').click(); cy.get('[role="listbox"]') .find('[role="option"]') .should('have.length.gte', 2); cy.get('[role="option"][data-value="bibtex"]').click(); - cy.get('[data-testid="citation-formatter-citation"]').contains( + cy.get( + '[data-testid="Concept-Data-Citation-citation-formatter-citation"]' + ).contains( '@misc{dr sabrina gaertner_mr vincent deguin_dr pierre ghesquiere_dr claire' ); - cy.get('#citation-formatter-error-message').should('not.exist'); + cy.get('#Concept-Data-Citation-citation-formatter-error-message').should( + 'not.exist' + ); + + cy.get('#Latest-Version-Data-Citation-citation-formatter').click(); + cy.get('[role="listbox"]') + .find('[role="option"]') + .should('have.length.gte', 2); + + cy.get('[role="option"][data-value="bibtex"]').click(); + cy.get( + '[data-testid="Latest-Version-Data-Citation-citation-formatter-citation"]' + ).contains( + '@misc{dr alice barrett_mr charlie deguin_dr elizabeth francis_dr gary' + ); + cy.get( + '#Latest-Version-Data-Citation-citation-formatter-error-message' + ).should('not.exist'); }); - it('citation formatter should give an error when there is a problem', () => { - cy.intercept('**/datapublications?*', [ - { - id: 101224979, - pid: 'invaliddoi', - }, - ]); - cy.intercept('**/text/x-bibliography/invaliddoi?*', { - statusCode: 503, + it('citation formatters should give an error when there is a problem', () => { + cy.contains('Test DOI title').should('be.visible'); + + cy.get('@dataPublication1').then((response) => { + cy.intercept(`**/text/x-bibliography/${response.body.concept.doi}?*`, { + statusCode: 503, + }); + + cy.intercept(`**/text/x-bibliography/${response.body.version.doi}?*`, { + statusCode: 503, + }); + + cy.get( + '[data-testid="Latest-Version-Data-Citation-citation-formatter-citation"]' + ) + .first() + .contains( + `STFC ISIS Neutron and Muon Source, https://doi.org/${response.body.version.doi}` + ); + cy.get( + '[data-testid="Concept-Data-Citation-citation-formatter-citation"]' + ) + .last() + .contains( + `STFC ISIS Neutron and Muon Source, https://doi.org/${response.body.concept.doi}` + ); }); - cy.visit('/browseDataPublications/instrument/1/dataPublication/36'); - cy.get('#datagateway-dataview').should('be.visible'); - cy.contains('invaliddoi').should('be.visible'); - //Default citation - cy.get('[data-testid="citation-formatter-citation"]').contains( - 'STFC ISIS Neutron and Muon Source, https://doi.org/invaliddoi' - ); + cy.get('#Concept-Data-Citation-citation-formatter').click(); + cy.get('[role="listbox"]') + .find('[role="option"]') + .should('have.length.gte', 2); + + cy.get('[role="option"][data-value="chicago-author-date"]').click(); + cy.get('#Concept-Data-Citation-citation-formatter-error-message', { + timeout: 10000, + }).should('exist'); - cy.get('#citation-formatter').click(); + cy.get('#Latest-Version-Data-Citation-citation-formatter').click(); cy.get('[role="listbox"]') .find('[role="option"]') .should('have.length.gte', 2); cy.get('[role="option"][data-value="chicago-author-date"]').click(); - cy.get('#citation-formatter-error-message', { timeout: 10000 }).should( - 'exist' - ); + cy.get('#Latest-Version-Data-Citation-citation-formatter-error-message', { + timeout: 10000, + }).should('exist'); }); }); diff --git a/packages/datagateway-dataview/cypress/e2e/table/dls/myDois.cy.ts b/packages/datagateway-dataview/cypress/e2e/table/dls/myDois.cy.ts index c92ff89e8..570d5f9ff 100644 --- a/packages/datagateway-dataview/cypress/e2e/table/dls/myDois.cy.ts +++ b/packages/datagateway-dataview/cypress/e2e/table/dls/myDois.cy.ts @@ -1,3 +1,5 @@ +import { type MintResponse } from '../../landing/dls/dataPublication.cy'; + describe('DLS - MyDOIs Table', () => { it('Should redirect when logged in anonymously', () => { cy.login(); @@ -7,63 +9,38 @@ describe('DLS - MyDOIs Table', () => { describe('Logged in tests', () => { beforeEach(() => { - cy.intercept( - /\/datapublications\?.*where=%7B%22users\.contributorType%22%3A%7B%22eq%22%3A%22Minter%22%7D%7D.*where=%7B%22relatedItems\.relationType%22%3A%7B%22eq%22%3A%22HasVersion%22%7D%7D.*/, - (req) => { - // delete type = investigation requirement - const [url, search] = req.url.split('?'); - const params = new URLSearchParams(search); - // params.delete with value is still a new standard, so use workaround for now until browser compat catches up - // params.delete('where', '{"users.contributorType":{"eq":"Minter"}}'); - // params.delete('where', '{"relatedItems.relationType":{"eq":"HasVersion"}}'); - const removeValue = ( - params: URLSearchParams, - key: string, - valueToRemove: string - ): URLSearchParams => { - const values = params.getAll(key); - if (values.length) { - params.delete(key); - for (const value of values) { - if (value !== valueToRemove) { - params.append(key, value); - } - } - } - return params; - }; - removeValue( - params, - 'where', - '{"relatedItems.relationType":{"eq":"HasVersion"}}' - ); - removeValue( - params, - 'where', - '{"users.contributorType":{"eq":"Minter"}}' - ); - params.append( - 'where', - JSON.stringify({ - 'users.contributorType': { - eq: 'ProjectLeader', - }, - }) - ); - req.url = `${url}?${params.toString()}`; - - req.continue(); - } - ).as('getDataPublications'); + cy.intercept('**/datapublications?order=*').as('dataPublicationsOrder'); + cy.login( { - username: 'root', + username: 'Chris481', password: 'pw', mechanism: 'simple', }, 'Chris481' ); - cy.visit('/my-dois/DLS').wait('@getDataPublications'); + cy.seedUserGeneratedDataPublication('Test DOI Title 1').as( + 'dataPublication1' + ); + + cy.seedUserGeneratedDataPublication('Test DOI Title 2').as( + 'dataPublication2' + ); + + cy.visit('/my-dois/DLS'); + }); + + afterEach(() => { + cy.get('@dataPublication1').then((dp1) => { + cy.get('@dataPublication2').then((dp2) => { + cy.clearUserGeneratedDataPublications([ + dp1.body.concept.data_publication, + dp1.body.version.data_publication, + dp2.body.concept.data_publication, + dp2.body.version.data_publication, + ]); + }); + }); }); it('should load correctly', () => { @@ -75,35 +52,108 @@ describe('DLS - MyDOIs Table', () => { cy.get('.MuiTableSortLabel-iconDirectionDesc').should('be.visible'); }); - it('should be able to click an investigation to see its datasets', () => { - cy.get('[role="gridcell"] a').first().click({ force: true }); + it('should be able to click an data publication to see its landing page', () => { + cy.contains('Test DOI Title 1').click(); - cy.location('pathname').should('eq', '/browse/dataPublication/14'); + cy.get('@dataPublication1') + .its('body.concept.data_publication') + .then((id) => + cy.location('pathname').should('eq', `/browse/dataPublication/${id}`) + ); }); - // can't test sorting as there's only 1 table item + it('should be able to sort by all sort directions on single and multiple columns', () => { + //Revert the default sort + cy.contains('[role="button"]', 'Publication Date') + .as('dateSortButton') + .click(); + cy.wait('@dataPublicationsOrder', { timeout: 10000 }); + + // ascending order + cy.contains('[role="button"]', 'Title').as('titleSortButton').click(); + cy.wait('@dataPublicationsOrder', { timeout: 10000 }); + + cy.get('[aria-sort="ascending"]').should('exist'); + cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible'); + cy.get('[aria-rowindex="1"] [aria-colindex="1"]').contains( + 'Test DOI Title 1' + ); + + // descending order + cy.get('@titleSortButton').click(); + cy.wait('@dataPublicationsOrder', { timeout: 10000 }); + + cy.get('[aria-sort="descending"]').should('exist'); + cy.get('.MuiTableSortLabel-iconDirectionDesc').should( + 'not.have.css', + 'opacity', + '0' + ); + cy.get('[aria-rowindex="1"] [aria-colindex="1"]').contains( + 'Test DOI Title 2' + ); + + // no order + cy.get('@titleSortButton').click(); + + cy.get('[aria-sort="ascending"]').should('not.exist'); + cy.get('[aria-sort="descending"]').should('not.exist'); + cy.get('.MuiTableSortLabel-iconDirectionAsc').should('not.exist'); + + cy.get('[data-testid="SortIcon"]').should('have.length', 3); + cy.get('[data-testid="ArrowUpwardIcon"]').should('not.exist'); + + cy.get('[aria-rowindex="1"] [aria-colindex="1"]').contains( + 'Test DOI Title 1' + ); + + // multiple columns (shift click) + cy.get('@dateSortButton').click(); + cy.wait('@dataPublicationsOrder', { timeout: 10000 }); + cy.get('@titleSortButton').click({ shiftKey: true }); + cy.wait('@dataPublicationsOrder', { timeout: 10000 }); + cy.get('@titleSortButton').click({ shiftKey: true }); + cy.wait('@dataPublicationsOrder', { timeout: 10000 }); + + cy.get('[aria-rowindex="1"] [aria-colindex="1"]').contains( + 'Test DOI Title 2' + ); + + // should replace previous sort when clicked without shift + cy.contains('[role="button"]', 'DOI').click(); + cy.get('[aria-sort="ascending"]').should('have.length', 1); + }); it('should be able to filter with text & date filters on multiple columns', () => { // test text filter - cy.get('[aria-rowcount="1"]').should('exist'); + // cy.get('[aria-rowcount="1"]').should('exist'); cy.get('[aria-label="Filter by Title"]').type('random text'); cy.get('[aria-rowcount="0"]').should('exist'); cy.get('[aria-label="Filter by Title"]').clear(); - cy.get('[aria-label="Filter by Title"]').type('Officer'); + cy.get('[aria-label="Filter by Title"]').type('1'); // test date filter cy.get('[aria-rowcount="1"]').should('exist'); const date = new Date(); - cy.get('input[aria-label="Publication Date filter to"]').type( + cy.get('input[aria-label="Publication Date filter from"]').type( date.toISOString().slice(0, 10) ); cy.get('[aria-rowcount="1"]').should('exist'); - cy.get('input[id="Publication Date filter from"]').type('2019-01-01'); + cy.get('input[aria-label="Publication Date filter from"]').type( + '{ctrl}a{backspace}' + ); + + const futureDate = new Date(); + futureDate.setFullYear(futureDate.getFullYear() + 1); + + cy.get('input[aria-label="Publication Date filter from"]').type( + futureDate.toISOString().slice(0, 10) + ); cy.get('[aria-rowcount="0"]').should('exist'); }); diff --git a/packages/datagateway-dataview/cypress/support/commands.js b/packages/datagateway-dataview/cypress/support/commands.js index c38ae30cb..35e1c548c 100644 --- a/packages/datagateway-dataview/cypress/support/commands.js +++ b/packages/datagateway-dataview/cypress/support/commands.js @@ -121,3 +121,71 @@ Cypress.Commands.add('isScrolledTo', { prevSubject: true }, (element) => { ); }); }); + +Cypress.Commands.add('seedUserGeneratedDataPublication', (title) => { + return cy.request('datagateway-dataview-settings.json').then((response) => { + const settings = response.body; + return cy.request({ + method: 'POST', + url: `${settings.doiMinterUrl}/mint`, + headers: { + Authorization: `Bearer ${readSciGatewayToken().sessionId}`, + }, + body: { + metadata: { + title: title ?? 'Test DOI title', + description: 'Test DOI description', + // creators: [], + related_items: [], + resource_type: 'Collection', + }, + // these ids are specifically mintable by the Chris481 user + investigation_ids: [], + dataset_ids: [15], + datafile_ids: [74, 193], + }, + }); + }); +}); + +Cypress.Commands.add('clearUserGeneratedDataPublications', (ids) => { + return cy.request('datagateway-dataview-settings.json').then((response) => { + const settings = response.body; + ids.forEach((id) => { + cy.request({ + method: 'DELETE', + url: `${settings.apiUrl}/datapublications/${id}`, + headers: { + Authorization: `Bearer ${readSciGatewayToken().sessionId}`, + }, + }); + }); + }); +}); + +Cypress.Commands.add('seedDownloadCart', (cartItems) => { + let items = ''; + + if (!cartItems) { + const entities = ['investigation', 'dataset', 'datafile']; + items = Array(60) + .fill() + .map((value, index) => `${entities[index % 2]} ${index}`) + .join(', '); + } else { + items = cartItems.join(', '); + } + + return cy.request('datagateway-dataview-settings.json').then((response) => { + const settings = response.body; + cy.request({ + method: 'POST', + url: `${settings.downloadApiUrl}/user/cart/${settings.facilityName}/cartItems`, + body: { + sessionId: readSciGatewayToken().sessionId, + items, + }, + form: true, + }); + }); +}); diff --git a/packages/datagateway-dataview/cypress/support/index.d.ts b/packages/datagateway-dataview/cypress/support/index.d.ts index 004d508dc..aaba4d2a5 100644 --- a/packages/datagateway-dataview/cypress/support/index.d.ts +++ b/packages/datagateway-dataview/cypress/support/index.d.ts @@ -9,5 +9,12 @@ declare namespace Cypress { user?: string ): Cypress.Chainable; clearDownloadCart(): Cypress.Chainable; + seedDownloadCart(cartItems: string[]): Cypress.Chainable; + seedUserGeneratedDataPublication( + title?: string + ): Cypress.Chainable; + clearUserGeneratedDataPublications( + ids: string[] + ): Cypress.Chainable; } } diff --git a/packages/datagateway-dataview/public/res/default.json b/packages/datagateway-dataview/public/res/default.json index 83abcd1ac..e4ebf8e98 100644 --- a/packages/datagateway-dataview/public/res/default.json +++ b/packages/datagateway-dataview/public/res/default.json @@ -65,6 +65,7 @@ "content_tab_entity_tabs_aria_label": "content tabs", "edit": { "edit_label": "Edit Data Publication", + "edit_data_label": "Edit data", "select_all": "Select All", "choices": "Choices", "chosen": "Chosen", diff --git a/packages/datagateway-dataview/server/e2e-settings.json b/packages/datagateway-dataview/server/e2e-settings.json index 395b7be54..e30394b11 100644 --- a/packages/datagateway-dataview/server/e2e-settings.json +++ b/packages/datagateway-dataview/server/e2e-settings.json @@ -9,6 +9,8 @@ "idsUrl": "https://localhost:8181/ids", "apiUrl": "http://localhost:5000", "downloadApiUrl": "https://localhost:8181/topcat", + "doiMinterUrl": "http://localhost:8000", + "dataCiteUrl": "https://api.test.datacite.org", "breadcrumbs": [ { "matchEntity": "proposal", diff --git a/packages/datagateway-dataview/src/views/citationFormatter.component.tsx b/packages/datagateway-dataview/src/views/citationFormatter.component.tsx index f4108e925..4570fc126 100644 --- a/packages/datagateway-dataview/src/views/citationFormatter.component.tsx +++ b/packages/datagateway-dataview/src/views/citationFormatter.component.tsx @@ -132,7 +132,9 @@ const CitationFormatter = ( {doi && ( @@ -144,7 +146,9 @@ const CitationFormatter = ( aria-label={t( 'datapublications.details.citation_formatter.select_arialabel' )} - aria-describedby="citation-formatter-error-message" + aria-describedby={`${ + label ? `${label.replace(/\s/g, '-')}-` : '' + }citation-formatter-error-message`} variant="standard" > @@ -168,7 +172,9 @@ const CitationFormatter = ( {error && ( {t('datapublications.details.citation_formatter.error')} @@ -176,13 +182,19 @@ const CitationFormatter = ( )} - + {citation && {citation}} {!copiedCitation ? (