/* eslint-disable @department-of-veterans-affairs/axe-check-required */
import manifest from '../../manifest.json';
import { proxyRewriteWhitelist as allowList } from '../../proxy-rewrite-whitelist.json';

describe(manifest.appName, () => {
  // Skip tests unless we are running the daily workflow job
  // eslint-disable-next-line func-names
  before(function() {
    if (Cypress.env('RUN_INJECTION') !== true) this.skip();
  });

  it('Should not inject header & footer on non-allowed host', () => {
    const hostToEval = 'www.innovation.va.gov';
    const isAllowed = allowList.some(item => item.hostname === hostToEval);

    if (!isAllowed) {
      cy.visit(`https://${hostToEval}`);
      cy.get('.consolidated > header').should('not.exist');
      cy.get('.consolidated > footer').should('not.exist');
    } else {
      throw new Error('Evaluated hostname is allowed.');
    }
  });

  it('Should not inject header & footer on allowed hosts that are cookie-only', () => {
    const hostToEval = 'www.volunteer.va.gov';
    const listItem = allowList.find(item => item.hostname === hostToEval);
    const { cookieOnly } = listItem;

    if (cookieOnly) {
      cy.visit(`https://${hostToEval}`);
      cy.get('.consolidated > header').should('not.exist');
      cy.get('.consolidated > footer').should('not.exist');
    } else {
      throw new Error(
        'Evaluated hostname is not allowed or is not cookie-only.',
      );
    }
  });

  it('Should inject header & footer on allowed hosts that are not cookie-only', () => {
    const hostToEval = 'www.benefits.va.gov';
    const listItem = allowList.find(item => item.hostname === hostToEval);
    const { cookieOnly } = listItem;

    if (!cookieOnly) {
      cy.visit(`https://${hostToEval}`);
      cy.get('.consolidated > header').should('exist');
      cy.get('.consolidated > footer').should('exist');
    } else {
      throw new Error('Evaluated hostname is not allowed or is cookie-only.');
    }
  });
});

@@ -1563,16 +1563,14 @@
 www.
-benef
+ea.o
 it
-s
 .va.

Update proxy rewrite e2e testing for stability (#21827)