mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-16 10:06:17 -05:00
## Description > Should include a concise description of the changes (bug or feature), it's > impact, along with a summary of the solution ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
// Copyright 2025 Google LLC
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
import { describe, test, before, after } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "fs";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const ORCH_NAME = process.env.ORCH_NAME;
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const orchDir = path.join(__dirname, ORCH_NAME);
|
|
const quickstartPath = path.join(orchDir, "quickstart.js");
|
|
|
|
const { main: runAgent } = await import(quickstartPath);
|
|
|
|
const GOLDEN_KEYWORDS = ["Hilton Basel", "Hyatt Regency", "book"];
|
|
|
|
describe(`${ORCH_NAME} Quickstart Agent`, () => {
|
|
let capturedOutput = [];
|
|
let originalLog;
|
|
|
|
before(() => {
|
|
originalLog = console.log;
|
|
console.log = (msg) => {
|
|
capturedOutput.push(msg);
|
|
};
|
|
});
|
|
|
|
after(() => {
|
|
console.log = originalLog;
|
|
});
|
|
|
|
test("outputContainsRequiredKeywords", async () => {
|
|
capturedOutput = [];
|
|
await runAgent();
|
|
const actualOutput = capturedOutput.join("\n");
|
|
|
|
assert.ok(
|
|
actualOutput.length > 0,
|
|
"Assertion Failed: Script ran successfully but produced no output."
|
|
);
|
|
|
|
const missingKeywords = [];
|
|
for (const keyword of GOLDEN_KEYWORDS) {
|
|
if (!actualOutput.toLowerCase().includes(keyword.toLowerCase())) {
|
|
missingKeywords.push(keyword);
|
|
}
|
|
}
|
|
|
|
assert.ok(
|
|
missingKeywords.length === 0,
|
|
`Assertion Failed: The following keywords were missing from the output: [${missingKeywords.join(", ")}]`
|
|
);
|
|
});
|
|
}); |