-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVPROD-5994: Implement Token Permission Restrictions section on GitH…
…ub App Settings tab (#258)
- Loading branch information
Showing
25 changed files
with
470 additions
and
60 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
61 changes: 61 additions & 0 deletions
61
apps/spruce/cypress/integration/projectSettings/github_app_settings.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,61 @@ | ||
import { clickSave } from "../../utils"; | ||
import { getAppSettingsRoute, saveButtonEnabled } from "./constants"; | ||
|
||
describe("GitHub app settings", () => { | ||
const destination = getAppSettingsRoute("spruce"); | ||
const selectMenu = "[role='listbox']"; | ||
const permissionGroups = { | ||
all: "All app permissions", | ||
readPRs: "Read Pull Requests", | ||
writeIssues: "Write Issues", | ||
}; | ||
|
||
beforeEach(() => { | ||
cy.visit(destination); | ||
// Wait for page content to finish loading. | ||
cy.contains("Token Permission Restrictions"); | ||
}); | ||
|
||
it("save button should be disabled by default", () => { | ||
saveButtonEnabled(false); | ||
}); | ||
|
||
it("should be able to save different permission groups for requesters, then return to defaults", () => { | ||
cy.dataCy("permission-group-input").should("have.length", 7); | ||
cy.dataCy("permission-group-input").eq(0).as("permission-group-input-0"); | ||
cy.dataCy("permission-group-input").eq(4).as("permission-group-input-4"); | ||
|
||
// Save different permission groups. | ||
cy.get("@permission-group-input-0").click(); | ||
cy.get(selectMenu).within(() => { | ||
cy.contains(permissionGroups.readPRs).click(); | ||
}); | ||
cy.get("@permission-group-input-4").click(); | ||
cy.get(selectMenu).within(() => { | ||
cy.contains(permissionGroups.writeIssues).click(); | ||
}); | ||
cy.dataCy("save-settings-button").scrollIntoView(); | ||
saveButtonEnabled(true); | ||
clickSave(); | ||
cy.validateToast("success", "Successfully updated project"); | ||
|
||
// Changes should persist on the page. | ||
cy.reload(); | ||
cy.get("@permission-group-input-0").contains(permissionGroups.readPRs); | ||
cy.get("@permission-group-input-4").contains(permissionGroups.writeIssues); | ||
|
||
// Return to and save defaults. | ||
cy.get("@permission-group-input-0").click(); | ||
cy.get(selectMenu).within(() => { | ||
cy.contains(permissionGroups.all).click(); | ||
}); | ||
cy.get("@permission-group-input-4").click(); | ||
cy.get(selectMenu).within(() => { | ||
cy.contains(permissionGroups.all).click(); | ||
}); | ||
cy.dataCy("save-settings-button").scrollIntoView(); | ||
saveButtonEnabled(true); | ||
clickSave(); | ||
cy.validateToast("success", "Successfully updated project"); | ||
}); | ||
}); |
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,6 +1,2 @@ | ||
export const commitQueueAlias = "__commit_queue"; | ||
export const commitQueueRequester = "merge_test"; | ||
export const githubMergeRequester = "github_merge_request"; | ||
export const githubPRRequester = "github_pull_request"; | ||
export const patchRequester = "patch_request"; | ||
export const unlinkedPRUsers = new Set(["github_pull_request", "parent_patch"]); |
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,38 @@ | ||
import { PartialRecord } from "types/utils"; | ||
|
||
// Not included in Requester enum because it will be deprecated. | ||
const commitQueueRequester = "merge_test"; | ||
|
||
enum Requester { | ||
AdHoc = "ad_hoc", | ||
GitHubMergeQueue = "github_merge_request", | ||
GitHubPR = "github_pull_request", | ||
GitTag = "git_tag_request", | ||
Gitter = "gitter_request", | ||
Patch = "patch_request", | ||
Trigger = "trigger_request", | ||
} | ||
|
||
const requesterToTitle: PartialRecord<Requester, string> = { | ||
[Requester.AdHoc]: "Ad Hoc Request", | ||
[Requester.GitHubMergeQueue]: "GitHub Merge Request", | ||
[Requester.GitHubPR]: "GitHub Pull Request", | ||
[Requester.GitTag]: "Git Tag Request", | ||
[Requester.Gitter]: "Gitter Request", | ||
[Requester.Patch]: "Patch Request", | ||
[Requester.Trigger]: "Trigger Request", | ||
}; | ||
|
||
const requesterToDescription: PartialRecord<Requester, string> = { | ||
[Requester.AdHoc]: "Periodic build versions", | ||
[Requester.Gitter]: "Repotracker versions", | ||
[Requester.Patch]: "Manual patches made via CLI or API", | ||
[Requester.Trigger]: "Downstream trigger versions", | ||
}; | ||
|
||
export { | ||
Requester, | ||
commitQueueRequester, | ||
requesterToTitle, | ||
requesterToDescription, | ||
}; |
3 changes: 3 additions & 0 deletions
3
apps/spruce/src/gql/fragments/projectSettings/appSettings.graphql
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,3 @@ | ||
fragment ProjectAppSettings on Project { | ||
githubPermissionGroupByRequester | ||
} |
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.