generated from helsingborg-stad/gdi-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/helsingborg-stad/haffa-backend…
… into dev
- Loading branch information
Showing
10 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,4 +165,69 @@ describe('returnAdvert', () => { | |
expect(result.status).toMatchObject(TxErrors.Unauthorized) | ||
} | ||
)) | ||
it('should set unpicked on return', () => { | ||
const advertWasReturned = jest.fn(async () => undefined) | ||
const advertWasReturnedOwner = jest.fn(async () => undefined) | ||
const notifications = createTestNotificationServices({ | ||
advertWasReturned, | ||
advertWasReturnedOwner, | ||
}) | ||
const workflow = { | ||
get pickOnCollect() { | ||
return true | ||
}, | ||
get unpickOnReturn() { | ||
return true | ||
}, | ||
} | ||
const spy = jest.spyOn(workflow, 'unpickOnReturn', 'get') | ||
|
||
return end2endTest( | ||
{ services: { notifications, workflow } }, | ||
async ({ mappedGqlRequest, adverts, user, loginPolicies }) => { | ||
// give us rights to collect | ||
await loginPolicies.updateLoginPolicies([ | ||
{ | ||
emailPattern: user.id, | ||
roles: ['canManageReturns'], | ||
}, | ||
]) | ||
|
||
// eslint-disable-next-line no-param-reassign | ||
adverts['advert-123'] = { | ||
...createEmptyAdvert(), | ||
id: 'advert-123', | ||
createdBy: '[email protected]', | ||
pickedAt: '2025-01-01T00:00:00:000Z', | ||
quantity: 5, | ||
claims: [ | ||
{ | ||
type: AdvertClaimType.collected, | ||
by: '[email protected]', | ||
quantity: 1, | ||
at: new Date().toISOString(), | ||
events: [], | ||
}, | ||
], | ||
} | ||
|
||
const result = await mappedGqlRequest<AdvertMutationResult>( | ||
'returnAdvert', | ||
returnAdvertMutation, | ||
{ | ||
id: 'advert-123', | ||
} | ||
) | ||
expect(result.status).toBeNull() | ||
|
||
T('should be updated in database', () => | ||
expect(adverts['advert-123'].pickedAt).toBe('') | ||
) | ||
|
||
T('should have checked configuration', () => | ||
expect(spy).toHaveBeenCalled() | ||
) | ||
} | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export interface WorkflowService { | ||
pickOnCollect: boolean | ||
unpickOnReturn: boolean | ||
} |