RF-39249 Add AI Test Generation Command#500
Conversation
178126b to
a9c1140
Compare
generate command for AI test generationgenerate command for AI test generation
7119044 to
7fa7b22
Compare
7fa7b22 to
4be863d
Compare
generate command for AI test generation4be863d to
c179fac
Compare
c179fac to
5ca079e
Compare
22f31f0 to
74bf734
Compare
b696760 to
26f2e5f
Compare
ef9679b to
efead42
Compare
efead42 to
8e41eb9
Compare
|
/reviewme @ubergeek42 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ubergeek42
left a comment
There was a problem hiding this comment.
I think I have a bunch of questions/concerns about RFML/download/export, because I don't think that's a thing for automated tests.
README.md
Outdated
| Download the generated test as an RFML file after creation. | ||
|
|
||
| ```bash | ||
| rainforest generate "Search for a product" --start-uri /search --download | ||
| ``` |
There was a problem hiding this comment.
I don't think this makes any sense. RFML is for plain english tests, which test generation doesn't produce.
rainforest-cli.go
Outdated
| }, | ||
| cli.StringFlag{ | ||
| Name: "credentials", | ||
| Usage: "Credentials information to pass to the AI for test generation. Mutually exclusive with --login-snippet-id.", |
There was a problem hiding this comment.
This help text seems like it could be better. What is the expected format for this? Is it just an opaque string that gets passed into some AI model under the hood, so you can write whatever you want here? Or do they need to be username: whatever; password: something_else?
rainforest-cli.go
Outdated
| cli.BoolFlag{ | ||
| Name: "download, d", | ||
| Usage: "Download the generated test as an RFML file after creation.", | ||
| }, |
There was a problem hiding this comment.
Likewise, I don't think this makes sense.
tests.go
Outdated
| if len(browserNames) == 0 { | ||
| browserName = "windows11_chrome" |
There was a problem hiding this comment.
Does the backend require us to pass a value for platform? If we leave it blank/unset/null in the api request, will it default to something sane on the backend?
I'd prefer not to set a default here if the backend will already do so, as it makes changing the default later on more annoying (two places instead of one)
tests.go
Outdated
| // parseAndValidateBrowser parses the platform flag for AI test generation. | ||
| // Returns the browsers array with a single browser name. | ||
| func parseAndValidateBrowser(c cliContext) ([]string, error) { | ||
| browserNames := c.StringSlice("platform") |
There was a problem hiding this comment.
I'm a little curious why we're doing any processing on this to turn it into a list, just to say "hey, we don't support this being a list". Shouldn't it just be that we only accept a single platform, and let the backend validate it as a valid platform or not. And if we want to get fancier, just say that anything that contains characters other than [a-z0-9_] isn't valid.
tests.go
Outdated
|
|
||
| title := c.String("title") | ||
| if title == "" { | ||
| // Use first 50 characters (runes) of prompt as default title |
There was a problem hiding this comment.
Out of scope, but I wonder if we should just send in an empty title, and have the backend generate one based on what actually got created. Similar to how chatgpt/gemini/etc give a name to your chat after your initial message that "summarizes" what it's about.
But similar to the above, I don't like setting a default/passing it in if we can avoid it and let the backend choose a sane default. I don't know what the backend behavior currently is, so maybe this is fine for now.
tests.go
Outdated
| log.Printf("Successfully created test #%d: %s", response.TestID, response.Title) | ||
| log.Printf("RFML ID: %s", response.RFMLID) | ||
| log.Printf("State: %s", response.State) |
There was a problem hiding this comment.
Seems like this needs some note about how the test is technically created, but is still processing/generating? And RFMLID should go away.
8e41eb9 to
ce865c0
Compare
Add support for generating tests using AI through the CLI. The new `generate` command (with `gen` and `ai` aliases) accepts a natural language prompt and creates a test via the Rainforest API. Features: - Generate tests from natural language prompts - Support for --start-uri or --url to specify the starting point - Optional --title flag for custom test name - Optional --environment-id flag for test environment - Support for authentication via --credentials or --login-snippet-id (mutually exclusive); credentials is a free-form string passed to the AI model - Platform selection with --platform (single value, validated with [a-z0-9_] pattern, backend provides default if omitted) - Comprehensive validation and error handling Example usage: rainforest generate "Log in with valid credentials" --start-uri /login rainforest generate "Add item to cart" --url https://example.com
Update version constant and add CHANGELOG entry for the new `generate` command feature.
ce865c0 to
8098c2d
Compare
|
/reviewme @ubergeek42 |
Tested manually ☑️
Introduces AI-powered test generation to the Rainforest CLI, allowing users to create tests using natural language prompts.
New Commands
rainforest generate- Generate a new test from a natural language promptKey Features
--start-urior--url(mutually exclusive)--titleand--environment-idflags--credentials(free-form string passed to AI) or--login-snippet-id(mutually exclusive)--platform(validated with[a-z0-9_]pattern; omit to use backend default)Implementation Highlights
CreateTestWithAI()API methodVersion: 3.8.0