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
  },
  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: 4,
  bail: 3,
  capabilities: [
    {
      browserName: "chrome",
      version: "latest",
      platform: 'Windows 10',
      name: "MWP - Saucelabs - CHROME",
      screenResolution: "1920x1080",
      "chromeOptions": {
        args: ['headless', 'window-size=1920,1080', 'disable-infobars', 'ignore-gpu-blacklist', 'test-type', 'disable-gpu'],
        // args: ['start-maximized', 'disable-infobars', 'ignore-gpu-blacklist', 'test-type', 'disable-gpu'],
      },
      // "goog:loggingPrefs": { browser: "ALL", driver: "ALL", performance: "ALL" },
      maxDuration: 5400,
      idleTimeout: 120
    },
  ],
  app: 'MWP',
  env: 'DEV',
  //SAUCE
  user: process.env.SAUCE_USERNAME,
  key: process.env.SAUCE_ACCESS_KEY,
  region: 'eu',
  useWdioImageComparison: true,
  services: ['sauce', ['image-comparison', {
    // Some options, see the docs for more
    baselineFolder: join(process.cwd(), IMAGE_FOLDER_PREFIX),
    formatImageName: '{tag}-{logName}-{width}x{height}',
    screenshotPath: join(process.cwd(), '.tmp/'),
    savePerInstance: true,
    autoSaveBaseline: true,
    blockOutStatusBar: true,
    blockOutToolBar: true,
    // NOTE: When you are testing a hybrid app please use this setting
    isHybridApp: true,
  }]],
  reporters: ['spec',
    ['allure', {
      outputDir: 'allure-results-dev-sauce',
      reportDir: 'allure-report-dev-sauce',
      cleanBefore: true,
      disableWebdriverStepsReporting: true,
      disableWebdriverScreenshotsReporting: false,
      openReport: true // CAREFULL, should be false when run on CI execution or other execution agent
    }],
    [EuiReporter, {
      loggerOptions: {
        reportDir: 'jsonReport'
      }
    }]]
});


