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

export const config = Object.assign(master.config, {
  screenshot: 'fail',  // never, fail or always
  browserlog: 'always',  // never, fail or always
  baseUrl: 'https://eui.ecdevops.eu/',
  specs: ['./packages/eui-automation/tests/**/*.spec.js'],
  logLevel: 'error',
  suites: testSuites,
  maxInstances: 15,
  capabilities: [
    {
      browserName: 'chrome',
      'goog:chromeOptions': {
        args: ['disable-infobars', 'headless', 'window-size=1920,1080', 'incognito'],
        // args: ['disable-infobars', '--window-size=1920,1080', '--incognito'],
      },
      "goog:loggingPrefs": { browser: "ALL", driver: "ALL", performance: "ALL" },
    },
  ],
  env: 'INT',
  window_width: 1920,
  window_height: 1080,
  // set below flag to true to enable wdioImageComparison code in eUI tests
  useWdioImageComparison: true,
  automationProtocol:'webdriver',
  services: [
  ['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',
    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'
    },
    publishers: [
      {
        type:ZephyrPublisher,
        config:{
          publish: 'never',  // never, fail or always
          username: jiraUser,
          password: jiraPassword,
          baseUrl: 'https://webgate.ec.europa.eu/CITnet/jira',
          zapiUrl: '/rest/zapi/latest',
          projectKey: 'CCQA',
          boardId: '4414',
          onlyPublishFailures: true,
          deleteOldReports: true,
          keepMonthsHistoryNbr:3
        }
      }
    ]
  }]]
});


