From 16ea422124fbaaa5a02381f92148573e5668aeef Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Mon, 6 Jan 2025 15:59:30 +0000 Subject: [PATCH] Prefer a named constructor to casting Refs #1834, #2165 --- integration/base.ts | 6 ++--- src/types/uuid.ts | 2 +- test/Comments/Queries.test.ts | 8 +++---- test/fc.ts | 4 ++-- .../CheckPage/CheckPage.spec.ts | 8 +++---- .../ChoosePersonaPage.spec.ts | 8 +++---- .../CodeOfConductPage.spec.ts | 6 ++--- .../CompetingInterestsPage.spec.ts | 10 ++++----- .../EnterCommentPage/EnterCommentPage.spec.ts | 8 +++---- .../EnterEmailAddressPage.spec.ts | 10 ++++----- .../NeedToVerifyEmailAddressPage.spec.ts | 4 ++-- .../PublishedPage/PublishedPage.spec.ts | 4 ++-- .../PublishingPage/PublishingPage.spec.ts | 4 ++-- .../StartNow/CarryOnPage.spec.ts | 4 ++-- .../author-invite-check.test.ts | 6 ++--- .../author-invite-decline.test.ts | 6 ++--- .../author-invite-enter-email-address.test.ts | 10 ++++----- ...nvite-need-to-verify-email-address.test.ts | 6 ++--- .../author-invite-persona.test.ts | 6 ++--- .../author-invite-published.test.ts | 4 ++-- .../author-invite-start.test.ts | 4 ++-- .../author-invite-flow/author-invite.test.ts | 6 ++--- visual-regression/email.spec.ts | 22 +++++++++---------- .../my-details/my-details-page.spec.ts | 4 ++-- 24 files changed, 80 insertions(+), 80 deletions(-) diff --git a/integration/base.ts b/integration/base.ts index 25bd6964e..827b10eca 100644 --- a/integration/base.ts +++ b/integration/base.ts @@ -22,7 +22,7 @@ import { type MutableRedirectUri, OAuth2Server } from 'oauth2-mock-server' import { Orcid } from 'orcid-id-ts' import type { BrowserContextOptions } from 'playwright-core' import { URL } from 'url' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { EmptyDepositionC, InProgressDepositionC, @@ -1999,7 +1999,7 @@ export const hasAnUnverifiedEmailAddress: Fixtures< ContactEmailAddressC.encode( new UnverifiedContactEmailAddress({ value: EmailAddress('jcarberry@example.com'), - verificationToken: 'ff0d6f8e-7dca-4a26-b68b-93f2d2bc3c2a' as Uuid, + verificationToken: Uuid('ff0d6f8e-7dca-4a26-b68b-93f2d2bc3c2a'), }), ), ) @@ -2104,7 +2104,7 @@ export const invitedToBeAnAuthor: Fixtures< name: 'Josiah Carberry' as NonEmptyString, emailAddress: EmailAddress('jcarberry@example.com'), }, - 'bec5727e-9992-4f3b-85be-6712df617b9d' as Uuid, + Uuid('bec5727e-9992-4f3b-85be-6712df617b9d'), { author: 'Josiah Carberry', preprint: { diff --git a/src/types/uuid.ts b/src/types/uuid.ts index 841d7cda6..d0877acda 100644 --- a/src/types/uuid.ts +++ b/src/types/uuid.ts @@ -7,7 +7,7 @@ import * as D from 'io-ts/lib/Decoder.js' import { type Uuid, isUuid, v4 } from 'uuid-ts' import * as FptsToEffect from '../FptsToEffect.js' -export type { Uuid } from 'uuid-ts' +export { Uuid } from 'uuid-ts' export class GenerateUuid extends Context.Tag('GenerateUuid')>() {} diff --git a/test/Comments/Queries.test.ts b/test/Comments/Queries.test.ts index 56d97c18b..107fccd19 100644 --- a/test/Comments/Queries.test.ts +++ b/test/Comments/Queries.test.ts @@ -6,13 +6,13 @@ import { Orcid } from 'orcid-id-ts' import * as _ from '../../src/Comments/Queries.js' import * as Comments from '../../src/Comments/index.js' import { html } from '../../src/html.js' -import type { Uuid } from '../../src/types/index.js' +import { Uuid } from '../../src/types/index.js' import * as fc from '../fc.js' describe('GetNextExpectedCommandForUser', () => { const authorId = Orcid('0000-0002-1825-0097') const prereviewId = 123 - const resourceId = '358f7fc0-9725-4192-8673-d7c64f398401' as Uuid.Uuid + const resourceId = Uuid.Uuid('358f7fc0-9725-4192-8673-d7c64f398401') const commentWasStarted = new Comments.CommentWasStarted({ authorId, prereviewId }) const commentWasEntered = new Comments.CommentWasEntered({ comment: html`Some comment` }) const personaWasChosen = new Comments.PersonaWasChosen({ persona: 'public' }) @@ -172,7 +172,7 @@ describe('GetNextExpectedCommandForUser', () => { describe('GetNextExpectedCommandForUserOnAComment', () => { const authorId = Orcid('0000-0002-1825-0097') const prereviewId = 123 - const resourceId = '358f7fc0-9725-4192-8673-d7c64f398401' as Uuid.Uuid + const resourceId = Uuid.Uuid('358f7fc0-9725-4192-8673-d7c64f398401') const commentWasStarted = new Comments.CommentWasStarted({ authorId, prereviewId }) const commentWasEntered = new Comments.CommentWasEntered({ comment: html`Some comment` }) const personaWasChosen = new Comments.PersonaWasChosen({ persona: 'public' }) @@ -313,7 +313,7 @@ describe('GetNextExpectedCommandForUserOnAComment', () => { describe('GetACommentInNeedOfADoi', () => { const authorId = Orcid('0000-0002-1825-0097') const prereviewId = 123 - const resourceId = '358f7fc0-9725-4192-8673-d7c64f398401' as Uuid.Uuid + const resourceId = Uuid.Uuid('358f7fc0-9725-4192-8673-d7c64f398401') const commentWasStarted = new Comments.CommentWasStarted({ authorId, prereviewId }) const commentWasEntered = new Comments.CommentWasEntered({ comment: html`Some comment` }) const personaWasChosen = new Comments.PersonaWasChosen({ persona: 'public' }) diff --git a/test/fc.ts b/test/fc.ts index 77ea57f1b..5c4b3f18b 100644 --- a/test/fc.ts +++ b/test/fc.ts @@ -23,7 +23,7 @@ import { createResponse, } from 'node-mocks-http' import { type Orcid, isOrcid } from 'orcid-id-ts' -import { type Uuid, isUuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import type { AssignedAuthorInvite, AuthorInvite, @@ -223,7 +223,7 @@ export const partialRecord = => fc.uuid().filter(isUuid) +export const uuid = (): fc.Arbitrary => fc.uuid().map(Uuid) export const locale = (): fc.Arbitrary => constantFrom( diff --git a/visual-regression/WriteCommentFlow/CheckPage/CheckPage.spec.ts b/visual-regression/WriteCommentFlow/CheckPage/CheckPage.spec.ts index 545d24c0a..e605b085c 100644 --- a/visual-regression/WriteCommentFlow/CheckPage/CheckPage.spec.ts +++ b/visual-regression/WriteCommentFlow/CheckPage/CheckPage.spec.ts @@ -2,7 +2,7 @@ import { Option } from 'effect' import { Orcid } from 'orcid-id-ts' import { html } from '../../../src/html.js' import { DefaultLocale } from '../../../src/locales/index.js' -import type { NonEmptyString, Uuid } from '../../../src/types/index.js' +import { type NonEmptyString, Uuid } from '../../../src/types/index.js' import type { Pseudonym } from '../../../src/types/pseudonym.js' import type { User } from '../../../src/user.js' import * as _ from '../../../src/WriteCommentFlow/CheckPage/CheckPage.js' @@ -12,7 +12,7 @@ test('content looks right', async ({ showPage }) => { const response = _.CheckPage({ competingInterests: Option.none(), comment, - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), locale: DefaultLocale, persona: 'public', user, @@ -27,7 +27,7 @@ test('content looks right using a pseudonym', async ({ showPage }) => { const response = _.CheckPage({ competingInterests: Option.none(), comment, - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), locale: DefaultLocale, persona: 'pseudonym', user, @@ -44,7 +44,7 @@ test('content looks right with competing interests', async ({ showPage }) => { 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' as NonEmptyString.NonEmptyString, ), comment, - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), locale: DefaultLocale, persona: 'public', user, diff --git a/visual-regression/WriteCommentFlow/ChoosePersonaPage/ChoosePersonaPage.spec.ts b/visual-regression/WriteCommentFlow/ChoosePersonaPage/ChoosePersonaPage.spec.ts index e10dd7b80..69627b682 100644 --- a/visual-regression/WriteCommentFlow/ChoosePersonaPage/ChoosePersonaPage.spec.ts +++ b/visual-regression/WriteCommentFlow/ChoosePersonaPage/ChoosePersonaPage.spec.ts @@ -1,7 +1,7 @@ import { Either } from 'effect' import { Orcid } from 'orcid-id-ts' import { DefaultLocale } from '../../../src/locales/index.js' -import type { Uuid } from '../../../src/types/index.js' +import { Uuid } from '../../../src/types/index.js' import type { Pseudonym } from '../../../src/types/pseudonym.js' import type { User } from '../../../src/user.js' import * as ChoosePersonaForm from '../../../src/WriteCommentFlow/ChoosePersonaPage/ChoosePersonaForm.js' @@ -10,7 +10,7 @@ import { expect, test } from '../../base.js' test('content looks right', async ({ showPage }) => { const response = _.ChoosePersonaPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new ChoosePersonaForm.EmptyForm(), locale: DefaultLocale, user, @@ -23,7 +23,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when there is a persona', async ({ showPage }) => { const response = _.ChoosePersonaPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new ChoosePersonaForm.CompletedForm({ persona: 'public' }), locale: DefaultLocale, user, @@ -36,7 +36,7 @@ test('content looks right when there is a persona', async ({ showPage }) => { test('content looks right when the persona is missing', async ({ showPage }) => { const response = _.ChoosePersonaPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new ChoosePersonaForm.InvalidForm({ persona: Either.left(new ChoosePersonaForm.Missing()) }), locale: DefaultLocale, user, diff --git a/visual-regression/WriteCommentFlow/CodeOfConductPage/CodeOfConductPage.spec.ts b/visual-regression/WriteCommentFlow/CodeOfConductPage/CodeOfConductPage.spec.ts index c6f3b6895..6c41b3e21 100644 --- a/visual-regression/WriteCommentFlow/CodeOfConductPage/CodeOfConductPage.spec.ts +++ b/visual-regression/WriteCommentFlow/CodeOfConductPage/CodeOfConductPage.spec.ts @@ -1,13 +1,13 @@ import { Either } from 'effect' import { DefaultLocale } from '../../../src/locales/index.js' -import type { Uuid } from '../../../src/types/index.js' +import { Uuid } from '../../../src/types/index.js' import * as CodeOfConductForm from '../../../src/WriteCommentFlow/CodeOfConductPage/CodeOfConductForm.js' import * as _ from '../../../src/WriteCommentFlow/CodeOfConductPage/CodeOfConductPage.js' import { expect, test } from '../../base.js' test('content looks right', async ({ showPage }) => { const response = _.CodeOfConductPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new CodeOfConductForm.EmptyForm(), locale: DefaultLocale, }) @@ -19,7 +19,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when the agreement is missing', async ({ showPage }) => { const response = _.CodeOfConductPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new CodeOfConductForm.InvalidForm({ agree: Either.left(new CodeOfConductForm.Missing()) }), locale: DefaultLocale, }) diff --git a/visual-regression/WriteCommentFlow/CompetingInterestsPage/CompetingInterestsPage.spec.ts b/visual-regression/WriteCommentFlow/CompetingInterestsPage/CompetingInterestsPage.spec.ts index 2f6463465..4583cddab 100644 --- a/visual-regression/WriteCommentFlow/CompetingInterestsPage/CompetingInterestsPage.spec.ts +++ b/visual-regression/WriteCommentFlow/CompetingInterestsPage/CompetingInterestsPage.spec.ts @@ -1,13 +1,13 @@ import { Either } from 'effect' import { DefaultLocale } from '../../../src/locales/index.js' -import type { NonEmptyString, Uuid } from '../../../src/types/index.js' +import { type NonEmptyString, Uuid } from '../../../src/types/index.js' import * as CompetingInterestsForm from '../../../src/WriteCommentFlow/CompetingInterestsPage/CompetingInterestsForm.js' import * as _ from '../../../src/WriteCommentFlow/CompetingInterestsPage/CompetingInterestsPage.js' import { expect, test } from '../../base.js' test('content looks right', async ({ showPage }) => { const response = _.CompetingInterestsPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new CompetingInterestsForm.EmptyForm(), locale: DefaultLocale, }) @@ -19,7 +19,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when there are details', async ({ showPage }) => { const response = _.CompetingInterestsPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new CompetingInterestsForm.CompletedFormYes({ competingInterests: 'yes', competingInterestsDetails: @@ -35,7 +35,7 @@ test('content looks right when there are details', async ({ showPage }) => { test('content looks right when missing', async ({ showPage }) => { const response = _.CompetingInterestsPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new CompetingInterestsForm.InvalidForm({ competingInterests: Either.left(new CompetingInterestsForm.Missing()), competingInterestsDetails: Either.right(''), @@ -50,7 +50,7 @@ test('content looks right when missing', async ({ showPage }) => { test('content looks right when details are missing', async ({ showPage }) => { const response = _.CompetingInterestsPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new CompetingInterestsForm.InvalidForm({ competingInterests: Either.right('yes'), competingInterestsDetails: Either.left(new CompetingInterestsForm.Missing()), diff --git a/visual-regression/WriteCommentFlow/EnterCommentPage/EnterCommentPage.spec.ts b/visual-regression/WriteCommentFlow/EnterCommentPage/EnterCommentPage.spec.ts index 63d67bfe7..0b912eec7 100644 --- a/visual-regression/WriteCommentFlow/EnterCommentPage/EnterCommentPage.spec.ts +++ b/visual-regression/WriteCommentFlow/EnterCommentPage/EnterCommentPage.spec.ts @@ -1,14 +1,14 @@ import { Either } from 'effect' import { html } from '../../../src/html.js' import { DefaultLocale } from '../../../src/locales/index.js' -import type { Uuid } from '../../../src/types/index.js' +import { Uuid } from '../../../src/types/index.js' import * as EnterCommentForm from '../../../src/WriteCommentFlow/EnterCommentPage/EnterCommentForm.js' import * as _ from '../../../src/WriteCommentFlow/EnterCommentPage/EnterCommentPage.js' import { expect, test } from '../../base.js' test('content looks right', async ({ showPage }) => { const response = _.EnterCommentPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new EnterCommentForm.EmptyForm(), locale: DefaultLocale, prereviewId: 10779310, @@ -21,7 +21,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when there is a comment', async ({ showPage }) => { const response = _.EnterCommentPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new EnterCommentForm.CompletedForm({ comment }), locale: DefaultLocale, prereviewId: 10779310, @@ -34,7 +34,7 @@ test('content looks right when there is a comment', async ({ showPage }) => { test('content looks right when the comment is missing', async ({ showPage }) => { const response = _.EnterCommentPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new EnterCommentForm.InvalidForm({ comment: Either.left(new EnterCommentForm.Missing()) }), locale: DefaultLocale, prereviewId: 10779310, diff --git a/visual-regression/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.spec.ts b/visual-regression/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.spec.ts index 197ae1145..9e62e6cc9 100644 --- a/visual-regression/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.spec.ts +++ b/visual-regression/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.spec.ts @@ -1,13 +1,13 @@ import { Either } from 'effect' import { DefaultLocale } from '../../../src/locales/index.js' -import { EmailAddress, type Uuid } from '../../../src/types/index.js' +import { EmailAddress, Uuid } from '../../../src/types/index.js' import * as EnterEmailAddressForm from '../../../src/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressForm.js' import * as _ from '../../../src/WriteCommentFlow/EnterEmailAddressPage/EnterEmailAddressPage.js' import { expect, test } from '../../base.js' test('content looks right', async ({ showPage }) => { const response = _.EnterEmailAddressPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new EnterEmailAddressForm.EmptyForm(), locale: DefaultLocale, }) @@ -19,7 +19,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when there is an email address', async ({ showPage }) => { const response = _.EnterEmailAddressPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new EnterEmailAddressForm.CompletedForm({ emailAddress: EmailAddress.EmailAddress('jcarberry@example.com'), }), @@ -33,7 +33,7 @@ test('content looks right when there is an email address', async ({ showPage }) test('content looks right when the email address is missing', async ({ showPage }) => { const response = _.EnterEmailAddressPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new EnterEmailAddressForm.InvalidForm({ emailAddress: Either.left(new EnterEmailAddressForm.Missing()) }), locale: DefaultLocale, }) @@ -45,7 +45,7 @@ test('content looks right when the email address is missing', async ({ showPage test('content looks right when the email address is invalid', async ({ showPage }) => { const response = _.EnterEmailAddressPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), form: new EnterEmailAddressForm.InvalidForm({ emailAddress: Either.left(new EnterEmailAddressForm.Invalid({ value: 'not an email address' })), }), diff --git a/visual-regression/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.spec.ts b/visual-regression/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.spec.ts index dfa4f6679..f08cc362c 100644 --- a/visual-regression/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.spec.ts +++ b/visual-regression/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.spec.ts @@ -1,11 +1,11 @@ import { DefaultLocale } from '../../../src/locales/index.js' -import { EmailAddress, type Uuid } from '../../../src/types/index.js' +import { EmailAddress, Uuid } from '../../../src/types/index.js' import * as _ from '../../../src/WriteCommentFlow/NeedToVerifyEmailAddressPage/NeedToVerifyEmailAddressPage.js' import { expect, test } from '../../base.js' test('content looks right', async ({ showPage }) => { const response = _.NeedToVerifyEmailAddressPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), emailAddress: EmailAddress.EmailAddress('jcarberry@example.com'), locale: DefaultLocale, }) diff --git a/visual-regression/WriteCommentFlow/PublishedPage/PublishedPage.spec.ts b/visual-regression/WriteCommentFlow/PublishedPage/PublishedPage.spec.ts index a89601ed8..866545792 100644 --- a/visual-regression/WriteCommentFlow/PublishedPage/PublishedPage.spec.ts +++ b/visual-regression/WriteCommentFlow/PublishedPage/PublishedPage.spec.ts @@ -1,13 +1,13 @@ import * as Doi from 'doi-ts' import { DefaultLocale } from '../../../src/locales/index.js' -import type { Uuid } from '../../../src/types/index.js' +import { Uuid } from '../../../src/types/index.js' import * as _ from '../../../src/WriteCommentFlow/PublishedPage/PublishedPage.js' import { expect, test } from '../../base.js' test('content looks right', async ({ showPage }) => { const response = _.PublishedPage({ doi: Doi.Doi('10.5072/zenodo.107286'), - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), locale: DefaultLocale, prereviewId: 10779310, }) diff --git a/visual-regression/WriteCommentFlow/PublishingPage/PublishingPage.spec.ts b/visual-regression/WriteCommentFlow/PublishingPage/PublishingPage.spec.ts index dc6964de5..9ec5b84c2 100644 --- a/visual-regression/WriteCommentFlow/PublishingPage/PublishingPage.spec.ts +++ b/visual-regression/WriteCommentFlow/PublishingPage/PublishingPage.spec.ts @@ -1,11 +1,11 @@ import { DefaultLocale } from '../../../src/locales/index.js' -import type { Uuid } from '../../../src/types/index.js' +import { Uuid } from '../../../src/types/index.js' import * as _ from '../../../src/WriteCommentFlow/PublishingPage/PublishingPage.js' import { expect, test } from '../../base.js' test('content looks right', async ({ showPage }) => { const response = _.PublishingPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), locale: DefaultLocale, }) diff --git a/visual-regression/WriteCommentFlow/StartNow/CarryOnPage.spec.ts b/visual-regression/WriteCommentFlow/StartNow/CarryOnPage.spec.ts index d4aa2d6de..8cd20e4f4 100644 --- a/visual-regression/WriteCommentFlow/StartNow/CarryOnPage.spec.ts +++ b/visual-regression/WriteCommentFlow/StartNow/CarryOnPage.spec.ts @@ -5,7 +5,7 @@ import { html } from '../../../src/html.js' import { DefaultLocale } from '../../../src/locales/index.js' import * as Prereview from '../../../src/Prereview.js' import * as Routes from '../../../src/routes.js' -import type { Uuid } from '../../../src/types/index.js' +import { Uuid } from '../../../src/types/index.js' import * as _ from '../../../src/WriteCommentFlow/StartNow/CarryOnPage.js' import { expect, test } from '../../base.js' @@ -13,7 +13,7 @@ import PlainDate = Temporal.PlainDate test('content looks right', async ({ showPage }) => { const response = _.CarryOnPage({ - commentId: '7ad2f67d-dc01-48c5-b6ac-3490d494f67d' as Uuid.Uuid, + commentId: Uuid.Uuid('7ad2f67d-dc01-48c5-b6ac-3490d494f67d'), nextPage: Routes.WriteCommentEnterComment, prereview, locale: DefaultLocale, diff --git a/visual-regression/author-invite-flow/author-invite-check.test.ts b/visual-regression/author-invite-flow/author-invite-check.test.ts index 140ca2292..e4f0e6a0d 100644 --- a/visual-regression/author-invite-flow/author-invite-check.test.ts +++ b/visual-regression/author-invite-flow/author-invite-check.test.ts @@ -1,5 +1,5 @@ import { Orcid } from 'orcid-id-ts' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { checkPage } from '../../src/author-invite-flow/check-page/check-page.js' import { failureMessage } from '../../src/author-invite-flow/check-page/failure-message.js' import { DefaultLocale } from '../../src/locales/index.js' @@ -8,7 +8,7 @@ import { expect, test } from '../base.js' test('content looks right', async ({ showPage }) => { const response = checkPage({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), persona: 'public', user: { name: 'Josiah Carberry', @@ -25,7 +25,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when using a pseudonym', async ({ showPage }) => { const response = checkPage({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), persona: 'pseudonym', user: { name: 'Josiah Carberry', diff --git a/visual-regression/author-invite-flow/author-invite-decline.test.ts b/visual-regression/author-invite-flow/author-invite-decline.test.ts index 9ddf90bcc..08c92b2b2 100644 --- a/visual-regression/author-invite-flow/author-invite-decline.test.ts +++ b/visual-regression/author-invite-flow/author-invite-decline.test.ts @@ -1,7 +1,7 @@ import { Temporal } from '@js-temporal/polyfill' import { Doi } from 'doi-ts' import { Orcid } from 'orcid-id-ts' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { declinePage } from '../../src/author-invite-flow/decline-page/decline-page.js' import { inviteDeclinedPage } from '../../src/author-invite-flow/decline-page/invite-declined-page.js' import { html } from '../../src/html.js' @@ -11,7 +11,7 @@ import PlainDate = Temporal.PlainDate test('content looks right before declining', async ({ showPage }) => { const response = declinePage({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), review: { authors: { named: [ @@ -56,7 +56,7 @@ test('content looks right before declining', async ({ showPage }) => { }) test('content looks right when declined', async ({ showPage }) => { - const response = inviteDeclinedPage('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid) + const response = inviteDeclinedPage(Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0')) const content = await showPage(response) diff --git a/visual-regression/author-invite-flow/author-invite-enter-email-address.test.ts b/visual-regression/author-invite-flow/author-invite-enter-email-address.test.ts index e2990e0dd..91abec9b3 100644 --- a/visual-regression/author-invite-flow/author-invite-enter-email-address.test.ts +++ b/visual-regression/author-invite-flow/author-invite-enter-email-address.test.ts @@ -1,5 +1,5 @@ import * as E from 'fp-ts/lib/Either.js' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { enterEmailAddressForm } from '../../src/author-invite-flow/enter-email-address-page/enter-email-address-form.js' import { invalidE, missingE } from '../../src/form.js' import { EmailAddress } from '../../src/types/email-address.js' @@ -7,7 +7,7 @@ import { expect, test } from '../base.js' test('content looks right', async ({ showPage }) => { const response = enterEmailAddressForm({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), invitedEmailAddress: EmailAddress('jcarberry@example.com'), form: { useInvitedAddress: E.right(undefined), otherEmailAddress: E.right(undefined) }, }) @@ -20,7 +20,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when fields are missing', async ({ showPage }) => { await test.step('choice field', async () => { const response = enterEmailAddressForm({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), invitedEmailAddress: EmailAddress('jcarberry@example.com'), form: { useInvitedAddress: E.left(missingE()), otherEmailAddress: E.right(undefined) }, }) @@ -32,7 +32,7 @@ test('content looks right when fields are missing', async ({ showPage }) => { await test.step('other email address field', async () => { const response = enterEmailAddressForm({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), invitedEmailAddress: EmailAddress('jcarberry@example.com'), form: { useInvitedAddress: E.right('no'), otherEmailAddress: E.left(missingE()) }, }) @@ -45,7 +45,7 @@ test('content looks right when fields are missing', async ({ showPage }) => { test('content looks right when fields are invalid', async ({ showPage }) => { const response = enterEmailAddressForm({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), invitedEmailAddress: EmailAddress('jcarberry@example.com'), form: { useInvitedAddress: E.right('no'), otherEmailAddress: E.left(invalidE('not an email address')) }, }) diff --git a/visual-regression/author-invite-flow/author-invite-need-to-verify-email-address.test.ts b/visual-regression/author-invite-flow/author-invite-need-to-verify-email-address.test.ts index e37e3cad6..15cc34256 100644 --- a/visual-regression/author-invite-flow/author-invite-need-to-verify-email-address.test.ts +++ b/visual-regression/author-invite-flow/author-invite-need-to-verify-email-address.test.ts @@ -1,4 +1,4 @@ -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { needToVerifyEmailAddressPage } from '../../src/author-invite-flow/need-to-verify-email-address-page/need-to-verify-email-address-page.js' import { UnverifiedContactEmailAddress } from '../../src/contact-email-address.js' import { EmailAddress } from '../../src/types/email-address.js' @@ -6,10 +6,10 @@ import { expect, test } from '../base.js' test('content looks right', async ({ showPage }) => { const response = needToVerifyEmailAddressPage({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), contactEmailAddress: new UnverifiedContactEmailAddress({ value: EmailAddress('jcarberry@example.com'), - verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid, + verificationToken: Uuid('2a29e36c-da26-438d-9a67-577101fa8968'), }), }) diff --git a/visual-regression/author-invite-flow/author-invite-persona.test.ts b/visual-regression/author-invite-flow/author-invite-persona.test.ts index 935a8c6e3..03bf90840 100644 --- a/visual-regression/author-invite-flow/author-invite-persona.test.ts +++ b/visual-regression/author-invite-flow/author-invite-persona.test.ts @@ -1,6 +1,6 @@ import * as E from 'fp-ts/lib/Either.js' import { Orcid } from 'orcid-id-ts' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { personaForm } from '../../src/author-invite-flow/persona-page/persona-form.js' import { missingE } from '../../src/form.js' import type { Pseudonym } from '../../src/types/pseudonym.js' @@ -8,7 +8,7 @@ import { expect, test } from '../base.js' test('content looks right', async ({ showPage }) => { const response = personaForm({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), form: { persona: E.right(undefined) }, user: { name: 'Josiah Carberry', @@ -24,7 +24,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when fields are missing', async ({ showPage }) => { const response = personaForm({ - inviteId: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + inviteId: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), form: { persona: E.left(missingE()) }, user: { name: 'Josiah Carberry', diff --git a/visual-regression/author-invite-flow/author-invite-published.test.ts b/visual-regression/author-invite-flow/author-invite-published.test.ts index 136a6c533..3ef978404 100644 --- a/visual-regression/author-invite-flow/author-invite-published.test.ts +++ b/visual-regression/author-invite-flow/author-invite-published.test.ts @@ -1,7 +1,7 @@ import { Doi } from 'doi-ts' import * as TE from 'fp-ts/lib/TaskEither.js' import { Orcid } from 'orcid-id-ts' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { authorInvitePublished } from '../../src/author-invite-flow/index.js' import { html } from '../../src/html.js' import type { Pseudonym } from '../../src/types/pseudonym.js' @@ -9,7 +9,7 @@ import { expect, test } from '../base.js' test('content looks right', async ({ showPage }) => { const response = await authorInvitePublished({ - id: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + id: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), user: { name: 'Josiah Carberry', orcid: Orcid('0000-0002-1825-0097'), diff --git a/visual-regression/author-invite-flow/author-invite-start.test.ts b/visual-regression/author-invite-flow/author-invite-start.test.ts index d040f7c55..8294c7ae6 100644 --- a/visual-regression/author-invite-flow/author-invite-start.test.ts +++ b/visual-regression/author-invite-flow/author-invite-start.test.ts @@ -1,6 +1,6 @@ import * as TE from 'fp-ts/lib/TaskEither.js' import { Orcid } from 'orcid-id-ts' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { authorInviteStart } from '../../src/author-invite-flow/index.js' import { html } from '../../src/html.js' import { EmailAddress } from '../../src/types/email-address.js' @@ -9,7 +9,7 @@ import { expect, test } from '../base.js' test('content looks right when already started', async ({ showPage }) => { const response = await authorInviteStart({ - id: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + id: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), user: { name: 'Josiah Carberry', orcid: Orcid('0000-0002-1825-0097'), diff --git a/visual-regression/author-invite-flow/author-invite.test.ts b/visual-regression/author-invite-flow/author-invite.test.ts index 42008ca41..14b84f437 100644 --- a/visual-regression/author-invite-flow/author-invite.test.ts +++ b/visual-regression/author-invite-flow/author-invite.test.ts @@ -2,7 +2,7 @@ import { Temporal } from '@js-temporal/polyfill' import { Doi } from 'doi-ts' import * as TE from 'fp-ts/lib/TaskEither.js' import { Orcid } from 'orcid-id-ts' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { authorInvite } from '../../src/author-invite-flow/index.js' import { html } from '../../src/html.js' import { EmailAddress } from '../../src/types/email-address.js' @@ -12,7 +12,7 @@ import { expect, test } from '../base.js' import PlainDate = Temporal.PlainDate test('content looks right', async ({ showPage }) => { - const response = await authorInvite({ id: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid })({ + const response = await authorInvite({ id: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0') })({ getAuthorInvite: () => TE.right({ status: 'open', emailAddress: EmailAddress('jcarberry@example.com'), review: 1234 }), getPrereview: () => @@ -65,7 +65,7 @@ test('content looks right', async ({ showPage }) => { test('content looks right when logged in', async ({ showPage }) => { const response = await authorInvite({ - id: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + id: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), user: { name: 'Josiah Carberry', orcid: Orcid('0000-0002-1825-0097'), diff --git a/visual-regression/email.spec.ts b/visual-regression/email.spec.ts index 8b16762da..1b1008a5f 100644 --- a/visual-regression/email.spec.ts +++ b/visual-regression/email.spec.ts @@ -1,6 +1,6 @@ import { Doi } from 'doi-ts' import { Orcid } from 'orcid-id-ts' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { UnverifiedContactEmailAddress } from '../src/contact-email-address.js' import { createAuthorInviteEmail, @@ -23,9 +23,9 @@ test('email-verification HTML for an invited author looks right', async ({ page }, emailAddress: new UnverifiedContactEmailAddress({ value: EmailAddress('jcarberry@example.com'), - verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid, + verificationToken: Uuid('2a29e36c-da26-438d-9a67-577101fa8968'), }), - authorInvite: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + authorInvite: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), })({ publicUrl: new URL('http://example.com'), locale: DefaultLocale }) await page.setContent(email.html.toString()) @@ -42,9 +42,9 @@ test('email-verification text for an invited author looks right', async ({ page }, emailAddress: new UnverifiedContactEmailAddress({ value: EmailAddress('jcarberry@example.com'), - verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid, + verificationToken: Uuid('2a29e36c-da26-438d-9a67-577101fa8968'), }), - authorInvite: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + authorInvite: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), })({ publicUrl: new URL('http://example.com'), locale: DefaultLocale }) await page.setContent(`
${email.text}
`) @@ -61,9 +61,9 @@ test('email-verification HTML for a comment looks right', async ({ page }) => { }, emailAddress: new UnverifiedContactEmailAddress({ value: EmailAddress('jcarberry@example.com'), - verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid, + verificationToken: Uuid('2a29e36c-da26-438d-9a67-577101fa8968'), }), - comment: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + comment: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), locale: DefaultLocale, })({ publicUrl: new URL('http://example.com') }) @@ -81,9 +81,9 @@ test('email-verification text for a comment looks right', async ({ page }) => { }, emailAddress: new UnverifiedContactEmailAddress({ value: EmailAddress('jcarberry@example.com'), - verificationToken: '2a29e36c-da26-438d-9a67-577101fa8968' as Uuid, + verificationToken: Uuid('2a29e36c-da26-438d-9a67-577101fa8968'), }), - comment: 'ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0' as Uuid, + comment: Uuid('ee9dd955-7b3b-4ad2-8a61-25dd42cb70f0'), locale: DefaultLocale, })({ publicUrl: new URL('http://example.com') }) @@ -98,7 +98,7 @@ test('author-invite HTML looks right', async ({ page }) => { name: 'Josiah Carberry' as NonEmptyString, emailAddress: EmailAddress('jcarberry@example.com'), }, - 'cda07004-01ec-4d48-8ff0-87bb32c6e81d' as Uuid, + Uuid('cda07004-01ec-4d48-8ff0-87bb32c6e81d'), { author: 'Jean-Baptiste Botul', preprint: { @@ -123,7 +123,7 @@ test('author-invite text looks right', async ({ page }) => { name: 'Josiah Carberry' as NonEmptyString, emailAddress: EmailAddress('jcarberry@example.com'), }, - 'cda07004-01ec-4d48-8ff0-87bb32c6e81d' as Uuid, + Uuid('cda07004-01ec-4d48-8ff0-87bb32c6e81d'), { author: 'Jean-Baptiste Botul', preprint: { diff --git a/visual-regression/my-details/my-details-page.spec.ts b/visual-regression/my-details/my-details-page.spec.ts index f755fc5ee..d21fcdabf 100644 --- a/visual-regression/my-details/my-details-page.spec.ts +++ b/visual-regression/my-details/my-details-page.spec.ts @@ -1,6 +1,6 @@ import * as O from 'fp-ts/lib/Option.js' import { Orcid } from 'orcid-id-ts' -import type { Uuid } from 'uuid-ts' +import { Uuid } from 'uuid-ts' import { UnverifiedContactEmailAddress, VerifiedContactEmailAddress } from '../../src/contact-email-address.js' import { createPage } from '../../src/my-details-page/my-details-page.js' import { EmailAddress } from '../../src/types/email-address.js' @@ -61,7 +61,7 @@ test('content looks right when restricted visible', async ({ showPage }) => { contactEmailAddress: O.some( new UnverifiedContactEmailAddress({ value: EmailAddress('some-email@example.com'), - verificationToken: '9492b53b-ac19-4a6d-966c-5d2f27e80b83' as Uuid, + verificationToken: Uuid('9492b53b-ac19-4a6d-966c-5d2f27e80b83'), }), ), openForRequests: O.some({ value: false, visibility: 'restricted' }),