forked from n8n-io/n8n
-
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.
feat: add support for unit testing using vitest in editor-ui (n8n-io#…
…4184) * feat: add support for unit testing using vitest in editor-ui * fix(editor): update tsconfig types and typeRoots * chore(editor): update package-lock.json
- Loading branch information
1 parent
902e2c4
commit b3c2153
Showing
9 changed files
with
35,218 additions
and
43,225 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
import { parsePermissionsTable } from '@/permissions'; | ||
import { IUser } from "@/Interface"; | ||
|
||
describe('parsePermissionsTable()', () => { | ||
const user: IUser = { | ||
id: "1", | ||
firstName: "John", | ||
lastName: "Doe", | ||
isDefaultUser: false, | ||
isOwner: true, | ||
isPending: false, | ||
isPendingUser: false, | ||
}; | ||
|
||
it('should return permissions object using generic permissions table', () => { | ||
const permissions = parsePermissionsTable(user, []); | ||
|
||
expect(permissions.isInstanceOwner).toBe(true); | ||
}); | ||
|
||
it('should set permission based on permissions table row test function', () => { | ||
const permissions = parsePermissionsTable(user, [ | ||
{ name: 'canRead', test: () => true }, | ||
{ name: 'canUpdate', test: () => false }, | ||
]); | ||
|
||
expect(permissions.canRead).toBe(true); | ||
expect(permissions.canUpdate).toBe(false); | ||
}); | ||
|
||
it('should set permission based on previously computed permission', () => { | ||
const permissions = parsePermissionsTable(user, [ | ||
{ name: 'canRead', test: ['isInstanceOwner'] }, | ||
]); | ||
|
||
expect(permissions.canRead).toBe(true); | ||
}); | ||
|
||
it('should set permission based on multiple previously computed permissions', () => { | ||
const permissions = parsePermissionsTable(user, [ | ||
{ name: 'isResourceOwner', test: ['isInstanceOwner'] }, | ||
{ name: 'canRead', test: ['isInstanceOwner', 'isResourceOwner'] }, | ||
]); | ||
|
||
expect(permissions.canRead).toBe(true); | ||
}); | ||
}); |
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 @@ | ||
import '@testing-library/jest-dom'; |
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