Initial commit

This commit is contained in:
Aditya Gupta
2026-06-29 19:29:19 +05:30
committed by GitHub
commit aabb8986aa
292 changed files with 17976 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
import { config as baseConfig } from './wdio.conf.js';
import { getChromeExtensionPath, getFirefoxExtensionPath } from '../utils/extension-path.js';
import { IS_CI, IS_FIREFOX } from '@extension/env';
import { readdir, readFile } from 'node:fs/promises';
import { extname, join } from 'node:path';
const extName = IS_FIREFOX ? '.xpi' : '.zip';
const extensions = await readdir(join(import.meta.dirname, '../../../dist-zip'));
const latestExtension = extensions.filter(file => extname(file) === extName).at(-1);
const extPath = join(import.meta.dirname, `../../../dist-zip/${latestExtension}`);
const bundledExtension = (await readFile(extPath)).toString('base64');
const chromeCapabilities = {
browserName: 'chrome',
acceptInsecureCerts: true,
'goog:chromeOptions': {
args: [
'--disable-web-security',
'--disable-gpu',
'--no-sandbox',
'--disable-dev-shm-usage',
...(IS_CI ? ['--headless'] : []),
],
prefs: { 'extensions.ui.developer_mode': true },
extensions: [bundledExtension],
},
};
const firefoxCapabilities = {
browserName: 'firefox',
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: [...(IS_CI ? ['--headless'] : [])],
},
};
export const config: WebdriverIO.Config = {
...baseConfig,
capabilities: IS_FIREFOX ? [firefoxCapabilities] : [chromeCapabilities],
maxInstances: IS_CI ? 10 : 1,
logLevel: 'error',
execArgv: IS_CI ? [] : ['--inspect'],
before: async ({ browserName }: WebdriverIO.Capabilities, _specs, browser: WebdriverIO.Browser) => {
if (browserName === 'firefox') {
await browser.installAddOn(bundledExtension, true);
browser.addCommand('getExtensionPath', async () => getFirefoxExtensionPath(browser));
} else if (browserName === 'chrome') {
browser.addCommand('getExtensionPath', async () => getChromeExtensionPath(browser));
}
},
afterTest: async () => {
if (!IS_CI) {
await browser.pause(500);
}
},
};

View File

@@ -0,0 +1,97 @@
/**
* WebdriverIO v9 configuration file
* https://webdriver.io/docs/configurationfile
*/
export const config: WebdriverIO.Config = {
runner: 'local',
tsConfigPath: '../tsconfig.json',
//
// ==================
// Specify Test Files
// ==================
// Define which test specs should run. The pattern is relative to the directory
// of the configuration file being run.
//
// The specs are defined as an array of spec files (optionally using wildcards
// that will be expanded). The test for each spec file will be run in a separate
// worker process. In order to have a group of spec files run in the same worker
// process simply enclose them in an array within the specs array.
//
// The path of the spec files will be resolved relative from the directory
// of the config file unless it's absolute.
specs: ['../specs/**/*.ts'],
// Patterns to exclude.
exclude: [],
//
// ============
// Capabilities
// ============
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
// time. Depending on the number of capabilities, WebdriverIO launches several test
// sessions. Within your capabilities you can overwrite the spec and exclude options in
// order to group specific specs to a specific capability.
//
// First, you can define how many instances should be started at the same time. Let's
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
// files and you set maxInstances to 10, all spec files will get tested at the same time
// and 30 processes will get spawned. The property handles how many capabilities
// from the same test should run tests.
//
maxInstances: 10,
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://saucelabs.com/platform/platform-configurator
//
capabilities: [],
//
// ===================
// Test Configurations
// ===================
// Define all options that are relevant for the WebdriverIO instance here
//
// Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'info',
//
// If you only want to run your tests until a specific amount of tests have failed use
// bail (default is 0 - don't bail, run all tests).
bail: 0,
//
// Default timeout for all waitFor* commands.
waitforTimeout: 10000,
//
// Default timeout in milliseconds for request
// if browser driver or grid doesn't send response
connectionRetryTimeout: 120000,
//
// Default request retries count
connectionRetryCount: 3,
//
// Framework you want to run your specs with.
// The following are supported: Mocha, Jasmine, and Cucumber
// see also: https://webdriver.io/docs/frameworks
//
// Make sure you have the wdio adapter package for the specific framework installed
// before running any tests.
framework: 'mocha',
//
// Test reporter for stdout.
// The only one supported by default is 'dot'
// see also: https://webdriver.io/docs/dot-reporter
reporters: ['spec'],
// Options to be passed to Mocha.
// See the full list at http://mochajs.org/
mochaOpts: {
ui: 'bdd',
timeout: 60000,
},
};

7
tests/e2e/config/wdio.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
declare namespace WebdriverIO {
interface Browser extends WebdriverIO.Browser {
getExtensionPath: () => Promise<string>;
installAddOn: (extension: string, temporary: boolean) => Promise<void>;
addCommand: (name: string, func: () => Promise<string>) => void;
}
}