-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(editor): Unit test Version control frontend components (#6408)
* test(editor): test n8n-select design system component * test(editor): test version control settings happy path * test(editor): test version control settings disconnect
- Loading branch information
Showing
8 changed files
with
277 additions
and
30 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
77 changes: 77 additions & 0 deletions
77
packages/editor-ui/src/__tests__/server/endpoints/versionControl.ts
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,77 @@ | ||
import type { Server, Request } from 'miragejs'; | ||
import { Response } from 'miragejs'; | ||
import { jsonParse } from 'n8n-workflow'; | ||
import type { AppSchema } from '@/__tests__/server/types'; | ||
import type { VersionControlPreferences } from '@/Interface'; | ||
|
||
export function routesForVersionControl(server: Server) { | ||
const versionControlApiRoot = '/rest/version-control'; | ||
const defaultVersionControlPreferences: VersionControlPreferences = { | ||
branchName: '', | ||
branches: [], | ||
authorName: '', | ||
authorEmail: '', | ||
repositoryUrl: '', | ||
branchReadOnly: false, | ||
branchColor: '#1d6acb', | ||
connected: false, | ||
publicKey: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHEX+25m', | ||
}; | ||
|
||
server.post(`${versionControlApiRoot}/preferences`, (schema: AppSchema, request: Request) => { | ||
const requestBody = jsonParse(request.requestBody) as Partial<VersionControlPreferences>; | ||
|
||
return new Response( | ||
200, | ||
{}, | ||
{ | ||
data: { | ||
...defaultVersionControlPreferences, | ||
...requestBody, | ||
}, | ||
}, | ||
); | ||
}); | ||
|
||
server.patch(`${versionControlApiRoot}/preferences`, (schema: AppSchema, request: Request) => { | ||
const requestBody = jsonParse(request.requestBody) as Partial<VersionControlPreferences>; | ||
|
||
return new Response( | ||
200, | ||
{}, | ||
{ | ||
data: { | ||
...defaultVersionControlPreferences, | ||
...requestBody, | ||
}, | ||
}, | ||
); | ||
}); | ||
|
||
server.get(`${versionControlApiRoot}/get-branches`, () => { | ||
return new Response( | ||
200, | ||
{}, | ||
{ | ||
data: { | ||
branches: ['main', 'dev'], | ||
currentBranch: 'main', | ||
}, | ||
}, | ||
); | ||
}); | ||
|
||
server.post(`${versionControlApiRoot}/disconnect`, () => { | ||
return new Response( | ||
200, | ||
{}, | ||
{ | ||
data: { | ||
...defaultVersionControlPreferences, | ||
branchName: '', | ||
connected: 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
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
Oops, something went wrong.