-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(cli): fix github md report report and test
- Loading branch information
Showing
11 changed files
with
123 additions
and
12 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 |
---|---|---|
|
@@ -43,3 +43,5 @@ Thumbs.db | |
|
||
.env | ||
.code-pushup | ||
|
||
examples/**/measures/* |
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,10 @@ | ||
{ | ||
"collect": { | ||
"url": "https://coffee-cart.netlify.app/", | ||
"ufPath": "./examples/github-report/user-flows" | ||
}, | ||
"persist": { | ||
"outPath": "./examples/github-report/measures", | ||
"format": [ "md" ] | ||
} | ||
} |
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,15 @@ | ||
## Github Comment Report Example | ||
|
||
This example demonstrates how you can easily take you current user-flow reports and add them as comments in a GITHUB PR | ||
|
||
### Description | ||
|
||
The example has a minimal user-flow and is executed in a github workflow. | ||
|
||
You can find the related workflow under `.github/workflows/user-flow-md-report-test.yml`. | ||
|
||
The workflow executes user-flow then with a script transforms and renames the report. | ||
|
||
Then using a GITHUB action it adds it to the pull request as a comment. If there is already a report present it will minimize the previous one when adding a new one. | ||
|
||
![github-report-comment](assets/github-report-comment.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
15 changes: 11 additions & 4 deletions
15
tools/md-report-rename.ts → .../github-report/tools/md-report-rename.mts
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,19 +1,26 @@ | ||
import {readdirSync, readFileSync, writeFileSync} from 'fs'; | ||
import {join} from 'path'; | ||
import {readdirSync, readFileSync, writeFileSync} from 'node:fs'; | ||
import {join} from 'node:path'; | ||
|
||
console.log(`Rename results for comment action`); | ||
|
||
const path = './examples/github-report/measures'; | ||
|
||
console.log(`Reame results for comment action`); | ||
const path = 'dist/user-flow/user-flow-gh-integration'; | ||
const reportPath = readdirSync(path)[0]; | ||
|
||
if (!reportPath) { | ||
throw new Error('Report file not found'); | ||
} | ||
|
||
const targetPath = join(path, reportPath); | ||
const destPath = join(path, 'md-report.md'); | ||
|
||
let report = readFileSync(targetPath, {encoding: 'utf8'}); | ||
|
||
report = ` | ||
❗❗❗ **report generated by this PR** ❗❗❗ | ||
--- | ||
` + report; | ||
|
||
writeFileSync(destPath, report); | ||
console.log(`Report ${targetPath} renamed to ${destPath}`); |
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 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": {}, | ||
"files": [], | ||
"include": ["**/*"], | ||
} |
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,67 @@ | ||
import {UserFlowContext, UserFlowInteractionsFn, UserFlowProvider} from '@push-based/user-flow'; | ||
|
||
const interactions: UserFlowInteractionsFn = async (ctx: UserFlowContext): Promise<any> => { | ||
const { page, flow, browser, collectOptions } = ctx; | ||
const { url } = collectOptions; | ||
|
||
// Navigate to coffee order site | ||
await flow.navigate(url, { | ||
name: '🧭 Navigate to coffee cart', | ||
}); | ||
|
||
await flow.startTimespan({ name: '☕ Select coffee' }); | ||
|
||
// Select coffee | ||
const cappuccinoItem = '.cup:nth-child(1)'; | ||
await page.waitForSelector(cappuccinoItem); | ||
await page.click(cappuccinoItem); | ||
|
||
await flow.endTimespan(); | ||
|
||
await flow.snapshot({ name: '✔ Coffee selected' }); | ||
|
||
|
||
await flow.startTimespan({ name: '🛒 Checkout order' }); | ||
|
||
// Checkout order | ||
const checkoutBtn = '[data-test=checkout]'; | ||
await page.waitForSelector(checkoutBtn); | ||
await page.click(checkoutBtn); | ||
|
||
const nameInputSelector = '#name'; | ||
await page.waitForSelector(nameInputSelector); | ||
await page.type(nameInputSelector, 'nina'); | ||
|
||
const emailInputSelector = '#email'; | ||
await page.waitForSelector(emailInputSelector); | ||
await page.type(emailInputSelector, '[email protected]'); | ||
|
||
await flow.endTimespan(); | ||
|
||
await flow.snapshot({ name: '🧾 Order checked out' }); | ||
|
||
await flow.startTimespan({ name: '💌 Submit order' }); | ||
|
||
// Submit order | ||
const submitBtn = '#submit-payment'; | ||
await page.click(submitBtn); | ||
await page.waitForSelector(submitBtn); | ||
const successMsg = '.snackbar.success'; | ||
await page.waitForSelector(successMsg); | ||
|
||
await flow.endTimespan(); | ||
|
||
await flow.snapshot({ name: '📧 Order submitted' }); | ||
|
||
// Navigate to github info site | ||
await flow.navigate(url+'github', { | ||
name: '🧭 Navigate to github' | ||
}); | ||
}; | ||
|
||
const userFlowProvider: UserFlowProvider = { | ||
flowOptions: {name: '☕ Order Coffee ☕'}, | ||
interactions | ||
}; | ||
|
||
module.exports = userFlowProvider; |
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