-
Notifications
You must be signed in to change notification settings - Fork 4
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 flaky tests #4
- Loading branch information
Showing
20 changed files
with
387 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ const config: PlaywrightTestConfig<{}, {}> = { | |
linkUrlOnFailure: | ||
"https://github.com/playwright-community/playwright-msteams-reporter/issues", | ||
linkTextOnFailure: "Report an issue", | ||
mentionOnFailure: "Elio <[email protected]>, [email protected]", | ||
mentionOnFailure: "[email protected]", | ||
mentionOnFailureText: "", | ||
debug: 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const Images = { | ||
success: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAFCAIAAAAL5hHIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAEklEQVQImWOweTCViYGBARkDAB59Abohe/o4AAAAAElFTkSuQmCC`, | ||
flaky: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAFCAIAAAAL5hHIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAEUlEQVQImWP4nszDxMDAgIwBGnsBb7ZK8egAAAAASUVORK5CYII=`, | ||
failed: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAFCAIAAAAL5hHIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAEUlEQVQImWP45+XJxMDAgIwBHUsBmph35dMAAAAASUVORK5CYII=`, | ||
}; |
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,6 @@ | ||
export interface TestStatuses { | ||
passed: number; | ||
flaky: number; | ||
failed: number; | ||
skipped: number; | ||
} |
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,3 +1,4 @@ | ||
export * from "./AdaptiveCard"; | ||
export * from "./Table"; | ||
export * from "./TestStatuses"; | ||
export * from "./WebhookType"; |
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,44 @@ | ||
import { TestStatuses } from "../models"; | ||
import { getNotificationBackground } from "."; | ||
import { Images } from "../constants"; | ||
|
||
describe("getNotificationBackground", () => { | ||
it("Should return 'success' background", () => { | ||
const statuses: TestStatuses = { | ||
passed: 1, | ||
failed: 0, | ||
flaky: 0, | ||
skipped: 0, | ||
}; | ||
|
||
const title = getNotificationBackground(statuses); | ||
|
||
expect(title).toBe(Images.success); | ||
}); | ||
|
||
it("Should return 'flaky' background", () => { | ||
const statuses: TestStatuses = { | ||
passed: 1, | ||
failed: 0, | ||
flaky: 1, | ||
skipped: 0, | ||
}; | ||
|
||
const title = getNotificationBackground(statuses); | ||
|
||
expect(title).toBe(Images.flaky); | ||
}); | ||
|
||
it("Should return 'failed' background", () => { | ||
const statuses: TestStatuses = { | ||
passed: 1, | ||
failed: 1, | ||
flaky: 1, | ||
skipped: 0, | ||
}; | ||
|
||
const title = getNotificationBackground(statuses); | ||
|
||
expect(title).toBe(Images.failed); | ||
}); | ||
}); |
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,17 @@ | ||
import { TestStatuses } from "../models"; | ||
import { getNotificationOutcome } from "."; | ||
import { Images } from "../constants"; | ||
|
||
export const getNotificationBackground = (statuses: TestStatuses) => { | ||
const outcome = getNotificationOutcome(statuses); | ||
|
||
if (outcome === "passed") { | ||
return Images.success; | ||
} | ||
|
||
if (outcome === "flaky") { | ||
return Images.flaky; | ||
} | ||
|
||
return Images.failed; | ||
}; |
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 { TestStatuses } from "../models"; | ||
import { getNotificationColor } from "."; | ||
|
||
describe("getNotificationColor", () => { | ||
it("Should return 'good' background", () => { | ||
const statuses: TestStatuses = { | ||
passed: 1, | ||
failed: 0, | ||
flaky: 0, | ||
skipped: 0, | ||
}; | ||
|
||
const title = getNotificationColor(statuses); | ||
|
||
expect(title).toBe("Good"); | ||
}); | ||
|
||
it("Should return 'warning' background", () => { | ||
const statuses: TestStatuses = { | ||
passed: 1, | ||
failed: 0, | ||
flaky: 1, | ||
skipped: 0, | ||
}; | ||
|
||
const title = getNotificationColor(statuses); | ||
|
||
expect(title).toBe("Warning"); | ||
}); | ||
|
||
it("Should return 'attention' background", () => { | ||
const statuses: TestStatuses = { | ||
passed: 1, | ||
failed: 1, | ||
flaky: 1, | ||
skipped: 0, | ||
}; | ||
|
||
const title = getNotificationColor(statuses); | ||
|
||
expect(title).toBe("Attention"); | ||
}); | ||
}); |
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,18 @@ | ||
import { TestStatuses } from "../models"; | ||
import { getNotificationOutcome } from "."; | ||
|
||
export const getNotificationColor = ( | ||
statuses: TestStatuses | ||
): "Good" | "Warning" | "Attention" => { | ||
const outcome = getNotificationOutcome(statuses); | ||
|
||
if (outcome === "passed") { | ||
return "Good"; | ||
} | ||
|
||
if (outcome === "flaky") { | ||
return "Warning"; | ||
} | ||
|
||
return "Attention"; | ||
}; |
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,18 @@ | ||
import { TestStatuses } from "../models"; | ||
|
||
export const getNotificationOutcome = ( | ||
statuses: TestStatuses | ||
): "passed" | "flaky" | "failed" => { | ||
const isSuccess = statuses.failed === 0; | ||
const hasFlakyTests = statuses.flaky > 0; | ||
|
||
if (isSuccess && !hasFlakyTests) { | ||
return "passed"; | ||
} | ||
|
||
if (isSuccess && hasFlakyTests) { | ||
return "flaky"; | ||
} | ||
|
||
return "failed"; | ||
}; |
Oops, something went wrong.