import { describe, it, beforeAll, afterAll } from 'vitest';
import TestDriver from 'testdriverai';
import {
runPrerunChromeExtension,
runPostrun
} from 'testdriverai/testdriver/acceptance-sdk/setup/lifecycleHelpers.mjs';
describe('Chrome Extension Testing', () => {
let client;
let dashcamUrl;
beforeAll(async () => {
client = await TestDriver.create({
apiKey: process.env.TD_API_KEY,
os: "linux",
verbosity: 1,
});
// Load uBlock Origin extension
await runPrerunChromeExtension(client, "cjpalhdlnbpafiamejdnhcphjbkeiagm");
});
afterAll(async () => {
if (client) {
dashcamUrl = await runPostrun(client);
await client.cleanup();
}
});
it('should verify extension is loaded', async () => {
await client.focusApplication("Google Chrome");
// Navigate to a page
const element = await client.find("TestDriver.ai Sandbox");
expect(element.found()).toBe(true);
// Test extension-specific functionality
// For example, checking if ads are blocked with uBlock
});
it('should access extension popup', async () => {
await client.focusApplication("Google Chrome");
// Open extension management
await client.exec(
"sh",
`xdotool key --clearmodifiers ctrl+shift+e`,
5000,
true
);
// Wait for extensions page
await new Promise((resolve) => setTimeout(resolve, 2000));
});
});