import { describe, it, expect } from 'vitest';
import { TestDriver } from 'testdriverai/vitest/hooks';
describe('Chrome Extension - Hello World', () => {
it('should load extension and verify popup', async (context) => {
const testdriver = TestDriver(context, {
headless: true,
newSandbox: true,
cacheKey: 'chrome-extension-test'
});
// Clone the Chrome extensions samples repo
await testdriver.exec(
'sh',
'git clone --depth 1 https://github.com/GoogleChrome/chrome-extensions-samples.git /tmp/chrome-extensions-samples',
60000,
true
);
// Launch Chrome with the hello-world extension loaded
await testdriver.provision.chromeExtension({
extensionPath: '/tmp/chrome-extensions-samples/functional-samples/tutorial.hello-world',
url: 'https://testdriver.ai'
});
// Verify the page loaded
const pageResult = await testdriver.assert("the testdriver.ai website is visible");
expect(pageResult).toBeTruthy();
// Click on the extensions button in Chrome toolbar
const extensionsButton = await testdriver.find("Extensions button, puzzle piece icon in Chrome toolbar");
await extensionsButton.click();
// Find and click the hello world extension
const helloExtension = await testdriver.find("Hello World extension in the extensions dropdown");
await helloExtension.click();
// Verify the extension popup shows
const popupResult = await testdriver.assert("a popup shows with the text 'Hello Extensions'");
expect(popupResult).toBeTruthy();
});
});