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

export const config = Object.assign(master.config, {
  vaultConfig: {
    endpoint: 'https://vault.compasscorporate.eu/v1',
    user: vaultUser,
    password: vaultPassword
  },
  monitorMonitorConfig: {
    nodemailerTransportOptions: {
      host: 'SMTPMAIL.cec.eu.int',
      port: 25,
      secure: false,
      tls: { rejectUnauthorized: false }
    },
    checkSources: [
      {
        type: "es",
        sourceConfig: {
          protocol: 'https',
          host: 'es.acceptance.tech.ec.europa.eu',
          port: '9200',
          index: 'mwp',
          vaultConfig: {
            path: "/secret/functional/elasticsearch",
            key: "default",
          }
        },
        checks: [
          {
            type: "recent-entry",
            moreThen: 1, //minutes
            query: "logentrytype:\"testCycle\"",
            index: "mwp-int-moni-*",
            sort: "start:desc",
            monitoredSystem: "INT monitor",
            dashboardLink: "https://kibana.tech.ec.europa.eu/app/dashboards#/view/c21ada20-1458-11ec-b0e0-eb94a1ed7faa",
            mails: [
              {
                from: "automated-notifications@nomail.ec.europa.eu",
                to: "", // list of receivers
                bcc: "jan.verhulst@ext.ec.europa.eu",
              }
            ]
          }
        ]
      }
    ]
  },
  runner: 'local',
  protocol: 'http',
  hostname: 'seleniumhub-dev.cc.cec.eu.int',
  port: 5555,
  path: '/wd/hub',
  screenshot: 'fail',  // never, fail or always
  browserlog: 'always',  // never, fail or always
  baseUrl: 'https://euidev.ecdevops.eu/',
  specs: ['./packages/eui-automation/tests/**/*.spec.js'],
  logLevel: 'error',
  suites: testSuites,
  maxInstances: 2,
  bail: 3,
  capabilities: [
    {
      browserName: "chrome",
      platformName: 'WINDOWS',
      "goog:chromeOptions": {
        args: ['disable-infobars', '--window-size=1920,1080', '--incognito', '--headless=chrome'],
      },
      "goog:loggingPrefs": { browser: "ALL", driver: "ALL", performance: "ALL" },
    },
  ],
  app: 'EUI',
  env: 'DEV',
  services: [],
  reporters: ['spec',
    ['allure', {
      outputDir: 'allure-results-dev-sauce',
      reportDir: 'allure-report-dev-sauce',
      cleanBefore: true,
      disableWebdriverStepsReporting: true,
      disableWebdriverScreenshotsReporting: false,
      openReport: false // CAREFULL, should be false when run on CI execution or other execution agent
    }],
    [EuiReporter, {
      loggerOptions: {
        reportDir: 'jsonReport'
      }
    }]]
});


