import * as master from '@eui/automation/wdio.conf.js';
import EuiReporter from '@eui/automation/core/reporter/eui-reporter.js';
import testSuites from './suites.json' assert { type: "json" };
import tools from '@eui/tools/scripts/utils/tools.js';
const { vaultUser, vaultPassword } = tools.getArgs();

export const config = Object.assign(master.config, {
  vaultConfig: {
    endpoint: 'https://hcp.devops.tech.ec.europa.eu/v1',
    user: vaultUser,
    password: vaultPassword,
    namespace: '/EC/DIGIT_B3_CC_VAULT',
    testusersPath: '/kvccqa/test_users/'
  },
  screenshot: 'fail',  // never, fail or always
  saveScreenshotToJson: false,
  browserlog: 'always',  // never, fail or always
  baseUrl: 'https://tst.myworkplace.services.ec.europa.eu/mwp?1fa',
  specs: ['./tests/**/*.spec.js'],
  logLevel: 'error',
  suites: testSuites,
  maxInstances: 3,
  capabilities: [
    {
      browserName: "chrome",
      "goog:chromeOptions": {
        args: ['disable-infobars', '--window-size=1920,1080', '--incognito',
                '--proxy-pac-url=http://autoproxy.cec.eu.int/proxy.pac'],
      },
      "goog:loggingPrefs": { browser: "ALL", driver: "ALL", performance: "ALL" },
    },
  ],
  // Don't forget to set the following environment variables
  devtoolsProxyCredentials: {username: process.env.proxyuser, password: process.env.proxypassword},
  app: 'MWP',
  env: 'TST',
  userenv: 'ACC',
  testUsers: ['w0501057', 'w0501056'],
  automationProtocol:'devtools',
  services: [],
  puppeteerNetworkCapture: { saveResponse: true, captureMimeTypes: ['text/html', 'text/plain', 'application/json', 'text/event-stream'] }, //only works on local executions
  networkAdditionalChecks: {
    threshholds: {
      blocked: 1000,
      dns: 200,
      connect: 200,
      send: 2000,
      wait: 6000,
      receive: 4000,
      ssl: 200
    }
  },
  reporters: ['spec',
    ['allure', {
      outputDir: 'allure-results-tst',
      reportDir: 'allure-report-tst',
      cleanBefore: true,
      disableWebdriverStepsReporting: true,
      disableWebdriverScreenshotsReporting: false,
      openReport: true // CAREFULL, should be false when run on CI execution or other execution agent
    }],
    [EuiReporter, {
      loggerOptions: {
        reportDir: 'jsonReportTst'
      },
      publishers: []
    }]]
});
