From 386a50868ee1fbd121edc6340bf80aff1b66faa1 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Thu, 20 Oct 2022 14:18:13 +0100 Subject: [PATCH] Add a form to change an author on a PREreview This commit adds a feature-flagged page that allows the user to change an author on the PREreview. It's not linked. As there's no consistent identifier in the author list, I've used their (0-indexed) position in the list. Refs #388, b35c1d230474553d8c9b5678a1a180cf13df768a --- integration/posting-a-prereview.spec.ts | 129 +++- ...o-the-PREreview-4-Desktop-Chrome-linux.png | 4 +- ...-4-Desktop-Chrome-no-JavaScript--linux.png | 4 +- ...-the-PREreview-4-Desktop-Firefox-linux.png | 4 +- ...4-Desktop-Firefox-no-JavaScript--linux.png | 4 +- ...ors-to-the-PREreview-4-iPhone-11-linux.png | 4 +- ...eview-4-iPhone-11-no-JavaScript--linux.png | 4 +- ...o-the-PREreview-5-Desktop-Chrome-linux.png | 4 +- ...-5-Desktop-Chrome-no-JavaScript--linux.png | 4 +- ...-the-PREreview-5-Desktop-Firefox-linux.png | 4 +- ...5-Desktop-Firefox-no-JavaScript--linux.png | 4 +- ...ors-to-the-PREreview-5-iPhone-11-linux.png | 4 +- ...eview-5-iPhone-11-no-JavaScript--linux.png | 4 +- ...o-the-PREreview-6-Desktop-Chrome-linux.png | 3 + ...-6-Desktop-Chrome-no-JavaScript--linux.png | 3 + ...-the-PREreview-6-Desktop-Firefox-linux.png | 3 + ...6-Desktop-Firefox-no-JavaScript--linux.png | 3 + ...ors-to-the-PREreview-6-iPhone-11-linux.png | 3 + ...eview-6-iPhone-11-no-JavaScript--linux.png | 3 + ...o-the-PREreview-7-Desktop-Chrome-linux.png | 3 + ...-7-Desktop-Chrome-no-JavaScript--linux.png | 3 + ...-the-PREreview-7-Desktop-Firefox-linux.png | 3 + ...7-Desktop-Firefox-no-JavaScript--linux.png | 3 + ...ors-to-the-PREreview-7-iPhone-11-linux.png | 3 + ...eview-7-iPhone-11-no-JavaScript--linux.png | 3 + ...-changed-author-1-Desktop-Chrome-linux.png | 3 + ...-1-Desktop-Chrome-no-JavaScript--linux.png | 3 + ...changed-author-1-Desktop-Firefox-linux.png | 3 + ...1-Desktop-Firefox-no-JavaScript--linux.png | 3 + ...-to-a-changed-author-1-iPhone-11-linux.png | 3 + ...uthor-1-iPhone-11-no-JavaScript--linux.png | 3 + ...-changed-author-2-Desktop-Chrome-linux.png | 3 + ...-2-Desktop-Chrome-no-JavaScript--linux.png | 3 + ...changed-author-2-Desktop-Firefox-linux.png | 3 + ...2-Desktop-Firefox-no-JavaScript--linux.png | 3 + ...-to-a-changed-author-2-iPhone-11-linux.png | 3 + ...uthor-2-iPhone-11-no-JavaScript--linux.png | 3 + ...d-author-s-name-1-Desktop-Chrome-linux.png | 3 + ...-1-Desktop-Chrome-no-JavaScript--linux.png | 3 + ...-author-s-name-1-Desktop-Firefox-linux.png | 3 + ...1-Desktop-Firefox-no-JavaScript--linux.png | 3 + ...hanged-author-s-name-1-iPhone-11-linux.png | 3 + ...-name-1-iPhone-11-no-JavaScript--linux.png | 3 + ...d-author-s-name-2-Desktop-Chrome-linux.png | 3 + ...-2-Desktop-Chrome-no-JavaScript--linux.png | 3 + ...-author-s-name-2-Desktop-Firefox-linux.png | 3 + ...2-Desktop-Firefox-no-JavaScript--linux.png | 3 + ...hanged-author-s-name-2-iPhone-11-linux.png | 3 + ...-name-2-iPhone-11-no-JavaScript--linux.png | 3 + src/app.ts | 2 +- .../write-review-change-author.ts | 285 +++++++- .../write-review-change-author.test.ts | 661 +++++++++++++++++- 52 files changed, 1187 insertions(+), 46 deletions(-) create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Chrome-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Chrome-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Firefox-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Firefox-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-iPhone-11-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-iPhone-11-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Chrome-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Chrome-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Firefox-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Firefox-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-iPhone-11-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-iPhone-11-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Chrome-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Chrome-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Firefox-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Firefox-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-iPhone-11-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-iPhone-11-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Chrome-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Chrome-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Firefox-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Firefox-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-iPhone-11-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-iPhone-11-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Chrome-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Chrome-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Firefox-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Firefox-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-iPhone-11-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-iPhone-11-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Chrome-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Chrome-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Firefox-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Firefox-no-JavaScript--linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-iPhone-11-linux.png create mode 100644 integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-iPhone-11-no-JavaScript--linux.png diff --git a/integration/posting-a-prereview.spec.ts b/integration/posting-a-prereview.spec.ts index 15fd7e22b..2b2dac796 100644 --- a/integration/posting-a-prereview.spec.ts +++ b/integration/posting-a-prereview.spec.ts @@ -459,16 +459,28 @@ test.extend(canAddAuthors)('can add other authors to the PREreview', async ({ fe await expect(page.locator('h1')).toHaveText('You have added 3 other authors') await expect(page).toHaveScreenshot() - await page.click('role=link[name="Remove Otto Lidenbrock"]') + await page.goto('/preprints/doi-10.1101-2022.01.13.476201/write-a-prereview/change-author/1') - await expect(page.locator('h1')).toHaveText('Are you sure you want to remove Otto Lidenbrock?') + await expect(page.locator('h1')).toHaveText('Change Otto Lidenbrock') + await expect(page).toHaveScreenshot() + + await page.fill('role=textbox[name="Name"]', 'Arne Saknussemm') + await page.click('text="Save and continue"') + + await expect(page.locator('h1')).toHaveText('You have added 3 other authors') + await expect(page.locator('main')).not.toContainText('Otto Lidenbrock') + await expect(page).toHaveScreenshot() + + await page.click('role=link[name="Remove Arne Saknussemm"]') + + await expect(page.locator('h1')).toHaveText('Are you sure you want to remove Arne Saknussemm?') await expect(page).toHaveScreenshot() await page.check('text="Yes"') await page.click('text="Save and continue"') await expect(page.locator('h1')).toHaveText('You have added 2 other authors') - await expect(page.locator('main')).not.toContainText('Otto Lidenbrock') + await expect(page.locator('main')).not.toContainText('Arne Saknussemm') await page.check('text="No"') await page.click('text="Continue"') @@ -482,7 +494,7 @@ test.extend(canAddAuthors)('can add other authors to the PREreview', async ({ fe await expect(preview).toContainText('Jean-Baptiste Botul') await expect(preview).toContainText('Stephen Hawking') - await expect(preview).not.toContainText('Otto Lidenbrock') + await expect(preview).not.toContainText('Arne Saknussemm') await expect(page).toHaveScreenshot() fetch @@ -1378,6 +1390,115 @@ test.extend(canAddAuthors)('have to add a valid ORCID iD to an author', async ({ await expect(page).toHaveScreenshot() }) +test.extend(canAddAuthors)("have to add the changed author's name", async ({ fetch, javaScriptEnabled, page }) => { + await page.goto('/preprints/doi-10.1101-2022.01.13.476201/write-a-prereview') + await page.click('text="Start now"') + + await page.fill('[type=email]', 'test@example.com') + await page.fill('[type=password]', 'password') + fetch.postOnce('http://orcid.test/token', { + status: Status.OK, + body: { + access_token: 'access-token', + token_type: 'Bearer', + name: 'Josiah Carberry', + orcid: '0000-0002-1825-0097', + }, + }) + await page.keyboard.press('Enter') + + if (javaScriptEnabled) { + await page.locator('[contenteditable]').waitFor() + } + await page.fill( + 'role=textbox[name="Write your PREreview"]', + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + ) + await page.click('text="Save and continue"') + + await page.click('text="Save and continue"') + await page.check('text="Josiah Carberry"') + await page.click('text="Save and continue"') + await page.check('text="Yes"') + await page.click('text="Save and continue"') + await page.fill('role=textbox[name="Name"]', 'Otto Lidenbrock') + await page.click('text="Save and continue"') + + await page.goto('/preprints/doi-10.1101-2022.01.13.476201/write-a-prereview/change-author/0') + await page.fill('role=textbox[name="Name"]', '') + await page.click('text="Save and continue"') + + if (javaScriptEnabled) { + await expect(page.locator('role=alert[name="There is a problem"]')).toBeFocused() + } else { + await expect(page.locator('role=alert[name="There is a problem"]')).toBeVisible() + } + await expect(page.locator('role=textbox[name="Name"]')).toHaveAttribute('aria-invalid', 'true') + await expect(page).toHaveScreenshot() + + await page.click('text="Enter their name"') + + await expect(page.locator('role=textbox[name="Name"]')).toBeFocused() + await expect(page).toHaveScreenshot() +}) + +test.extend(canAddAuthors)( + 'have to add a valid ORCID iD to a changed author', + async ({ fetch, javaScriptEnabled, page }) => { + await page.goto('/preprints/doi-10.1101-2022.01.13.476201/write-a-prereview') + await page.click('text="Start now"') + + await page.fill('[type=email]', 'test@example.com') + await page.fill('[type=password]', 'password') + fetch.postOnce('http://orcid.test/token', { + status: Status.OK, + body: { + access_token: 'access-token', + token_type: 'Bearer', + name: 'Josiah Carberry', + orcid: '0000-0002-1825-0097', + }, + }) + await page.keyboard.press('Enter') + + if (javaScriptEnabled) { + await page.locator('[contenteditable]').waitFor() + } + await page.fill( + 'role=textbox[name="Write your PREreview"]', + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + ) + await page.click('text="Save and continue"') + + await page.click('text="Save and continue"') + await page.check('text="Josiah Carberry"') + await page.click('text="Save and continue"') + await page.check('text="Yes"') + await page.click('text="Save and continue"') + await page.fill('role=textbox[name="Name"]', 'Otto Lidenbrock') + await page.click('text="Save and continue"') + + await page.goto('/preprints/doi-10.1101-2022.01.13.476201/write-a-prereview/change-author/0') + await page.fill('role=textbox[name="ORCID iD (optional)"]', 'not an ORCID iD') + await page.click('text="Save and continue"') + + if (javaScriptEnabled) { + await expect(page.locator('role=alert[name="There is a problem"]')).toBeFocused() + } else { + await expect(page.locator('role=alert[name="There is a problem"]')).toBeVisible() + } + await expect(page.locator('role=textbox[name="ORCID iD (optional)"]')).toHaveAttribute('aria-invalid', 'true') + await expect(page.locator('role=textbox[name="ORCID iD (optional)"]')).toHaveValue('not an ORCID iD') + await expect(page.locator('role=textbox[name="Name"]')).toHaveValue('Otto Lidenbrock') + await expect(page).toHaveScreenshot() + + await page.click('text="Enter their ORCID iD"') + + await expect(page.locator('role=textbox[name="ORCID iD (optional)"]')).toBeFocused() + await expect(page).toHaveScreenshot() + }, +) + test.extend(canAddAuthors)( 'have to confirm if you want to remove an author', async ({ fetch, javaScriptEnabled, page }) => { diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Chrome-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Chrome-linux.png index fd920f53e..7d8eef177 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Chrome-linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Chrome-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2a920dd72acbf705a29597fb19c0c9f9deae30d82a9e532fd599799205b04fd7 -size 30774 +oid sha256:f689cf7bd639c8cd90e65305418ced7a46f71f5ab0f31281e0095acc53852eb1 +size 29947 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Chrome-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Chrome-no-JavaScript--linux.png index fd920f53e..7d8eef177 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Chrome-no-JavaScript--linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Chrome-no-JavaScript--linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2a920dd72acbf705a29597fb19c0c9f9deae30d82a9e532fd599799205b04fd7 -size 30774 +oid sha256:f689cf7bd639c8cd90e65305418ced7a46f71f5ab0f31281e0095acc53852eb1 +size 29947 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Firefox-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Firefox-linux.png index 5ee7bd669..f53e1cd0d 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Firefox-linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Firefox-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e40dcf701f25233d81a8af4018639fa67b1380544446f6dd2b3a7c5c8219b9b7 -size 50271 +oid sha256:752b4d9d5fb08f5ad7b584f7cc59ad15d8af8bb5f9cf4b0e22de332f8010aaae +size 49464 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Firefox-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Firefox-no-JavaScript--linux.png index 5ee7bd669..f53e1cd0d 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Firefox-no-JavaScript--linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-Desktop-Firefox-no-JavaScript--linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e40dcf701f25233d81a8af4018639fa67b1380544446f6dd2b3a7c5c8219b9b7 -size 50271 +oid sha256:752b4d9d5fb08f5ad7b584f7cc59ad15d8af8bb5f9cf4b0e22de332f8010aaae +size 49464 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-iPhone-11-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-iPhone-11-linux.png index 4451e3ae6..734f311c3 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-iPhone-11-linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-iPhone-11-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:80bc9071d436e0f075e0cca1c6a4b239cab7bd523420412b50fd7a75212a6e3c -size 21427 +oid sha256:ec1b441914c64ba0fc9f2e99f6e55e73c7a32e564ceb6b4482ba29ddf69cf450 +size 20776 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-iPhone-11-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-iPhone-11-no-JavaScript--linux.png index 4451e3ae6..734f311c3 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-iPhone-11-no-JavaScript--linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-4-iPhone-11-no-JavaScript--linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:80bc9071d436e0f075e0cca1c6a4b239cab7bd523420412b50fd7a75212a6e3c -size 21427 +oid sha256:ec1b441914c64ba0fc9f2e99f6e55e73c7a32e564ceb6b4482ba29ddf69cf450 +size 20776 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Chrome-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Chrome-linux.png index 0a99356ec..98d03cf71 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Chrome-linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Chrome-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:16315a0dfea40883852e509049d15422a2cf9dac49890c8bd011943814c4ed4b -size 72517 +oid sha256:7468680c210fb09637058d9016b9f16c8b8c695248875cca576d9c71abe52fc8 +size 40985 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Chrome-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Chrome-no-JavaScript--linux.png index 0a99356ec..98d03cf71 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Chrome-no-JavaScript--linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Chrome-no-JavaScript--linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:16315a0dfea40883852e509049d15422a2cf9dac49890c8bd011943814c4ed4b -size 72517 +oid sha256:7468680c210fb09637058d9016b9f16c8b8c695248875cca576d9c71abe52fc8 +size 40985 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Firefox-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Firefox-linux.png index a75cf96f4..e9a2cdce0 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Firefox-linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Firefox-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65c1e459e80ff3adc1ebe0fb7fbda12fcf31a0e1b40dcadf7abf7f6cbdd165f6 -size 114280 +oid sha256:a8e05501248e0fa7c6ae2d2791f289d85b61b814a090f1024a3b5f9d9f2e4525 +size 66864 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Firefox-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Firefox-no-JavaScript--linux.png index a75cf96f4..e9a2cdce0 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Firefox-no-JavaScript--linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-Desktop-Firefox-no-JavaScript--linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65c1e459e80ff3adc1ebe0fb7fbda12fcf31a0e1b40dcadf7abf7f6cbdd165f6 -size 114280 +oid sha256:a8e05501248e0fa7c6ae2d2791f289d85b61b814a090f1024a3b5f9d9f2e4525 +size 66864 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-iPhone-11-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-iPhone-11-linux.png index 9c00f49f9..bc89e8b05 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-iPhone-11-linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-iPhone-11-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c11eeec6e891aa02ce726308e17f65bb53338a390c685f2009bf233f9206b238 -size 51577 +oid sha256:4201a0265aee8c26a9325993a0658ef1729c5d83d97e499ee310b0f6bd33a53c +size 32746 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-iPhone-11-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-iPhone-11-no-JavaScript--linux.png index 9c00f49f9..bc89e8b05 100644 --- a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-iPhone-11-no-JavaScript--linux.png +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-5-iPhone-11-no-JavaScript--linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c11eeec6e891aa02ce726308e17f65bb53338a390c685f2009bf233f9206b238 -size 51577 +oid sha256:4201a0265aee8c26a9325993a0658ef1729c5d83d97e499ee310b0f6bd33a53c +size 32746 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Chrome-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Chrome-linux.png new file mode 100644 index 000000000..d8bc596c0 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Chrome-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b48f3cea63c62316862a18bbcddb16be7dfb3cedefd5b2e0799845167f3be795 +size 30621 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Chrome-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Chrome-no-JavaScript--linux.png new file mode 100644 index 000000000..d8bc596c0 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Chrome-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b48f3cea63c62316862a18bbcddb16be7dfb3cedefd5b2e0799845167f3be795 +size 30621 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Firefox-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Firefox-linux.png new file mode 100644 index 000000000..f749dde88 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Firefox-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed5e8a08c6d6d7525423ffc86594d546aa274b2f0de2c058f8064bc133bc908f +size 51577 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Firefox-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Firefox-no-JavaScript--linux.png new file mode 100644 index 000000000..f749dde88 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-Desktop-Firefox-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed5e8a08c6d6d7525423ffc86594d546aa274b2f0de2c058f8064bc133bc908f +size 51577 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-iPhone-11-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-iPhone-11-linux.png new file mode 100644 index 000000000..ab61bbfac --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-iPhone-11-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff09ce6523c6e5bfa77771df3ad1782cce5b38377676a22d48ed85913b4ae398 +size 23005 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-iPhone-11-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-iPhone-11-no-JavaScript--linux.png new file mode 100644 index 000000000..ab61bbfac --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-6-iPhone-11-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff09ce6523c6e5bfa77771df3ad1782cce5b38377676a22d48ed85913b4ae398 +size 23005 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Chrome-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Chrome-linux.png new file mode 100644 index 000000000..0a99356ec --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Chrome-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16315a0dfea40883852e509049d15422a2cf9dac49890c8bd011943814c4ed4b +size 72517 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Chrome-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Chrome-no-JavaScript--linux.png new file mode 100644 index 000000000..0a99356ec --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Chrome-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16315a0dfea40883852e509049d15422a2cf9dac49890c8bd011943814c4ed4b +size 72517 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Firefox-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Firefox-linux.png new file mode 100644 index 000000000..a75cf96f4 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Firefox-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65c1e459e80ff3adc1ebe0fb7fbda12fcf31a0e1b40dcadf7abf7f6cbdd165f6 +size 114280 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Firefox-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Firefox-no-JavaScript--linux.png new file mode 100644 index 000000000..a75cf96f4 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-Desktop-Firefox-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65c1e459e80ff3adc1ebe0fb7fbda12fcf31a0e1b40dcadf7abf7f6cbdd165f6 +size 114280 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-iPhone-11-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-iPhone-11-linux.png new file mode 100644 index 000000000..9c00f49f9 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-iPhone-11-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c11eeec6e891aa02ce726308e17f65bb53338a390c685f2009bf233f9206b238 +size 51577 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-iPhone-11-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-iPhone-11-no-JavaScript--linux.png new file mode 100644 index 000000000..9c00f49f9 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/can-add-other-authors-to-the-PREreview-7-iPhone-11-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c11eeec6e891aa02ce726308e17f65bb53338a390c685f2009bf233f9206b238 +size 51577 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Chrome-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Chrome-linux.png new file mode 100644 index 000000000..a44f37c3a --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Chrome-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79b34b337cd039a6c0f946164c82aebe7f01fec6755cd78e84597c73a693c8fd +size 39879 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Chrome-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Chrome-no-JavaScript--linux.png new file mode 100644 index 000000000..52f9ec163 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Chrome-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5cca527d0d4c1b9018d30ee8398e7df1501d1b4d3a5e14002d0b8ba4c05594db +size 39820 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Firefox-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Firefox-linux.png new file mode 100644 index 000000000..67878202e --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Firefox-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c7b88cd07da6d148474f03eb450f67b6ac32dbf4091b978c17ae227516f5d50 +size 63565 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Firefox-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Firefox-no-JavaScript--linux.png new file mode 100644 index 000000000..a84481e6b --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-Desktop-Firefox-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa0837f8aa7f14c7142728a5383a15e536e6402a9d34d34a9800b16d67882e60 +size 63672 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-iPhone-11-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-iPhone-11-linux.png new file mode 100644 index 000000000..357960636 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-iPhone-11-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52c2bc376f508e2dc69b99db8983ed3c3c4bf63026edd1701ee355951f17f221 +size 29652 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-iPhone-11-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-iPhone-11-no-JavaScript--linux.png new file mode 100644 index 000000000..080201bb9 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-1-iPhone-11-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b2d5b5e9dbc8482b296076dca1cd8e6071e7323b22f157fc3eec6b4d326d482 +size 29555 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Chrome-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Chrome-linux.png new file mode 100644 index 000000000..9af017522 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Chrome-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a8b16d22a8f8b1b3adbb57935cc4e0694f4d9abcc5684b6d2f8e8a3b5b556305 +size 37422 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Chrome-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Chrome-no-JavaScript--linux.png new file mode 100644 index 000000000..9af017522 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Chrome-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a8b16d22a8f8b1b3adbb57935cc4e0694f4d9abcc5684b6d2f8e8a3b5b556305 +size 37422 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Firefox-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Firefox-linux.png new file mode 100644 index 000000000..fbd8ca21c --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Firefox-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01be85dc9403903e46053de7b8148b516f36aac4b722f889e91a32f8327e58dd +size 61027 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Firefox-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Firefox-no-JavaScript--linux.png new file mode 100644 index 000000000..fbd8ca21c --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-Desktop-Firefox-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01be85dc9403903e46053de7b8148b516f36aac4b722f889e91a32f8327e58dd +size 61027 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-iPhone-11-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-iPhone-11-linux.png new file mode 100644 index 000000000..56510ba5a --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-iPhone-11-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:74491bc04fd4e6e1c04bda1a0249d55143a411904ae93681ed394a2d51059e10 +size 29641 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-iPhone-11-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-iPhone-11-no-JavaScript--linux.png new file mode 100644 index 000000000..f7369db66 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-a-valid-ORCID-iD-to-a-changed-author-2-iPhone-11-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2dc716d6a96e1c1182d8084bc6692c49e90fce6df4ca430c772603f7fb00d6d3 +size 29608 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Chrome-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Chrome-linux.png new file mode 100644 index 000000000..fa01bd94c --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Chrome-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:385387ee957ac7ee2999c848d209411f0a70ce7ee0bc936c4dff3035dd6596a6 +size 33414 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Chrome-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Chrome-no-JavaScript--linux.png new file mode 100644 index 000000000..41951c4af --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Chrome-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d3928bb4f67ff06319e9d66747a4ba5774448f6972c6576c0ec9f87217fd2950 +size 33347 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Firefox-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Firefox-linux.png new file mode 100644 index 000000000..e9c0598ec --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Firefox-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78e4a147b77b6b9f518e66abf998eec9322bd7b2358fbd21b4153cc9f63ae199 +size 55928 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Firefox-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Firefox-no-JavaScript--linux.png new file mode 100644 index 000000000..2df51c389 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-Desktop-Firefox-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb8a5e97086a6abc27b100fc8a0b7898f72dd0577a93d6f71881d56450d7f1fb +size 55968 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-iPhone-11-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-iPhone-11-linux.png new file mode 100644 index 000000000..af6857f40 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-iPhone-11-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae53c5f17e7e229cb985f3f75e197892afbadf8f5228dd23e5db7356354c9b0f +size 24250 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-iPhone-11-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-iPhone-11-no-JavaScript--linux.png new file mode 100644 index 000000000..eb3d67d09 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-1-iPhone-11-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aaba45579b888dc5f36b682db284ece2f28fcbcfb57a8b02f55b4b0f4646255d +size 24160 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Chrome-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Chrome-linux.png new file mode 100644 index 000000000..9e08bd611 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Chrome-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04104a6fb93176d03caab07d95928ec2a0494ca914c5c5b328162bd71da8da33 +size 30782 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Chrome-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Chrome-no-JavaScript--linux.png new file mode 100644 index 000000000..9e08bd611 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Chrome-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04104a6fb93176d03caab07d95928ec2a0494ca914c5c5b328162bd71da8da33 +size 30782 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Firefox-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Firefox-linux.png new file mode 100644 index 000000000..776071712 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Firefox-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f3304d8cf8e1a99452655e0bf6e797ff73ee14bfca46aac8f126101b71b05216 +size 53259 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Firefox-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Firefox-no-JavaScript--linux.png new file mode 100644 index 000000000..776071712 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-Desktop-Firefox-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f3304d8cf8e1a99452655e0bf6e797ff73ee14bfca46aac8f126101b71b05216 +size 53259 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-iPhone-11-linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-iPhone-11-linux.png new file mode 100644 index 000000000..5208953c5 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-iPhone-11-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:832dbac6207fd925a46aee9b647d17166a2c47fab67c30299ef86db87001c9ee +size 24184 diff --git a/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-iPhone-11-no-JavaScript--linux.png b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-iPhone-11-no-JavaScript--linux.png new file mode 100644 index 000000000..5208953c5 --- /dev/null +++ b/integration/snapshots/posting-a-prereview.spec.ts-snapshots/have-to-add-the-changed-author-s-name-2-iPhone-11-no-JavaScript--linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:832dbac6207fd925a46aee9b647d17166a2c47fab67c30299ef86db87001c9ee +size 24184 diff --git a/src/app.ts b/src/app.ts index 29019625a..81071c4cd 100644 --- a/src/app.ts +++ b/src/app.ts @@ -137,7 +137,7 @@ export const router: P.Parser writeReviewChangeAuthor()), + P.map(({ doi, index }) => writeReviewChangeAuthor(doi, index)), ), pipe( writeReviewRemoveAuthorMatch.parser, diff --git a/src/write-review/write-review-change-author.ts b/src/write-review/write-review-change-author.ts index 8416daff0..f7cd04deb 100644 --- a/src/write-review/write-review-change-author.ts +++ b/src/write-review/write-review-change-author.ts @@ -1,3 +1,284 @@ -import { notFound } from '../middleware' +import { format } from 'fp-ts-routing' +import * as E from 'fp-ts/Either' +import * as O from 'fp-ts/Option' +import { Reader } from 'fp-ts/Reader' +import * as RA from 'fp-ts/ReadonlyArray' +import { constUndefined, flow, pipe } from 'fp-ts/function' +import { Status, StatusOpen } from 'hyper-ts' +import * as RM from 'hyper-ts/lib/ReaderMiddleware' +import * as D from 'io-ts/Decoder' +import { Orcid, parse } from 'orcid-id-ts' +import { get } from 'spectacles-ts' +import { P, match } from 'ts-pattern' +import { canAddAuthors } from '../feature-flags' +import { InvalidE, MissingE, getInput, hasAnError, invalidE, missingE } from '../form' +import { html, plainText, rawHtml, sendHtml } from '../html' +import { notFound, seeOther, serviceUnavailable } from '../middleware' +import { page } from '../page' +import { PreprintId } from '../preprint-id' +import { writeReviewAddAuthorsMatch, writeReviewChangeAuthorMatch, writeReviewMatch } from '../routes' +import { NonEmptyString, NonEmptyStringC } from '../string' +import { User, getUserFromSession } from '../user' +import { Form, getForm, saveForm, updateForm } from './form' +import { Preprint, getPreprint } from './preprint' -export const writeReviewChangeAuthor = () => notFound +export const writeReviewChangeAuthor = (doi: PreprintId['doi'], index: number) => + pipe( + RM.fromReaderTaskEither(getPreprint(doi)), + RM.ichainW(preprint => + pipe( + RM.right({ preprint }), + RM.apS('user', getUserFromSession()), + RM.bindW( + 'canAddAuthors', + fromReaderK(({ user }) => canAddAuthors(user)), + ), + RM.filterOrElseW( + ({ canAddAuthors }) => canAddAuthors, + () => 'not-found', + ), + RM.bindW('form', ({ user }) => RM.rightReaderTask(getForm(user.orcid, preprint.doi))), + RM.bindW('author', ({ form }) => + RM.fromEither( + pipe( + form.otherAuthors ?? [], + E.fromOptionK(() => 'not-found')(RA.lookup(index)), + E.let('index', () => index), + ), + ), + ), + RM.apSW('method', RM.decodeMethod(E.right)), + RM.ichainW(state => + match(state) + .with({ form: { moreAuthors: 'yes' }, method: 'POST' }, handleChangeAuthorForm) + .with({ form: { moreAuthors: 'yes' } }, showChangeAuthorForm) + .otherwise(() => notFound), + ), + RM.orElseW(error => + match(error) + .with('not-found', () => notFound) + .otherwise(() => RM.fromMiddleware(seeOther(format(writeReviewMatch.formatter, { doi: preprint.doi })))), + ), + ), + ), + RM.orElseW(error => + match(error) + .with('not-found', () => notFound) + .with('unavailable', () => serviceUnavailable) + .exhaustive(), + ), + ) + +const showChangeAuthorForm = flow( + fromReaderK(({ preprint, author }: { preprint: Preprint; author: Author }) => + changeAuthorForm(preprint, author, { name: E.right(author.name), orcid: E.right(author.orcid) }), + ), + RM.ichainFirst(() => RM.status(Status.OK)), + RM.ichainMiddlewareK(sendHtml), +) + +const showChangeAuthorErrorForm = (preprint: Preprint, author: Author) => + flow( + fromReaderK((form: ChangeAuthorForm) => changeAuthorForm(preprint, author, form)), + RM.ichainFirst(() => RM.status(Status.BadRequest)), + RM.ichainMiddlewareK(sendHtml), + ) + +const handleChangeAuthorForm = ({ + form, + preprint, + author, + user, +}: { + form: Form + preprint: Preprint + author: Author + user: User +}) => + pipe( + RM.decodeBody(body => + E.right({ + name: pipe(NameFieldD.decode(body), E.mapLeft(missingE)), + orcid: pipe( + OrcidFieldD.decode(body), + E.mapLeft( + flow( + getInput('orcid'), + O.getOrElse(() => ''), + invalidE, + ), + ), + ), + }), + ), + RM.chainEitherK(fields => + pipe( + E.Do, + E.apS('name', fields.name), + E.apSW('orcid', fields.orcid), + E.mapLeft(() => fields), + ), + ), + RM.map(changedAuthor => + pipe( + form.otherAuthors ?? [], + RA.updateAt(author.index, changedAuthor.orcid ? changedAuthor : { name: changedAuthor.name }), + O.getOrElse(() => form.otherAuthors ?? []), + otherAuthors => ({ otherAuthors }), + updateForm(form), + ), + ), + RM.chainFirstReaderTaskK(saveForm(user.orcid, preprint.doi)), + RM.ichainMiddlewareK(() => seeOther(format(writeReviewAddAuthorsMatch.formatter, { doi: preprint.doi }))), + RM.orElseW(showChangeAuthorErrorForm(preprint, author)), + ) + +type Author = { + readonly name: NonEmptyString + readonly orcid?: Orcid + readonly index: number +} + +const OrcidD = pipe( + D.string, + D.parse(s => E.fromOption(() => D.error(s, 'ORCID'))(parse(s))), +) + +const NameFieldD = pipe(D.struct({ name: NonEmptyStringC }), D.map(get('name'))) + +const OrcidFieldD = pipe( + D.struct({ orcid: D.union(OrcidD, pipe(D.literal(''), D.map(constUndefined))) }), + D.map(get('orcid')), +) + +type ChangeAuthorForm = { + readonly name: E.Either + readonly orcid: E.Either +} + +function changeAuthorForm(preprint: Preprint, author: Author, form: ChangeAuthorForm) { + const error = hasAnError(form) + + return page({ + title: plainText`${error ? 'Error: ' : ''}Change ${author.name} – PREreview of “${preprint.title}”`, + content: html` + + +
+
+ ${error + ? html` + +

There is a problem

+ +
+ ` + : ''} + +

