This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
DEVPROD-2227: Remove family triggers from trigger definitions #2203
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
58013e1
DEVPROD-2227: Remove family triggers from trigger definitions
minnakt 98ce727
case sensitivity -_-
minnakt 24cf6f2
Merge branch 'main' into DEVPROD-2227
minnakt a8ffdde
Better naming and comments
minnakt b57fd8a
Fix wrong capitalization
minnakt 1c10279
Update triggers.ts
minnakt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ describe("Notifications", () => { | |
cy.dataCy("add-button").contains("Add Subscription").should("be.visible"); | ||
cy.dataCy("add-button").click(); | ||
cy.dataCy("expandable-card").should("contain.text", "New Subscription"); | ||
cy.selectLGOption("Event", "Any Version Finishes"); | ||
cy.selectLGOption("Event", "Any version finishes"); | ||
cy.selectLGOption("Notification Method", "Email"); | ||
cy.getInputByLabel("Email").type("[email protected]"); | ||
cy.dataCy("save-settings-button").scrollIntoView(); | ||
|
@@ -43,7 +43,7 @@ describe("Notifications", () => { | |
cy.dataCy("expandable-card") | ||
.should("be.visible") | ||
.should("contain.text", "New Subscription"); | ||
cy.selectLGOption("Event", "Any Task Finishes"); | ||
cy.selectLGOption("Event", "Any task finishes"); | ||
cy.selectLGOption("Notification Method", "Comment on a JIRA issue"); | ||
cy.getInputByLabel("JIRA Issue").type("JIRA-123"); | ||
cy.contains("Subscription type not allowed for tasks in a project.").should( | ||
|
@@ -58,7 +58,7 @@ describe("Notifications", () => { | |
cy.dataCy("expandable-card") | ||
.should("be.visible") | ||
.should("contain.text", "New Subscription"); | ||
cy.selectLGOption("Event", "Any Version Finishes"); | ||
cy.selectLGOption("Event", "Any version finishes"); | ||
cy.selectLGOption("Notification Method", "Email"); | ||
cy.getInputByLabel("Email").type("Not a real email"); | ||
cy.contains("Value should be a valid email.").should("be.visible"); | ||
|
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 |
---|---|---|
|
@@ -106,7 +106,7 @@ describe("getGqlPayload", () => { | |
type: "email", | ||
target: "[email protected]", | ||
}, | ||
trigger: "family-outcome", | ||
trigger: "outcome", | ||
trigger_data: {}, | ||
}); | ||
}); | ||
|
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 | ||||
---|---|---|---|---|---|---|
|
@@ -135,19 +135,19 @@ export const taskTriggers: Trigger = { | |||||
// VERSION TRIGGERS | ||||||
export const versionTriggers: Trigger = { | ||||||
[VersionTriggers.VERSION_FINISHES]: { | ||||||
trigger: TriggerType.FAMILY_OUTCOME, | ||||||
trigger: TriggerType.OUTCOME, | ||||||
label: "This version finishes", | ||||||
resourceType: ResourceType.Version, | ||||||
payloadResourceIdKey: "id", | ||||||
}, | ||||||
[VersionTriggers.VERSION_FAILS]: { | ||||||
trigger: TriggerType.FAMILY_FAILURE, | ||||||
trigger: TriggerType.FAILURE, | ||||||
label: "This version fails", | ||||||
resourceType: ResourceType.Version, | ||||||
payloadResourceIdKey: "id", | ||||||
}, | ||||||
[VersionTriggers.VERSION_SUCCEEDS]: { | ||||||
trigger: TriggerType.FAMILY_SUCCESS, | ||||||
trigger: TriggerType.SUCCESS, | ||||||
label: "This version succeeds", | ||||||
resourceType: ResourceType.Version, | ||||||
payloadResourceIdKey: "id", | ||||||
|
@@ -207,70 +207,70 @@ export const versionTriggers: Trigger = { | |||||
|
||||||
export const projectTriggers: Trigger = { | ||||||
[ProjectTriggers.ANY_VERSION_FINISHES]: { | ||||||
trigger: TriggerType.FAMILY_OUTCOME, | ||||||
trigger: TriggerType.OUTCOME, | ||||||
resourceType: ResourceType.Version, | ||||||
label: "Any Version Finishes", | ||||||
label: "Any version finishes", | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_VERSION_FAILS]: { | ||||||
trigger: TriggerType.FAMILY_FAILURE, | ||||||
trigger: TriggerType.FAILURE, | ||||||
resourceType: ResourceType.Version, | ||||||
label: "Any Version Fails", | ||||||
label: "Any version fails", | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_BUILD_FINISHES]: { | ||||||
trigger: TriggerType.OUTCOME, | ||||||
resourceType: ResourceType.Build, | ||||||
label: "Any Build Finishes", | ||||||
label: "Any build finishes", | ||||||
regexSelectors: buildRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_BUILD_FAILS]: { | ||||||
trigger: TriggerType.FAILURE, | ||||||
resourceType: ResourceType.Build, | ||||||
label: "Any Build Fails", | ||||||
label: "Any build fails", | ||||||
regexSelectors: buildRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_TASK_FINISHES]: { | ||||||
trigger: TriggerType.OUTCOME, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "Any Task Finishes", | ||||||
label: "Any task finishes", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_TASK_FAILS]: { | ||||||
trigger: TriggerType.FAILURE, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "Any Task Fails", | ||||||
label: "Any task fails", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [failureTypeSubscriberConfig, requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.FIRST_FAILURE_VERSION]: { | ||||||
trigger: TriggerType.FIRST_FAILURE_VERSION, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "The First Failure In a Version Occurs", | ||||||
label: "The first failure in a version occurs", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.FIRST_FAILURE_BUILD]: { | ||||||
trigger: TriggerType.FIRST_FAILURE_BUILD, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "The First Failure In Each Build Occurs", | ||||||
label: "The first failure in each build occurs", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.FIRST_FAILURE_TASK]: { | ||||||
trigger: TriggerType.FIRST_FAILURE_VERSION_NAME, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "The First Failure In Each Version For Each Task Name Occurs", | ||||||
label: "The first failure in each version for each task name occurs", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.PREVIOUS_PASSING_TASK_FAILS]: { | ||||||
trigger: TriggerType.REGRESSION, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "A Previously Passing Task Fails", | ||||||
label: "A previously passing task fails", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [ | ||||||
{ | ||||||
|
@@ -286,7 +286,7 @@ export const projectTriggers: Trigger = { | |||||
[ProjectTriggers.PREVIOUS_PASSING_TEST_FAILS]: { | ||||||
trigger: TriggerType.TEST_REGRESSION, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "A Previously Passing Test In a Task Fails", | ||||||
label: "A previously passing test in a task fails", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [ | ||||||
{ | ||||||
|
@@ -309,7 +309,7 @@ export const projectTriggers: Trigger = { | |||||
[ProjectTriggers.SUCCESSFUL_TASK_EXCEEDS_DURATION]: { | ||||||
trigger: TriggerType.SUCCESSFUL_EXCEEDS_DURATION, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "The Runtime For a Successful Task Exceeds Some Duration", | ||||||
label: "The runtime For a successful task exceeds some duration", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [ | ||||||
{ | ||||||
|
@@ -324,7 +324,7 @@ export const projectTriggers: Trigger = { | |||||
[ProjectTriggers.TASK_EXCEEDS_DURATION]: { | ||||||
trigger: TriggerType.EXCEEDS_DURATION, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "The Runtime For Any Task Exceeds Some Duration", | ||||||
label: "The runtime for any task exceeds some duration", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [ | ||||||
{ | ||||||
|
@@ -339,7 +339,7 @@ export const projectTriggers: Trigger = { | |||||
[ProjectTriggers.SUCCESSFUL_TASK_RUNTIME_CHANGES]: { | ||||||
trigger: TriggerType.RUNTIME_CHANGE, | ||||||
resourceType: ResourceType.Task, | ||||||
label: "The Runtime For a Successful Task Changes By Some Percentage", | ||||||
label: "The runtime for a successful task changes by some percentage", | ||||||
regexSelectors: taskRegexSelectors, | ||||||
extraFields: [ | ||||||
{ | ||||||
|
@@ -355,41 +355,41 @@ export const projectTriggers: Trigger = { | |||||
|
||||||
export const waterfallTriggers: Trigger = { | ||||||
[ProjectTriggers.ANY_VERSION_FINISHES]: { | ||||||
trigger: TriggerType.FAMILY_OUTCOME, | ||||||
trigger: TriggerType.OUTCOME, | ||||||
resourceType: ResourceType.Version, | ||||||
label: "Any Version Finishes", | ||||||
label: "Any version finishes", | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_VERSION_FAILS]: { | ||||||
trigger: TriggerType.FAMILY_FAILURE, | ||||||
trigger: TriggerType.FAILURE, | ||||||
resourceType: ResourceType.Version, | ||||||
label: "Any Version Fails", | ||||||
label: "Any version fails", | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_VERSION_SUCCEEDS]: { | ||||||
trigger: TriggerType.FAMILY_SUCCESS, | ||||||
trigger: TriggerType.SUCCESS, | ||||||
resourceType: ResourceType.Version, | ||||||
label: "Any Version Succeeds", | ||||||
label: "Any version succeeds", | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_BUILD_FINISHES]: { | ||||||
trigger: TriggerType.OUTCOME, | ||||||
resourceType: ResourceType.Build, | ||||||
label: "Any Build Finishes", | ||||||
label: "Any build finishes", | ||||||
regexSelectors: buildRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_BUILD_FAILS]: { | ||||||
trigger: TriggerType.FAILURE, | ||||||
resourceType: ResourceType.Build, | ||||||
label: "Any Build Fails", | ||||||
label: "Any build fails", | ||||||
regexSelectors: buildRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
[ProjectTriggers.ANY_BUILD_SUCCEEDS]: { | ||||||
trigger: TriggerType.SUCCESS, | ||||||
resourceType: ResourceType.Build, | ||||||
label: "Any Build Succeeds", | ||||||
label: "Any build succeeds", | ||||||
regexSelectors: buildRegexSelectors, | ||||||
extraFields: [requesterSubscriberConfig], | ||||||
}, | ||||||
|
@@ -418,24 +418,23 @@ export const triggerToCopy = { | |||||
[TriggerType.OUTCOME]: "Outcome", | ||||||
[TriggerType.FAILURE]: "Failure", | ||||||
[TriggerType.SUCCESS]: "Success", | ||||||
[TriggerType.FAMILY_OUTCOME]: "Outcome", | ||||||
[TriggerType.FAMILY_FAILURE]: "Failure", | ||||||
[TriggerType.FAMILY_SUCCESS]: "Success", | ||||||
[TriggerType.RUNTIME_CHANGE]: "Runtime changes by %", | ||||||
[TriggerType.EXCEEDS_DURATION]: "Runtime exceeds duration", | ||||||
[TriggerType.SUCCESSFUL_EXCEEDS_DURATION]: "Runtime exceeds duration", | ||||||
[TriggerType.TASK_STARTED]: "Task started", | ||||||
[TriggerType.TASK_FAILED_OR_BLOCKED]: "Task failed or blocked", | ||||||
[TriggerType.REGRESSION]: "Regression", | ||||||
[TriggerType.TEST_REGRESSION]: "Test regression", | ||||||
[TriggerType.FIRST_FAILURE_BUILD]: "First failure", | ||||||
[TriggerType.FIRST_FAILURE_BUILD]: "First failure in build", | ||||||
[TriggerType.FIRST_FAILURE_VERSION]: "First failure in version", | ||||||
[TriggerType.FIRST_FAILURE_VERSION_NAME]: | ||||||
"First failure in version with name", | ||||||
[TriggerType.FAMILY_OUTCOME]: "Outcome", | ||||||
[TriggerType.FAMILY_FAILURE]: "Failure", | ||||||
[TriggerType.FAMILY_SUCCESS]: "Success", | ||||||
}; | ||||||
|
||||||
export const convertFamilyTrigger = (trigger: string) => { | ||||||
export const fromFamilyTrigger = (trigger: string) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this function have a comment on why it's used?
Suggested change
|
||||||
switch (trigger) { | ||||||
case TriggerType.FAMILY_OUTCOME: | ||||||
return TriggerType.OUTCOME; | ||||||
|
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,6 @@ | ||
import { ProjectSettingsTabRoutes } from "constants/routes"; | ||
import { getSubscriberText } from "constants/subscription"; | ||
import { convertFamilyTrigger, projectTriggers } from "constants/triggers"; | ||
import { fromFamilyTrigger, projectTriggers } from "constants/triggers"; | ||
import { | ||
BannerTheme, | ||
ProjectInput, | ||
|
@@ -16,7 +16,7 @@ type Tab = ProjectSettingsTabRoutes.Notifications; | |
const { toSentenceCase } = string; | ||
|
||
const getTriggerText = (trigger: string, resourceType: string) => { | ||
const convertedTrigger = convertFamilyTrigger(trigger); | ||
const convertedTrigger = fromFamilyTrigger(trigger); | ||
const triggerText = | ||
resourceType && trigger | ||
? `${toSentenceCase(resourceType)} ${convertedTrigger} ` | ||
|
@@ -25,9 +25,10 @@ const getTriggerText = (trigger: string, resourceType: string) => { | |
}; | ||
|
||
const getTriggerEnum = (trigger: string, resourceType: string) => { | ||
const convertedTrigger = fromFamilyTrigger(trigger); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you improve the variable naming for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The resolver is a good idea! I will file a ticket for it -- shouldn't be too difficult of a change! |
||
const triggerEnum = Object.keys(projectTriggers).find( | ||
(t) => | ||
projectTriggers[t].trigger === trigger && | ||
projectTriggers[t].trigger === convertedTrigger && | ||
projectTriggers[t].resourceType === resourceType | ||
); | ||
return triggerEnum; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you... 🥹