Skip to content

Commit

Permalink
Improve Testing UX (#9)
Browse files Browse the repository at this point in the history
* add optional verbose mode

* update readme and Playwright dependencies
  • Loading branch information
mgaoVA authored Oct 29, 2024
1 parent d686fc7 commit a7f6435
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 150 deletions.
22 changes: 11 additions & 11 deletions API-tests/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package main

type WorkflowEventsResponse []WorkflowEvent

type WorkflowEvent struct{
EventID string `json:"eventID"`
EventDescription string `json:"eventDescription"`
EventType string `json:"eventType"`
EventData string `json:"eventData"`
type WorkflowEvent struct {
EventID string `json:"eventID"`
EventDescription string `json:"eventDescription"`
EventType string `json:"eventType"`
EventData string `json:"eventData"`
}

type EmailTemplatesRecord struct{
DisplayName string `displayName`
FileName string `fileName`
EmailToFileName string `emailTo`
EmailCcFileName string `emailCc`
SubjectFileName string `subject`
type EmailTemplatesRecord struct {
DisplayName string `json:"displayName"`
FileName string `json:"fileName"`
EmailToFileName string `json:"emailToFileName"`
EmailCcFileName string `json:"emailCcFileName"`
SubjectFileName string `json:"subjectFileName"`
}

type EmailTemplatesResponse []EmailTemplatesRecord
11 changes: 10 additions & 1 deletion api-test-helper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var runningTests = false
var mxRunningTests sync.Mutex

func handleRunTest(w http.ResponseWriter, r *http.Request) {
modeVerbose := r.URL.Query().Has("-v")

mxRunningTests.Lock()
if !runningTests {
runningTests = true
Expand All @@ -35,7 +37,14 @@ func handleRunTest(w http.ResponseWriter, r *http.Request) {
cmdClear.Dir = "../API-tests/"
cmdClear.Run()

cmd := exec.Command("go", "test", "-v")
var cmd *exec.Cmd
if modeVerbose {
log.Println("Running in verbose mode")
cmd = exec.Command("go", "test", "-v")
} else {
cmd = exec.Command("go", "test")
}

cmd.Dir = "../API-tests/"
pipe, err := cmd.StdoutPipe()
if err != nil {
Expand Down
26 changes: 25 additions & 1 deletion end2end/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
# LEAF End-to-end testing

TODO: Add overview
These tests simulate interactions with LEAF from a web browser to help ensure the user interface is working as intended.

LEAF uses Playwright for end-to-end testing. The test database is populated and updated via LEAF's API tester.

## Installing Playwright* Development Tools

0. Prerequisites:
- Install [node.js](https://nodejs.org/en)
1. Set up and run the [LEAF Development Environment](https://github.com/department-of-veterans-affairs/LEAF/blob/master/docs/InstallationConfiguration.md)
3. On the command line: Navigate to the location where the development environment is installed
4. Change directory into `LEAF-Automated-Tests/end2end`
5. Install Playwright development tools:
```
npm install -D @playwright/test@latest
npx playwright install
```

*Note: If you decide to use Playwright's installation instructions, it will prompt with with some decisions that need to be made. The choices we've made are:
- TypeScript or JavaScript? **TypeScript**
- Name of your tests folder? **tests**
- GitHub Actions workflow? **N**
- Install browsers? **Y**


## Useful commands

These commands should be run from within the folder: `LEAF-Automated-Tests/end2end`

Start Playwright's code generator UI:
```
npx playwright codegen --ignore-https-errors https://host.docker.internal/Test_Request_Portal/
Expand Down
148 changes: 12 additions & 136 deletions end2end/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion end2end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "ISC",
"description": "",
"devDependencies": {
"@playwright/test": "^1.47.2",
"@playwright/test": "^1.48.1",
"@types/node": "^22.1.0"
}
}

0 comments on commit a7f6435

Please sign in to comment.