import { normal, slow } from 'platform/testing/e2e/timeouts';
import { createE2eTest, baseUrl } from 'platform/testing/e2e/helpers';

const visitorPass = {
  title: 'Visitor pass',
  questions: [
    { id: 'question-isStaff', value: 'no' },
    { id: 'question-fever', value: 'no' },
    { id: 'question-cough', value: 'no' },
    { id: 'question-flu', value: 'no' },
    { id: 'question-congestion', value: 'no' },
    { id: 'question-exposure', value: 'no' },
  ],
  result: {
    class: 'covid-screener-results-pass',
  },
};

const visitorScreening = {
  title: 'Visitor needs more screening',
  questions: [
    { id: 'question-isStaff', value: 'no' },
    { id: 'question-fever', value: 'no' },
    { id: 'question-cough', value: 'yes' },
    { id: 'question-flu', value: 'no' },
    { id: 'question-congestion', value: 'no' },
    { id: 'question-exposure', value: 'no' },
  ],
  result: {
    class: 'covid-screener-results-more-screening',
  },
};

const staffPass = {
  title: 'Staff pass',
  questions: [
    { id: 'question-isStaff', value: 'yes' },
    { id: 'question-fever', value: 'no' },
    { id: 'question-cough', value: 'no' },
    { id: 'question-flu', value: 'no' },
    { id: 'question-congestion', value: 'no' },
    { id: 'question-exposure-staff', value: 'no' },
  ],
  result: {
    class: 'covid-screener-results-pass',
  },
};

const staffScreening = {
  title: 'Staff needs more screening',
  questions: [
    { id: 'question-isStaff', value: 'yes' },
    { id: 'question-fever', value: 'no' },
    { id: 'question-cough', value: 'no' },
    { id: 'question-flu', value: 'no' },
    { id: 'question-congestion', value: 'no' },
    { id: 'question-exposure-staff', value: 'yes' },
  ],
  result: {
    class: 'covid-screener-results-more-screening',
  },
};

function testQuestionScenario({ scenario, client }) {
  client.refresh().waitForElementVisible('body', normal);
  scenario.questions.forEach(question => {
    client
      .waitForElementVisible(`div[id=${question.id}]`, slow)
      .assert.visible(`div[id=${question.id}]`)
      // extra click workaround for https://github.com/nightwatchjs/nightwatch/issues/1221
      .click(`div[id=${question.id}] > button[value=${question.value}]`)
      .click(`div[id=${question.id}] > button[value=${question.value}]`);
  });
  client
    .waitForElementVisible(`div[class*=${scenario.result.class}]`, slow)
    .assert.visible(`div[class*=${scenario.result.class}]`, scenario.title);
}

export default createE2eTest(client => {
  client
    .url(`${baseUrl}/covid19screen`)
    .waitForElementVisible('body', normal)
    .assert.visible('div[id=question-isStaff]')
    .assert.visible('div[class*=covid-screener-results-incomplete]')
    .axeCheck('.main');

  // visitor passing answers
  testQuestionScenario({ scenario: visitorPass, client });

  // visitor needs more screening
  testQuestionScenario({ scenario: visitorScreening, client });

  // staff passing answers
  testQuestionScenario({ scenario: staffPass, client });

  // staff needs more screening
  testQuestionScenario({ scenario: staffScreening, client });
});

@@ -2756,32 +2756,35 @@
 assing answers%0A 
+ //
  testQuestionSce
@@ -2822,24 +2822,50 @@
 client %7D);%0A%0A
+  // TODO: reenable tests%0A
   // visitor
@@ -2879,32 +2879,35 @@
 more screening%0A 
+ //
  testQuestionSce
@@ -2982,16 +2982,19 @@
 nswers%0A 
+ //
  testQue
@@ -3075,16 +3075,19 @@
 eening%0A 
+ //
  testQue

Disable coronavirus screener e2e tests (#13015)