Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Email Validation #135

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
a6747d6
feat: add sleep_miliseconds tool to wait for a certain condition to b…
m2rads Dec 24, 2024
59d2252
refactor: Directly execute setup.js since we now handle errors gracef…
m2rads Dec 24, 2024
bae44d5
fix: installation of playwright chrome browser
m2rads Dec 24, 2024
b9c6b1f
update
m2rads Dec 24, 2024
7e9ceaf
refactor: simplify setup script to only install playwright browsers -…
m2rads Dec 24, 2024
3f1f59a
refactor: remvoe manual installation of playwright browser in workflow
m2rads Dec 24, 2024
8a93770
update changelogs
m2rads Dec 24, 2024
854eca9
update: add -D to installation guide and .shortest/ to .gitignore
m2rads Dec 24, 2024
2b58f52
bump the version
m2rads Dec 24, 2024
b2743d7
Update: add exception handling to browser manager to install playwrig…
m2rads Dec 24, 2024
c9b73d4
update
m2rads Dec 24, 2024
b210f0f
update changelogs
m2rads Dec 24, 2024
c06ce71
install browsers before test execution to speed up the workflow
m2rads Dec 24, 2024
e7f9a2f
Merge branch 'main' into update-readme
m2rads Dec 24, 2024
342c75e
Merge branch 'update-readme' into fit/email-validation
m2rads Dec 24, 2024
d80c979
update prompt related to sleep_miliseconds tool
m2rads Dec 24, 2024
4a8c07f
feat: add rendering and email generation tool
m2rads Dec 24, 2024
eb6b468
update tests
m2rads Dec 24, 2024
9bd39fd
merge main
m2rads Dec 24, 2024
5db5747
bump version
m2rads Dec 24, 2024
0d8b817
Update config type to include Mailosaur apiKey and serverId
m2rads Dec 25, 2024
ea7a770
Add mailosaur sdk
m2rads Dec 25, 2024
e0bfaa0
add email address to the config file
m2rads Dec 25, 2024
17ce083
remove generate email tool as we add email address in config tool now
m2rads Dec 25, 2024
639c87d
Feat: add new integration with mailosaur to grab the latest email rec…
m2rads Dec 25, 2024
2c9ac2f
update exports
m2rads Dec 25, 2024
a074d90
update system prompt to include instructions for email validation
m2rads Dec 25, 2024
3697dc4
Feat: add 'render_email' tool to grab the latest email from Mailosaur…
m2rads Dec 25, 2024
22db152
add a new test script to test the email feature
m2rads Dec 25, 2024
aaebf80
update: marking node builts as external for https, http, net, tls, c…
m2rads Dec 26, 2024
c57dcfd
update
m2rads Dec 26, 2024
116b58b
Add email address as action input
m2rads Dec 26, 2024
dff473b
remove the need of adding email address to the config
m2rads Dec 26, 2024
bdb36fe
update: use emailAddress from ActionInput instead of the config file
m2rads Dec 26, 2024
834d5da
update emailAddress to be loosely typed
m2rads Dec 26, 2024
c621ebe
Update: in case of a failure in validating an email, send error to AI…
m2rads Dec 26, 2024
88474bf
Update prompt to instruct AI to pass the email as ActionInput
m2rads Dec 26, 2024
dab4f71
update: handle Mailsauor failrues seperately
m2rads Dec 26, 2024
1ac66cd
update: add a safe gaurd for missing email address
m2rads Dec 26, 2024
21be464
Update prompt to be more strcict about tool use
m2rads Dec 26, 2024
858e023
Update changelogs
m2rads Dec 26, 2024
f77a49d
remove extra space
m2rads Dec 26, 2024
a61ec17
update the test email address
m2rads Dec 26, 2024
7b587f3
merge main
m2rads Dec 26, 2024
89d41e7
Merge branch 'main' into fit/email-validation
m2rads Dec 26, 2024
2a4b89e
Update naming of email and sleep tools
m2rads Dec 26, 2024
e82bbe1
remove Helper related test
m2rads Dec 27, 2024
5646830
simplify the test case
m2rads Dec 27, 2024
d62f5a5
further simplify the test case
m2rads Dec 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/__tests__/dashboard.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { shortest } from "@antiwork/shortest";
import { clerk, clerkSetup } from "@clerk/testing/playwright";

let frontendUrl = process.env.SHORTEST_TEST_BASE_URL ?? "http://localhost:3000";
let frontendUrl = process.env.PLAYWRIGHT_TEST_BASE_URL ?? "http://localhost:3000";

