-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add state editing in-context (#3286)
- Loading branch information
Showing
29 changed files
with
1,407 additions
and
297 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { components } from '../../../packages/web/src/ui/client/apiSchema.generated'; | ||
import { getDevUi } from './devUiTools'; | ||
import { openUI, visitWithApiKey } from './nextInternalCommon'; | ||
import testLanguages from './testLanguages'; | ||
|
||
export type ApiKeyPermissionsModel = | ||
components['schemas']['ApiKeyPermissionsModel']; | ||
export type ComplexEditKeyDto = components['schemas']['ComplexEditKeyDto']; | ||
|
||
type Props = { | ||
permissions: ApiKeyPermissionsModel; | ||
inForm: () => void; | ||
checkRequest?: (data: ComplexEditKeyDto) => void; | ||
}; | ||
|
||
export const simulateReqAndResponse = ({ | ||
permissions, | ||
inForm, | ||
checkRequest, | ||
}: Props) => { | ||
const randomId = String(Math.random()); | ||
// simulating restricted languages in api key info (english only) | ||
cy.intercept( | ||
{ path: '/v2/api-keys/current-permissions', method: 'get' }, | ||
(req) => { | ||
req.reply(permissions); | ||
} | ||
); | ||
cy.intercept({ path: '/v2/projects/*/languages**', method: 'get' }, (req) => { | ||
req.reply(testLanguages); | ||
}); | ||
visitWithApiKey(permissions.scopes as any); | ||
openUI(); | ||
inForm(); | ||
cy.intercept({ path: '/v2/projects/*/keys/**', method: 'put' }, (req) => { | ||
checkRequest?.(req.body); | ||
// response is not checked by the client | ||
req.reply({}); | ||
}).as(randomId); | ||
|
||
getDevUi().contains('Update').click(); | ||
return cy.wait(`@${randomId}`); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ApiKeyPermissionsModel } from './simulateReqAndResponse'; | ||
|
||
export const fullPermissions: ApiKeyPermissionsModel = { | ||
projectId: 1, | ||
viewLanguageIds: null, | ||
translateLanguageIds: null, | ||
stateChangeLanguageIds: null, | ||
scopes: [ | ||
'keys.create', | ||
'keys.edit', | ||
'translations.view', | ||
'translations.edit', | ||
'translations.state-edit', | ||
'screenshots.view', | ||
'screenshots.delete', | ||
'screenshots.upload', | ||
], | ||
}; | ||
|
||
export const translateEnglish: ApiKeyPermissionsModel = { | ||
projectId: 1, | ||
viewLanguageIds: null, | ||
translateLanguageIds: [1000000001], | ||
stateChangeLanguageIds: null, | ||
scopes: ['translations.view', 'translations.edit', 'screenshots.view'], | ||
}; | ||
|
||
export const changeStateEnglish: ApiKeyPermissionsModel = { | ||
projectId: 1, | ||
viewLanguageIds: null, | ||
translateLanguageIds: null, | ||
stateChangeLanguageIds: [1000000001], | ||
scopes: ['translations.view', 'screenshots.view', 'translations.state-edit'], | ||
}; |
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
Oops, something went wrong.