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()


export const config = Object.assign(master.config, {
  screenshot: 'always',  // 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: {
    e2e: [
      // test is flaky but I don't have time to investigate now
      './packages/eui-automation/tests/eUIcomponent/navigate-to-showcase.spec.js',
      // TOBE Fixed for mobile './packages/eui-automation/tests/eUIcomponent/ux-card.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-a-date-tag.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-switch.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-dashboard-card.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-alert.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-a-icon.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-a-icon-box.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-a-icon-toggle.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-badge.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-badge-group.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-dashboard-button.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-a-toolbar-filter.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-list-item.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-a-tag.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-a-marker.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-growl.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-disable-content.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-button.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-block-content.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-layout-horizontal.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-layout-overlay-panel.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-a-label.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-layout-footer-action-bar.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-layout-page-header.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-block-document.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-fieldset.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-action-box.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-modal.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-overlay.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-button-group.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-dropdown-button.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-control-feedback.spec.js',
      './packages/eui-automation/tests/eUIcomponent/ux-notifications.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-dropdown-tree.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-dynamic-popover.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-dynamic-modal.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-field-search.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-tree-list.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-tree.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-form-group.spec.js',
      // TOBE Fixed for mobile'./packages/eui-automation/tests/eUIcomponent/ux-panel.spec.js'

    ]
  },
  maxInstances: 8,
  capabilities: [
    {
      // deviceName: 'iPhone Simulator',
      deviceName: 'Android Emulator',
      deviceOrientation: 'portrait',
      // browserName: 'Safari',
      browserName: 'Chrome',
      // platformVersion: '14.3',
      platformVersion: '8.0',
      platformName: 'Android',
      name: "EUI - Android - CHROME",
      // name: "EUI - iPhone - iOS 14.3 - Safari",
      shardTestFiles: false,
      maxInstances: 8,
      maxDuration: 5400
    },
  ],
  env: 'INT',
  window_width: 1920,
  window_height: 1080,
  useWdioImageComparison: false,
  //SAUCE
  user: process.env.SAUCE_USERNAME,
  key: process.env.SAUCE_ACCESS_KEY,
  region: 'eu',
  services: ['sauce'],
  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
        }
      }
    ]
  }]]
});


