From cdeaaa54584a9db9f14e784c279d937125a4b193 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 9 Oct 2023 19:12:10 +0500 Subject: [PATCH] chore: fix test case --- common/static/common/js/karma.common.conf.js | 43 ++++++++++++++++++++ pavelib/utils/envs.py | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/common/static/common/js/karma.common.conf.js b/common/static/common/js/karma.common.conf.js index 274d4efa7e..09f6a21848 100644 --- a/common/static/common/js/karma.common.conf.js +++ b/common/static/common/js/karma.common.conf.js @@ -45,6 +45,7 @@ var appRoot = path.join(__dirname, '../../../../'); // eslint-disable-next-line import/no-extraneous-dependencies var webdriver = require('selenium-webdriver'); // eslint-disable-next-line import/no-extraneous-dependencies +var firefox = require('selenium-webdriver/firefox'); var webpackConfig = require(path.join(appRoot, 'webpack.dev.config.js')); @@ -296,6 +297,8 @@ function getBaseConfig(config, useRequireJs) { 'karma-requirejs', 'karma-junit-reporter', 'karma-coverage', + 'karma-chrome-launcher', + 'karma-firefox-launcher', 'karma-spec-reporter', 'karma-selenium-webdriver-launcher', 'karma-webpack', @@ -333,6 +336,46 @@ function getBaseConfig(config, useRequireJs) { // enable / disable watching file and executing tests whenever any file changes autoWatch: false, + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['FirefoxNoUpdates'], + + customLaunchers: { + // Firefox configuration that doesn't perform auto-updates + FirefoxNoUpdates: { + base: 'Firefox', + prefs: { + 'app.update.auto': false, + 'app.update.enabled': false + } + }, + ChromeDocker: { + base: 'SeleniumWebdriver', + browserName: 'chrome', + getDriver: function() { + return new webdriver.Builder() + .forBrowser('chrome') + .usingServer('http://edx.devstack.chrome:4444/wd/hub') + .build(); + } + }, + FirefoxDocker: { + base: 'SeleniumWebdriver', + browserName: 'firefox', + getDriver: function() { + var options = new firefox.Options(), + profile = new firefox.Profile(); + profile.setPreference('focusmanager.testmode', true); + options.setProfile(profile); + return new webdriver.Builder() + .forBrowser('firefox') + .usingServer('http://edx.devstack.firefox:4444/wd/hub') + .setFirefoxOptions(options) + .build(); + } + } + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index eca00713ea..20764a613e 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -85,7 +85,7 @@ class Env: # Test Ids Directory TEST_DIR = REPO_ROOT / ".testids" - # Configured browser to use for the js test suites + # Configured browser to use for the js test suites SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') if USING_DOCKER: KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker'