Skip to content

feat: bdd unit tests added for httpTool example #140

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 40 additions & 0 deletions example/src/fabrice_latest_issues.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'dotenv/config'

import { httpTool } from '@fabrice-ai/tools/http'
import { agent } from 'fabrice-ai/agent'
import { logger } from 'fabrice-ai/telemetry'
import { workflow } from 'fabrice-ai/workflow'

const browser = agent({
description: `
You are skilled at browsing Web with specified URLs,
methods, params etc.
You are using "httpTool" to get the data from the API and/or Web pages.
`,
tools: {
httpTool,
},
})

const wrapupRedactor = agent({
description: `
Your role is to check Github project details and check for latest issues.
`,
})

export const checkupGithubProject = workflow({
team: { browser, wrapupRedactor },
description: `
Check the project details for "fabrice-ai" using the following API URL:
"https://api.github.com/repos/callstackincubator/fabrice-ai".

From the data received get the number of stars and the URL for the listing the issues.
List last top 3 issues and the number of star gazers for the project.
`,
output: `
Comprehensive markdown report for fabrice-ai project:
- Include top 3 new issues.
- Include the actual number of star gazers.
`,
snapshot: logger,
})
28 changes: 28 additions & 0 deletions example/src/fabrice_latest_issues.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'dotenv/config'

import { suite, test } from '@fabrice-ai/bdd/suite'
import { testwork } from '@fabrice-ai/bdd/testwork'

import { checkupGithubProject } from './fabrice_latest_issues.config.js'

const testResults = await testwork(
checkupGithubProject,
suite({
description: 'Black box testing suite',
team: {
},
workflow: [
test('0_check_stars', 'Final report should include the overal number of star gazers'),
test('1_check_issues', 'The report should contain list of 3 issues from Fabrice Github project'),
test('3_details', 'Should generate the report with the details of the selected project'),
],
})
)

if (!testResults.passed) {
console.log('🚨 Test suite failed')
process.exit(-1)
} else {
console.log('✅ Test suite passed')
process.exit(0)
}
39 changes: 1 addition & 38 deletions example/src/fabrice_latest_issues.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,8 @@
import 'dotenv/config'

import { httpTool } from '@fabrice-ai/tools/http'
import { agent } from 'fabrice-ai/agent'
import { solution } from 'fabrice-ai/solution'
import { teamwork } from 'fabrice-ai/teamwork'
import { logger } from 'fabrice-ai/telemetry'
import { workflow } from 'fabrice-ai/workflow'

const browser = agent({
description: `
You are skilled at browsing Web with specified URLs,
methods, params etc.
You are using "httpTool" to get the data from the API and/or Web pages.
`,
tools: {
httpTool,
},
})

const wrapupRedactor = agent({
description: `
Your role is to check Github project details and check for latest issues.
`,
})

const checkupGithubProject = workflow({
team: { browser, wrapupRedactor },
description: `
Check the project details for "fabrice-ai" using the following API URL:
"https://api.github.com/repos/callstackincubator/fabrice-ai".

From the data received get the number of stars and the URL for the listing the issues.
List last top 3 issues and the number of star gazers for the project.
`,
output: `
Comprehensive markdown report for fabrice-ai project:
- Include top 3 new issues.
- Include the actual number of star gazers.
`,
snapshot: logger,
})
import { checkupGithubProject } from './fabrice_latest_issues.config'

const result = await teamwork(checkupGithubProject)

Expand Down