Skip to content

Commit

Permalink
Replace deprecated setting
Browse files Browse the repository at this point in the history
Refs #2289
  • Loading branch information
thewilkybarkid committed Mar 11, 2025
1 parent ca2f262 commit c9d8190
Show file tree
Hide file tree
Showing 40 changed files with 91 additions and 95 deletions.
2 changes: 1 addition & 1 deletion test/WriteCommentFlow/ChoosePersonaPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('ChoosePersonaSubmission', () => {
fc.oneof(
fc.record(
{ persona: fc.string().filter(persona => !['public', 'pseudonym'].includes(persona)) },
{ withDeletedKeys: true },
{ requiredKeys: [] },
),
fc.anything().filter(body => typeof body === 'object' && (body === null || !Object.hasOwn(body, 'persona'))),
),
Expand Down
2 changes: 1 addition & 1 deletion test/WriteCommentFlow/CodeOfConduct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ describe('CodeOfConductSubmission', () => {
.chain(comment => fc.tuple(fc.constant(comment), fc.user({ orcid: fc.constant(comment.authorId) }))),
fc.supportedLocale(),
fc.oneof(
fc.record({ agree: fc.string().filter(string => string !== 'yes') }, { withDeletedKeys: true }),
fc.record({ agree: fc.string().filter(string => string !== 'yes') }, { requiredKeys: [] }),
fc.anything().filter(body => typeof body === 'object' && (body === null || !Object.hasOwn(body, 'agree'))),
),
])("when there isn't agreement", (commentId, [comment, user], locale, body) =>
Expand Down
4 changes: 2 additions & 2 deletions test/WriteCommentFlow/CompetingInterestsPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ describe('CompetingInterestsSubmission', () => {
competingInterests: fc.string().filter(competingInterests => !['no', 'yes'].includes(competingInterests)),
competingInterestsDetails: fc.anything(),
},
{ withDeletedKeys: true },
{ requiredKeys: [] },
),
fc.record(
{ competingInterests: fc.constant('yes'), competingInterestsDetails: fc.constant('') },
{ withDeletedKeys: true },
{ requiredKeys: [] },
),
fc
.anything()
Expand Down
2 changes: 1 addition & 1 deletion test/WriteCommentFlow/EnterCommentPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('EnterCommentSubmission', () => {
.chain(comment => fc.tuple(fc.constant(comment), fc.user({ orcid: fc.constant(comment.authorId) }))),
fc.supportedLocale(),
fc.oneof(
fc.record({ comment: fc.constant('') }, { withDeletedKeys: true }),
fc.record({ comment: fc.constant('') }, { requiredKeys: [] }),
fc.anything().filter(body => typeof body === 'object' && (body === null || !Object.hasOwn(body, 'comment'))),
),
])("when there isn't a comment", (commentId, [comment, user], locale, body) =>
Expand Down
2 changes: 1 addition & 1 deletion test/WriteCommentFlow/EnterEmailAddressPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ describe('EnterEmailAddressSubmission', () => {
.chain(comment => fc.tuple(fc.constant(comment), fc.user({ orcid: fc.constant(comment.authorId) }))),
fc.supportedLocale(),
fc.oneof(
fc.record({ emailAddress: fc.string().filter(string => !string.includes('@')) }, { withDeletedKeys: true }),
fc.record({ emailAddress: fc.string().filter(string => !string.includes('@')) }, { requiredKeys: [] }),
fc
.anything()
.filter(body => typeof body === 'object' && (body === null || !Object.hasOwn(body, 'emailAddress'))),
Expand Down
2 changes: 1 addition & 1 deletion test/connect-slack-page/connect-slack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ describe('connectSlackCode', () => {
fc.string(),
fc.string(),
fc.connection({
headers: fc.record({ Cookie: fc.lorem() }, { withDeletedKeys: true }),
headers: fc.record({ Cookie: fc.lorem() }, { requiredKeys: [] }),
}),
fc.html(),
])(
Expand Down
4 changes: 2 additions & 2 deletions test/fc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const partialRecord = <T, TConstraints extends { requiredKeys: Array<keyo
recordModel: { [K in keyof T]: fc.Arbitrary<T[K]> },
constraints?: TConstraints,
): fc.Arbitrary<
fc.RecordValue<{ [K in keyof T]: T[K] }, TConstraints extends undefined ? { withDeletedKeys: true } : TConstraints>
fc.RecordValue<{ [K in keyof T]: T[K] }, TConstraints extends undefined ? { requiredKeys: [] } : TConstraints>
> =>
fc
.constantFrom(
Expand All @@ -222,7 +222,7 @@ export const partialRecord = <T, TConstraints extends { requiredKeys: Array<keyo
.chain(omit =>
fc.record(
Object.fromEntries(Object.entries(recordModel).filter(([key]) => key !== omit)) as never,
(constraints ?? { withDeletedKeys: true }) as never,
(constraints ?? { requiredKeys: [] }) as never,
),
)

Expand Down
4 changes: 2 additions & 2 deletions test/flash-message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('deleteFlashMessage', () => {
expect(actual).toStrictEqual(E.right([{ type: 'clearCookie', name: 'flash-message', options: { httpOnly: true } }]))
})

test.prop([fc.connection<HeadersOpen>({ headers: fc.record({ Cookie: fc.string() }, { withDeletedKeys: true }) })])(
test.prop([fc.connection<HeadersOpen>({ headers: fc.record({ Cookie: fc.string() }, { requiredKeys: [] }) })])(
"when there isn't a message",
async connection => {
const actual = await runMiddleware(_.deleteFlashMessage, connection)()
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('getFlashMessage', () => {
fc.string().map(message => `flash-message="${encodeURIComponent(message)}"`),
),
},
{ withDeletedKeys: true },
{ requiredKeys: [] },
),
}),
])("when the message can't be decoded", async connection => {
Expand Down
36 changes: 18 additions & 18 deletions test/my-details-page/change-avatar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,25 @@ describe('changeAvatar', () => {
})
})

test.prop([
fc.oneof(fc.anything(), fc.record({ avatar: fc.constant('ERROR') }, { withDeletedKeys: true })),
fc.user(),
])('when the avatar is missing', async (body, user) => {
const actual = await _.changeAvatar({ body, method: 'POST', user })({
saveAvatar: shouldNotBeCalled,
})()
test.prop([fc.oneof(fc.anything(), fc.record({ avatar: fc.constant('ERROR') }, { requiredKeys: [] })), fc.user()])(
'when the avatar is missing',
async (body, user) => {
const actual = await _.changeAvatar({ body, method: 'POST', user })({
saveAvatar: shouldNotBeCalled,
})()

expect(actual).toStrictEqual({
_tag: 'PageResponse',
canonical: format(changeAvatarMatch.formatter, {}),
status: Status.BadRequest,
title: expect.anything(),
nav: expect.anything(),
main: expect.anything(),
skipToLabel: 'form',
js: ['error-summary.js', 'single-use-form.js'],
})
})
expect(actual).toStrictEqual({
_tag: 'PageResponse',
canonical: format(changeAvatarMatch.formatter, {}),
status: Status.BadRequest,
title: expect.anything(),
nav: expect.anything(),
main: expect.anything(),
skipToLabel: 'form',
js: ['error-summary.js', 'single-use-form.js'],
})
},
)

test.prop([fc.anything(), fc.string().filter(method => method !== 'POST'), fc.user()])(
'when the form needs to be submitted',
Expand Down
41 changes: 20 additions & 21 deletions test/my-details-page/change-career-stage-visibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,28 @@ describe('changeCareerStageVisibility', () => {
},
)

test.prop([
fc.record({ careerStageVisibility: fc.string() }, { withDeletedKeys: true }),
fc.user(),
fc.careerStage(),
])('when the form has been submitted without setting visibility', async (body, user, careerStage) => {
const saveCareerStage = jest.fn<_.Env['saveCareerStage']>(_ => TE.right(undefined))
test.prop([fc.record({ careerStageVisibility: fc.string() }, { requiredKeys: [] }), fc.user(), fc.careerStage()])(
'when the form has been submitted without setting visibility',
async (body, user, careerStage) => {
const saveCareerStage = jest.fn<_.Env['saveCareerStage']>(_ => TE.right(undefined))

const actual = await _.changeCareerStageVisibility({ body, method: 'POST', user })({
deleteCareerStage: shouldNotBeCalled,
getCareerStage: () => TE.of(careerStage),
saveCareerStage,
})()
const actual = await _.changeCareerStageVisibility({ body, method: 'POST', user })({
deleteCareerStage: shouldNotBeCalled,
getCareerStage: () => TE.of(careerStage),
saveCareerStage,
})()

expect(actual).toStrictEqual({
_tag: 'RedirectResponse',
status: Status.SeeOther,
location: format(myDetailsMatch.formatter, {}),
})
expect(saveCareerStage).toHaveBeenCalledWith(user.orcid, {
value: careerStage.value,
visibility: 'restricted',
})
})
expect(actual).toStrictEqual({
_tag: 'RedirectResponse',
status: Status.SeeOther,
location: format(myDetailsMatch.formatter, {}),
})
expect(saveCareerStage).toHaveBeenCalledWith(user.orcid, {
value: careerStage.value,
visibility: 'restricted',
})
},
)

test.prop([fc.anything(), fc.string(), fc.user()])("there isn't a career stage", async (body, method, user) => {
const actual = await _.changeCareerStageVisibility({ body, method, user })({
Expand Down
2 changes: 1 addition & 1 deletion test/my-details-page/change-career-stage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('changeCareerStage', () => {
expect(deleteCareerStage).toHaveBeenCalledWith(user.orcid)
})

test.prop([fc.record({ careerStage: fc.lorem() }, { withDeletedKeys: true }), fc.user()])(
test.prop([fc.record({ careerStage: fc.lorem() }, { requiredKeys: [] }), fc.user()])(
'when the form has been submitted without setting career stage',
async (body, user) => {
const actual = await _.changeCareerStage({ body, method: 'POST', user })({
Expand Down
4 changes: 2 additions & 2 deletions test/my-details-page/change-contact-email-address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('changeContactEmailAddress', () => {

describe('when no email address is set', () => {
test.prop([
fc.record({ emailAddress: fc.constant('') }, { withDeletedKeys: true }),
fc.record({ emailAddress: fc.constant('') }, { requiredKeys: [] }),
fc.user(),
fc.contactEmailAddress(),
])('when there was an email address before', async (body, user, existingEmailAddress) => {
Expand All @@ -193,7 +193,7 @@ describe('changeContactEmailAddress', () => {
})
})

test.prop([fc.record({ emailAddress: fc.constant('') }, { withDeletedKeys: true }), fc.user()])(
test.prop([fc.record({ emailAddress: fc.constant('') }, { requiredKeys: [] }), fc.user()])(
"when there wasn't an email address before",
async (body, user) => {
const actual = await _.changeContactEmailAddress({ body, method: 'POST', user })({
Expand Down
2 changes: 1 addition & 1 deletion test/my-details-page/change-languages-visibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('changeLanguagesVisibility', () => {
},
)

test.prop([fc.record({ languagesVisibility: fc.string() }, { withDeletedKeys: true }), fc.user(), fc.languages()])(
test.prop([fc.record({ languagesVisibility: fc.string() }, { requiredKeys: [] }), fc.user(), fc.languages()])(
'when the form has been submitted without setting visibility',
async (body, user, languages) => {
const saveLanguages = jest.fn<_.Env['saveLanguages']>(_ => TE.right(undefined))
Expand Down
2 changes: 1 addition & 1 deletion test/my-details-page/change-languages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('changeLanguages', () => {
})
})

test.prop([fc.record({ languages: fc.constant('') }, { withDeletedKeys: true }), fc.user()])(
test.prop([fc.record({ languages: fc.constant('') }, { requiredKeys: [] }), fc.user()])(
'when the form has been submitted without setting languages',
async (body, user) => {
const deleteLanguages = jest.fn<_.Env['deleteLanguages']>(_ => TE.right(undefined))
Expand Down
2 changes: 1 addition & 1 deletion test/my-details-page/change-location-visibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('changeLocationVisibility', () => {
},
)

test.prop([fc.record({ locationVisibility: fc.string() }, { withDeletedKeys: true }), fc.user(), fc.location()])(
test.prop([fc.record({ locationVisibility: fc.string() }, { requiredKeys: [] }), fc.user(), fc.location()])(
'when the form has been submitted without setting visibility',
async (body, user, location) => {
const saveLocation = jest.fn<_.Env['saveLocation']>(_ => TE.right(undefined))
Expand Down
2 changes: 1 addition & 1 deletion test/my-details-page/change-location.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('changeLocation', () => {
})
})

test.prop([fc.record({ location: fc.constant('') }, { withDeletedKeys: true }), fc.user()])(
test.prop([fc.record({ location: fc.constant('') }, { requiredKeys: [] }), fc.user()])(
'when the form has been submitted without setting a location',
async (body, user) => {
const deleteLocation = jest.fn<_.Env['deleteLocation']>(_ => TE.right(undefined))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('changeOpenForRequestsVisibility', () => {
})

test.prop([
fc.record({ openForRequestsVisibility: fc.string() }, { withDeletedKeys: true }),
fc.record({ openForRequestsVisibility: fc.string() }, { requiredKeys: [] }),
fc.user(),
fc.isOpenForRequestsVisibility(),
])('when the form has been submitted without setting visibility', async (body, user, visibility) => {
Expand Down
2 changes: 1 addition & 1 deletion test/my-details-page/change-open-for-requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('changeOpenForRequests', () => {
},
)

test.prop([fc.record({ openForRequests: fc.lorem() }, { withDeletedKeys: true }), fc.user()])(
test.prop([fc.record({ openForRequests: fc.lorem() }, { requiredKeys: [] }), fc.user()])(
'when the form has been submitted without setting open for requests',
async (body, user) => {
const actual = await _.changeOpenForRequests({ body, method: 'POST', user })({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('changeResearchInterestsVisibility', () => {
})

test.prop([
fc.record({ researchInterestsVisibility: fc.string() }, { withDeletedKeys: true }),
fc.record({ researchInterestsVisibility: fc.string() }, { requiredKeys: [] }),
fc.user(),
fc.researchInterests(),
])('when the form has been submitted without setting visibility', async (body, user, researchInterests) => {
Expand Down
2 changes: 1 addition & 1 deletion test/my-details-page/change-research-interests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('changeResearchInterests', () => {
},
)

test.prop([fc.record({ researchInterests: fc.constant('') }, { withDeletedKeys: true }), fc.user()])(
test.prop([fc.record({ researchInterests: fc.constant('') }, { requiredKeys: [] }), fc.user()])(
'when the form has been submitted without setting research interests',
async (body, user) => {
const deleteResearchInterests = jest.fn<_.Env['deleteResearchInterests']>(_ => TE.right(undefined))
Expand Down
2 changes: 1 addition & 1 deletion test/prereview-coar-notify/fc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const coarReviewActionOfferPayload = (): fc.Arbitrary<CoarReviewActionOff

export const newPrereview = (): fc.Arbitrary<NewPrereview> =>
fc.record({
preprint: fc.record({ doi: fc.doi() }, { withDeletedKeys: true }),
preprint: fc.record({ doi: fc.doi() }, { requiredKeys: [] }),
doi: fc.doi(),
url: fc.url(),
author: fc.record({
Expand Down
2 changes: 1 addition & 1 deletion test/review-a-preprint-page/review-a-preprint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('reviewAPreprint', () => {
})
})

test.prop([fc.record({ preprint: fc.string() }, { withDeletedKeys: true })])('with a non-DOI', async body => {
test.prop([fc.record({ preprint: fc.string() }, { requiredKeys: [] })])('with a non-DOI', async body => {
const actual = await _.reviewAPreprint({ body, method: 'POST' })({ doesPreprintExist: shouldNotBeCalled })()

expect(actual).toStrictEqual({
Expand Down
Loading

0 comments on commit c9d8190

Please sign in to comment.