-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e1f90e
commit 0e161f2
Showing
12 changed files
with
101 additions
and
1 deletion.
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
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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import { workflowUpdateEnabled } from './workflow-update-enabled'; | ||
|
||
describe('workflowUpdateEnabled', () => { | ||
const coreUser = { | ||
namespaceWriteDisabled: (ns: string) => ns === 'ns-write-disabled', | ||
}; | ||
|
||
test('returns true when global write actions, signal, and namespace write actions are all enabled', () => { | ||
expect( | ||
workflowUpdateEnabled( | ||
{ | ||
disableWriteActions: false, | ||
}, | ||
coreUser, | ||
'ns-write-enabled', | ||
), | ||
).toBe(true); | ||
}); | ||
|
||
describe('returns false', () => { | ||
test('when write actions are disabled', () => { | ||
expect( | ||
workflowUpdateEnabled( | ||
{ | ||
disableWriteActions: true, | ||
workflowUpdateDisabled: false, | ||
}, | ||
coreUser, | ||
'ns-write-enabled', | ||
), | ||
).toBe(false); | ||
}); | ||
|
||
test('when update is disabled', () => { | ||
expect( | ||
workflowUpdateEnabled( | ||
{ | ||
disableWriteActions: false, | ||
workflowUpdateDisabled: true, | ||
}, | ||
coreUser, | ||
'ns-write-enabled', | ||
), | ||
).toBe(false); | ||
}); | ||
|
||
test('when write actions and update are both disabled', () => { | ||
expect( | ||
workflowUpdateEnabled( | ||
{ | ||
disableWriteActions: true, | ||
workflowUpdateDisabled: true, | ||
}, | ||
coreUser, | ||
'ns-write-enabled', | ||
), | ||
).toBe(false); | ||
}); | ||
|
||
test('when namespace write actions are disabled', () => { | ||
expect( | ||
workflowUpdateEnabled( | ||
{ | ||
disableWriteActions: false, | ||
workflowUpdateDisabled: false, | ||
}, | ||
coreUser, | ||
'ns-write-disabled', | ||
), | ||
).toBe(false); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { CoreUser } from '$lib/models/core-user'; | ||
import type { Settings } from '$lib/types/global'; | ||
|
||
export const workflowUpdateEnabled = ( | ||
settings: Settings, | ||
coreUser: CoreUser, | ||
namespace: string, | ||
): boolean => { | ||
return ( | ||
!settings.disableWriteActions && | ||
!settings.workflowUpdateDisabled && | ||
!coreUser.namespaceWriteDisabled(namespace) | ||
); | ||
}; |