Change ${author.name}

+ +
+ + + ${E.isLeft(form.name) + ? html` +
+ Error: + ${match(form.name.left) + .with({ _tag: 'MissingE' }, () => 'Enter their name') + .exhaustive()} +
+ ` + : ''} + + html`value="${value}"`) + .otherwise(() => '')} + ${rawHtml(E.isLeft(form.name) ? 'aria-invalid="true" aria-errormessage="change-author-name-error"' : '')} + /> +
+ +
+ + + ${E.isLeft(form.orcid) + ? html` +
+ Error: + + ${match(form.orcid.left) + .with({ _tag: 'InvalidE' }, () => rawHtml('Enter their ORCID iD')) + .exhaustive()} +
+ ` + : ''} + + html`value="${value}"`) + .with(E.left({ actual: P.select() }), value => html`value="${value}"`) + .otherwise(() => '')} + ${rawHtml( + E.isLeft(form.orcid) ? 'aria-invalid="true" aria-errormessage="change-author-orcid-error"' : '', + )} + /> +
+ + +
+
+ `, + js: ['error-summary.js'], + }) +} + +// https://github.com/DenisFrezzato/hyper-ts/pull/85 +function fromReaderK, B, I = StatusOpen, E = never>( + f: (...a: A) => Reader, +): (...a: A) => RM.ReaderMiddleware { + return (...a) => RM.rightReader(f(...a)) +} diff --git a/test/write-review/write-review-change-author.test.ts b/test/write-review/write-review-change-author.test.ts index b40774524..ad6bb2443 100644 --- a/test/write-review/write-review-change-author.test.ts +++ b/test/write-review/write-review-change-author.test.ts @@ -1,22 +1,653 @@ +import cookieSignature from 'cookie-signature' import * as E from 'fp-ts/Either' +import * as TE from 'fp-ts/TaskEither' import { MediaType, Status } from 'hyper-ts' +import Keyv from 'keyv' +import { CanAddAuthorsEnv } from '../../src/feature-flags' +import { UserC } from '../../src/user' import * as _ from '../../src/write-review' import * as fc from '../fc' import { runMiddleware } from '../middleware' -test('writeReviewChangeAuthor', async () => { - await fc.assert( - fc.asyncProperty(fc.connection({}), async connection => { - const actual = await runMiddleware(_.writeReviewChangeAuthor()({}), connection)() - - expect(actual).toStrictEqual( - E.right([ - { type: 'setStatus', status: Status.NotFound }, - { type: 'setHeader', name: 'Cache-Control', value: 'no-store, must-revalidate' }, - { type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML }, - { type: 'setBody', body: expect.anything() }, - ]), - ) - }), - ) +describe('writeReviewChangeAuthor', () => { + test('when the form is completed', async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.record({ title: fc.html(), language: fc.languageCode() }), + fc + .tuple( + fc.record({ name: fc.nonEmptyString(), orcid: fc.option(fc.orcid(), { nil: undefined }) }), + fc.uuid(), + fc.string(), + ) + .chain(([otherAuthor, sessionId, secret]) => + fc.tuple( + fc.constant(otherAuthor), + fc.connection({ + body: fc.constant({ name: otherAuthor.name, orcid: otherAuthor.orcid ?? '' }), + headers: fc.constant({ Cookie: `session=${cookieSignature.sign(sessionId, secret)}` }), + method: fc.constant('POST'), + }), + fc.constant(sessionId), + fc.constant(secret), + ), + ), + fc.user(), + fc + .record( + { + competingInterests: fc.constantFrom('yes', 'no'), + competingInterestsDetails: fc.lorem(), + conduct: fc.constant('yes'), + moreAuthors: fc.constant('yes'), + otherAuthors: fc.nonEmptyArray( + fc.record({ name: fc.nonEmptyString(), orcid: fc.orcid() }, { requiredKeys: ['name'] }), + ), + persona: fc.constantFrom('public', 'pseudonym'), + review: fc.nonEmptyString(), + }, + { requiredKeys: ['moreAuthors', 'otherAuthors'] }, + ) + .chain(newReview => + fc.tuple(fc.constant(newReview), fc.integer({ min: 0, max: newReview.otherAuthors.length - 1 })), + ), + async (preprintDoi, preprintTitle, [author, connection, sessionId, secret], user, [newReview, authorIndex]) => { + const sessionStore = new Keyv() + await sessionStore.set(sessionId, UserC.encode(user)) + const formStore = new Keyv() + await formStore.set(`${user.orcid}_${preprintDoi}`, newReview) + const canAddAuthors: jest.MockedFunction = jest.fn(_ => true) + const getPreprintTitle: jest.MockedFunction<_.GetPreprintTitleEnv['getPreprintTitle']> = jest.fn(_ => + TE.right(preprintTitle), + ) + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(await formStore.get(`${user.orcid}_${preprintDoi}`)).toMatchObject({ + otherAuthors: expect.arrayContaining([author]), + }) + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.SeeOther }, + { + type: 'setHeader', + name: 'Location', + value: `/preprints/doi-${encodeURIComponent( + preprintDoi.toLowerCase().replaceAll('-', '+').replaceAll('/', '-'), + )}/write-a-prereview/add-more-authors`, + }, + { type: 'endResponse' }, + ]), + ) + expect(canAddAuthors).toHaveBeenCalledWith(user) + expect(getPreprintTitle).toHaveBeenCalledWith(preprintDoi) + }, + ), + ) + }) + + test('when there are no more authors', async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.record({ title: fc.html(), language: fc.languageCode() }), + fc + .tuple(fc.uuid(), fc.string()) + .chain(([sessionId, secret]) => + fc.tuple( + fc.connection({ headers: fc.constant({ Cookie: `session=${cookieSignature.sign(sessionId, secret)}` }) }), + fc.constant(sessionId), + fc.constant(secret), + ), + ), + fc.user(), + fc + .record( + { + competingInterests: fc.constantFrom('yes', 'no'), + competingInterestsDetails: fc.lorem(), + conduct: fc.constant('yes'), + moreAuthors: fc.constant('no'), + otherAuthors: fc.nonEmptyArray( + fc.record({ name: fc.nonEmptyString(), orcid: fc.orcid() }, { requiredKeys: ['name'] }), + ), + persona: fc.constantFrom('public', 'pseudonym'), + review: fc.nonEmptyString(), + }, + { requiredKeys: ['moreAuthors', 'otherAuthors'] }, + ) + .chain(newReview => + fc.tuple(fc.constant(newReview), fc.integer({ min: 0, max: newReview.otherAuthors.length - 1 })), + ), + async (preprintDoi, preprintTitle, [connection, sessionId, secret], user, [newReview, authorIndex]) => { + const sessionStore = new Keyv() + await sessionStore.set(sessionId, UserC.encode(user)) + const formStore = new Keyv() + await formStore.set(`${user.orcid}_${preprintDoi}`, newReview) + const getPreprintTitle = () => TE.right(preprintTitle) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => true, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.NotFound }, + { type: 'setHeader', name: 'Cache-Control', value: 'no-store, must-revalidate' }, + { type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML }, + { type: 'setBody', body: expect.anything() }, + ]), + ) + }, + ), + ) + }) + + test('when the author is not found', async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.record({ title: fc.html(), language: fc.languageCode() }), + fc + .tuple(fc.uuid(), fc.string()) + .chain(([sessionId, secret]) => + fc.tuple( + fc.connection({ headers: fc.constant({ Cookie: `session=${cookieSignature.sign(sessionId, secret)}` }) }), + fc.constant(sessionId), + fc.constant(secret), + ), + ), + fc.user(), + fc + .record( + { + competingInterests: fc.constantFrom('yes', 'no'), + competingInterestsDetails: fc.lorem(), + conduct: fc.constant('yes'), + moreAuthors: fc.constant('no'), + otherAuthors: fc.array( + fc.record({ name: fc.nonEmptyString(), orcid: fc.orcid() }, { requiredKeys: ['name'] }), + ), + persona: fc.constantFrom('public', 'pseudonym'), + review: fc.nonEmptyString(), + }, + { requiredKeys: ['moreAuthors', 'otherAuthors'] }, + ) + .chain(newReview => fc.tuple(fc.constant(newReview), fc.integer({ min: newReview.otherAuthors.length }))), + async (preprintDoi, preprintTitle, [connection, sessionId, secret], user, [newReview, authorIndex]) => { + const sessionStore = new Keyv() + await sessionStore.set(sessionId, UserC.encode(user)) + const formStore = new Keyv() + await formStore.set(`${user.orcid}_${preprintDoi}`, newReview) + const getPreprintTitle = () => TE.right(preprintTitle) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => true, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.NotFound }, + { type: 'setHeader', name: 'Cache-Control', value: 'no-store, must-revalidate' }, + { type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML }, + { type: 'setBody', body: expect.anything() }, + ]), + ) + }, + ), + ) + }) + + test('when the preprint cannot be loaded', async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.tuple(fc.uuid(), fc.string()).chain(([sessionId, secret]) => + fc.tuple( + fc.connection({ + headers: fc.constant({ Cookie: `session=${cookieSignature.sign(sessionId, secret)}` }), + method: fc.constant('POST'), + }), + fc.constant(sessionId), + fc.constant(secret), + ), + ), + fc.user(), + fc.boolean(), + fc.record( + { + competingInterests: fc.constantFrom('yes', 'no'), + competingInterestsDetails: fc.lorem(), + conduct: fc.constant('yes'), + moreAuthors: fc.constantFrom('yes', 'no'), + otherAuthors: fc.nonEmptyArray( + fc.record({ name: fc.nonEmptyString(), orcid: fc.orcid() }, { requiredKeys: ['name'] }), + ), + persona: fc.constantFrom('public', 'pseudonym'), + review: fc.nonEmptyString(), + }, + { withDeletedKeys: true }, + ), + fc.integer(), + async (preprintDoi, [connection, sessionId, secret], user, canAddAuthors, newReview, authorIndex) => { + const sessionStore = new Keyv() + await sessionStore.set(sessionId, UserC.encode(user)) + const formStore = new Keyv() + await formStore.set(`${user.orcid}_${preprintDoi}`, newReview) + const getPreprintTitle = () => TE.left('unavailable' as const) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => canAddAuthors, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.ServiceUnavailable }, + { type: 'setHeader', name: 'Cache-Control', value: 'no-store, must-revalidate' }, + { type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML }, + { type: 'setBody', body: expect.anything() }, + ]), + ) + }, + ), + ) + }) + + test('when the preprint cannot be found', async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.tuple(fc.uuid(), fc.string()).chain(([sessionId, secret]) => + fc.tuple( + fc.connection({ + headers: fc.constant({ Cookie: `session=${cookieSignature.sign(sessionId, secret)}` }), + method: fc.constant('POST'), + }), + fc.constant(sessionId), + fc.constant(secret), + ), + ), + fc.user(), + fc.boolean(), + fc.record( + { + competingInterests: fc.constantFrom('yes', 'no'), + competingInterestsDetails: fc.lorem(), + conduct: fc.constant('yes'), + moreAuthors: fc.constantFrom('yes', 'no'), + otherAuthors: fc.array( + fc.record({ name: fc.nonEmptyString(), orcid: fc.orcid() }, { requiredKeys: ['name'] }), + ), + persona: fc.constantFrom('public', 'pseudonym'), + review: fc.nonEmptyString(), + }, + { withDeletedKeys: true }, + ), + fc.integer(), + async (preprintDoi, [connection, sessionId, secret], user, canAddAuthors, newReview, authorIndex) => { + const sessionStore = new Keyv() + await sessionStore.set(sessionId, UserC.encode(user)) + const formStore = new Keyv() + await formStore.set(`${user.orcid}_${preprintDoi}`, newReview) + const getPreprintTitle = () => TE.left('not-found' as const) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => canAddAuthors, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.NotFound }, + { type: 'setHeader', name: 'Cache-Control', value: 'no-store, must-revalidate' }, + { type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML }, + { type: 'setBody', body: expect.anything() }, + ]), + ) + }, + ), + ) + }) + + test("when authors can't be added", async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.record({ title: fc.html(), language: fc.languageCode() }), + fc.tuple(fc.uuid(), fc.string()).chain(([sessionId, secret]) => + fc.tuple( + fc.connection({ + headers: fc.constant({ Cookie: `session=${cookieSignature.sign(sessionId, secret)}` }), + method: fc.constant('POST'), + }), + fc.constant(sessionId), + fc.constant(secret), + ), + ), + fc.user(), + fc.record( + { + competingInterests: fc.constantFrom('yes', 'no'), + competingInterestsDetails: fc.lorem(), + conduct: fc.constant('yes'), + moreAuthors: fc.constantFrom('yes', 'no'), + otherAuthors: fc.array( + fc.record({ name: fc.nonEmptyString(), orcid: fc.orcid() }, { requiredKeys: ['name'] }), + ), + persona: fc.constantFrom('public', 'pseudonym'), + review: fc.nonEmptyString(), + }, + { withDeletedKeys: true }, + ), + fc.integer(), + async (preprintDoi, preprintTitle, [connection, sessionId, secret], user, newReview, authorIndex) => { + const sessionStore = new Keyv() + await sessionStore.set(sessionId, UserC.encode(user)) + const formStore = new Keyv() + await formStore.set(`${user.orcid}_${preprintDoi}`, newReview) + const getPreprintTitle = () => TE.right(preprintTitle) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => false, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.NotFound }, + { type: 'setHeader', name: 'Cache-Control', value: 'no-store, must-revalidate' }, + { type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML }, + { type: 'setBody', body: expect.anything() }, + ]), + ) + }, + ), + ) + }) + + test("when there isn't a session", async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.record({ title: fc.html(), language: fc.languageCode() }), + fc.connection({ method: fc.constant('POST') }), + fc.string(), + fc.integer(), + async (preprintDoi, preprintTitle, connection, secret, authorIndex) => { + const sessionStore = new Keyv() + const formStore = new Keyv() + const getPreprintTitle = () => TE.right(preprintTitle) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => true, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.SeeOther }, + { + type: 'setHeader', + name: 'Location', + value: `/preprints/doi-${encodeURIComponent( + preprintDoi.toLowerCase().replaceAll('-', '+').replaceAll('/', '-'), + )}/write-a-prereview`, + }, + { type: 'endResponse' }, + ]), + ) + }, + ), + ) + }) + + test("when there isn't a session", async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.record({ title: fc.html(), language: fc.languageCode() }), + fc.connection({ method: fc.constant('POST') }), + fc.string(), + fc.integer(), + async (preprintDoi, preprintTitle, connection, secret, authorIndex) => { + const sessionStore = new Keyv() + const formStore = new Keyv() + const getPreprintTitle = () => TE.right(preprintTitle) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => true, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.SeeOther }, + { + type: 'setHeader', + name: 'Location', + value: `/preprints/doi-${encodeURIComponent( + preprintDoi.toLowerCase().replaceAll('-', '+').replaceAll('/', '-'), + )}/write-a-prereview`, + }, + { type: 'endResponse' }, + ]), + ) + }, + ), + ) + }) + + test('without a name', async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.record({ title: fc.html(), language: fc.languageCode() }), + fc.tuple(fc.uuid(), fc.string()).chain(([sessionId, secret]) => + fc.tuple( + fc.connection({ + body: fc.constant({}), + headers: fc.constant({ Cookie: `session=${cookieSignature.sign(sessionId, secret)}` }), + method: fc.constant('POST'), + }), + fc.constant(sessionId), + fc.constant(secret), + ), + ), + fc.user(), + fc + .record( + { + competingInterests: fc.constantFrom('yes', 'no'), + competingInterestsDetails: fc.lorem(), + conduct: fc.constant('yes'), + moreAuthors: fc.constant('yes'), + otherAuthors: fc.nonEmptyArray( + fc.record({ name: fc.nonEmptyString(), orcid: fc.orcid() }, { requiredKeys: ['name'] }), + ), + persona: fc.constantFrom('public', 'pseudonym'), + review: fc.nonEmptyString(), + }, + { requiredKeys: ['moreAuthors', 'otherAuthors'] }, + ) + .chain(newReview => + fc.tuple(fc.constant(newReview), fc.integer({ min: 0, max: newReview.otherAuthors.length - 1 })), + ), + async (preprintDoi, preprintTitle, [connection, sessionId, secret], user, [newReview, authorIndex]) => { + const sessionStore = new Keyv() + await sessionStore.set(sessionId, UserC.encode(user)) + const formStore = new Keyv() + await formStore.set(`${user.orcid}_${preprintDoi}`, newReview) + const getPreprintTitle = () => TE.right(preprintTitle) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => true, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.BadRequest }, + { type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML }, + { type: 'setBody', body: expect.anything() }, + ]), + ) + }, + ), + ) + }) + + test('without an ORCID iD', async () => { + await fc.assert( + fc.asyncProperty( + fc.preprintDoi(), + fc.record({ title: fc.html(), language: fc.languageCode() }), + fc.tuple(fc.uuid(), fc.string()).chain(([sessionId, secret]) => + fc.tuple( + fc.connection({ + body: fc.record({ name: fc.nonEmptyString(), orcid: fc.nonEmptyString() }, { requiredKeys: ['name'] }), + headers: fc.constant({ Cookie: `session=${cookieSignature.sign(sessionId, secret)}` }), + method: fc.constant('POST'), + }), + fc.constant(sessionId), + fc.constant(secret), + ), + ), + fc.user(), + fc + .record( + { + competingInterests: fc.constantFrom('yes', 'no'), + competingInterestsDetails: fc.lorem(), + conduct: fc.constant('yes'), + moreAuthors: fc.constant('yes'), + otherAuthors: fc.nonEmptyArray( + fc.record({ name: fc.nonEmptyString(), orcid: fc.orcid() }, { requiredKeys: ['name'] }), + ), + persona: fc.constantFrom('public', 'pseudonym'), + review: fc.nonEmptyString(), + }, + { requiredKeys: ['moreAuthors', 'otherAuthors'] }, + ) + .chain(newReview => + fc.tuple(fc.constant(newReview), fc.integer({ min: 0, max: newReview.otherAuthors.length - 1 })), + ), + async (preprintDoi, preprintTitle, [connection, sessionId, secret], user, [newReview, authorIndex]) => { + const sessionStore = new Keyv() + await sessionStore.set(sessionId, UserC.encode(user)) + const formStore = new Keyv() + await formStore.set(`${user.orcid}_${preprintDoi}`, newReview) + const getPreprintTitle = () => TE.right(preprintTitle) + + const actual = await runMiddleware( + _.writeReviewChangeAuthor( + preprintDoi, + authorIndex, + )({ + canAddAuthors: () => true, + formStore, + getPreprintTitle, + secret, + sessionStore, + }), + connection, + )() + + expect(actual).toStrictEqual( + E.right([ + { type: 'setStatus', status: Status.BadRequest }, + { type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML }, + { type: 'setBody', body: expect.anything() }, + ]), + ) + }, + ), + ) + }) })