Skip to content

Commit

Permalink
udpate test
Browse files Browse the repository at this point in the history
  • Loading branch information
m2rads committed Dec 16, 2024
1 parent ae98345 commit 4b82575
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/shortest/tests/test-ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { BrowserManager } from '../src/browser/manager';
import { getConfig, initialize } from '../src/index';
import type { TestFunction } from '../src/types/test';
import pc from 'picocolors';
import * as playwright from 'playwright';
import { request } from 'playwright';

async function testAI() {
console.log(pc.cyan('\n🧪 Testing AI Integration'));
Expand All @@ -17,6 +19,21 @@ async function testAI() {
const context = await browserManager.launch();
const page = context.pages()[0];

// Create playwright object with request context
const playwrightObj = {
...playwright,
request: {
...request,
newContext: async (options?: { extraHTTPHeaders?: Record<string, string> }) => {
const requestContext = await request.newContext({
baseURL: getConfig().baseUrl,
...options
});
return requestContext;
}
}
};

// Mock test data with callback
const mockTest: TestFunction = {
name: 'Test with callback',
Expand All @@ -38,6 +55,8 @@ async function testAI() {
height: 1080,
testContext: {
page,
browser: browserManager.getBrowser()!,
playwright: playwrightObj,
currentTest: mockTest,
currentStepIndex: 0
}
Expand All @@ -53,6 +72,8 @@ async function testAI() {
// Update test context for expectation callback
browserTool.updateTestContext({
page,
browser: browserManager.getBrowser()!,
playwright: playwrightObj,
currentTest: mockTest,
currentStepIndex: 1
});
Expand Down

0 comments on commit 4b82575

Please sign in to comment.