shortest.beforeAll(async ({ page }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review would be helpful to me. Why isn't this needed?

await clerkSetup({
Expand All @@ -18,4 +18,4 @@ shortest.beforeAll(async ({ page }) => {
await page.goto(frontendUrl + "/dashboard");
});

shortest("Verify that the user can access the /dashboard page");
shortest("Verify that the user can access the /dashboard page");
8 changes: 8 additions & 0 deletions packages/shortest/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.2] - 2024-12-26

### Added
- Added support for Mailosaur email validation
- Added email rendering feature in the browser
- Added sleep_milliseconds tool to add delays in the test execution
- Added more robust error handling for Mailosaur email validation
Comment on lines +8 to +14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the features that was added to in this PR. Since we have added a new feature, I used the wording Added. Maybe we can have a consistent wording for this file!?


## [0.1.1] - 2024-12-24

### Fixed
Expand Down
22 changes: 12 additions & 10 deletions packages/shortest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antiwork/shortest",
"version": "0.1.1",
"version": "0.1.2",
"description": "AI-powered natural language end-to-end testing framework",
"type": "module",
"main": "./dist/index.js",
Expand Down Expand Up @@ -29,36 +29,38 @@
"build:types": "tsc --emitDeclarationOnly --outDir dist/types && cp index.d.ts dist/",
"build:js": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:esbuild --external:punycode --external:playwright --external:@anthropic-ai/sdk --external:expect --external:dotenv",
"build:cjs": "esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.cjs --external:esbuild --external:punycode --external:playwright --external:@anthropic-ai/sdk --external:expect --external:dotenv",
"build:cli": "esbuild src/cli/bin.ts src/cli/setup.ts --bundle --platform=node --format=esm --outdir=dist/cli --metafile=dist/meta-cli.json --external:fsevents --external:chokidar --external:glob --external:esbuild --external:events --external:path --external:fs --external:util --external:stream --external:os --external:assert --external:url --external:playwright --external:@anthropic-ai/sdk --external:expect --external:dotenv --external:otplib --external:picocolors --external:punycode",
"build:cli": "esbuild src/cli/bin.ts src/cli/setup.ts --bundle --platform=node --format=esm --outdir=dist/cli --metafile=dist/meta-cli.json --external:fsevents --external:chokidar --external:glob --external:esbuild --external:events --external:path --external:fs --external:util --external:stream --external:os --external:assert --external:url --external:playwright --external:@anthropic-ai/sdk --external:expect --external:dotenv --external:otplib --external:picocolors --external:punycode --external:https --external:http --external:net --external:tls --external:crypto --external:mailosaur",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are just marking some more nodejs built ins as external so that they will work with Mailosaur implementation:. Here is the list:

https
http
net
tls
crypto

"dev": "pnpm build:types --watch",
"test:ai": "tsx tests/test-ai.ts",
"test:browser": "tsx tests/test-browser.ts",
"test:coordinates": "tsx tests/test-coordinates.ts",
"test:github": "tsx tests/test-github.ts",
"test:assertion": "tsx tests/test-assertion.ts",
"test:keyboard": "tsx tests/test-keyboard.ts"
"test:keyboard": "tsx tests/test-keyboard.ts",
"test:email": "tsx tests/test-email.ts"
},
"dependencies": {
"glob": "^10.3.10",
"chromium-bidi": "^0.5.2",
"glob": "^10.3.10",
"otplib": "^12.0.1",
"picocolors": "^1.0.0"
},
"devDependencies": {
"tsx": "^4.7.1",
"typescript": "~5.6.2",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.24"
"@types/node": "^20.11.24",
"tsx": "^4.7.1",
"typescript": "~5.6.2"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"playwright": "^1.48.2",
"esbuild": "^0.20.1",
"@anthropic-ai/sdk": "0.32.0",
"mailosaur": "^8.7.0",
"dotenv": "^16.4.5",
"esbuild": "^0.20.1",
"expect": "^29.7.0",
"dotenv": "^16.4.5"
"playwright": "^1.48.2"
},
"author": "Antiwork",
"license": "MIT",
Expand Down
15 changes: 12 additions & 3 deletions packages/shortest/src/ai/prompts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ Expect: 1. Test case to be generated within at least 20 seconds [HAS_CALLBACK]
IMPORTANT GLOBAL RULES:
1. **Waiting for Conditions**:
- Some steps will require waiting before proceeding to the next action.
- This waiting can be based on a time delay (e.g., seconds or minutes) or waiting for an element to become visible or clickable.
- If the specified condition is not met after the allotted time, the test should be considered failed.
- When you are specifically asked to wait for a condition, use the "sleep" tool. Otherwise, we internally handle proper waiting for elements to load.
- For time-based waits:
- Use { action: "sleep", duration: X } where X is milliseconds
- Always wait for the tool to finish before proceeding to the next action. You will recieve a message to continue with your next action once the wait is over. Then validate the condition is met.
2. **Tool Usage**:
- You may need to use provided tools to perform certain actions (e.g., clicking, navigating, or running callbacks).
Expand Down Expand Up @@ -42,6 +43,14 @@ IMPORTANT GLOBAL RULES:
- All expectations listed in the test instructions must be fulfilled.
- If any expectation is not met, the test case must be marked as failed.
8. **Testing Email**:
- If you need to test a condition that involves seeing the contents of an email, use the "check_email" tool.
- For email validation, you MUST always use 'Click' and 'Mouse' action instead of using keyboard shortcuts.
- This tool will grab the latest email from the email address given to you and will render it in a new tab for you to see.
- Once you are done with validating the email, navigate back to the original tab.
- You MUST pass the email address that is given to you to the tool as a parameter otherwise it will fail.
- If no email address is given to you for this test, you should fail the test.
Your task is to:
1. Execute browser actions to validate test cases
2. Use provided browser tools to interact with the page
Expand Down
36 changes: 36 additions & 0 deletions packages/shortest/src/ai/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,42 @@ export const AITools = [
required: ["action", "username", "password"],
},
},
{
name: "check_email",
description: "Fetch, decode and render received email in browser",
input_schema: {
type: "object",
properties: {
action: {
type: "string",
enum: ["check_email"],
description: "Render the received email in a new tab"
}
},
required: ["action", "email"]
}
},
{
name: "sleep",
description: "Pause test execution for specified duration",
input_schema: {
type: "object",
properties: {
action: {
type: "string",
enum: ["sleep"],
description: "The action to perform"
},
duration: {
type: "number",
description: "Duration to sleep in milliseconds (e.g. 5000 for 5 seconds)",
minimum: 0,
maximum: 60000
}
},
required: ["action", "duration"]
}
},
{
name: "run_callback",
description: "Run callback function for current test step",
Expand Down
Loading
Loading