<commit_before>// Relative imports.
import { mockUser } from '@@profile/tests/fixtures/users/user.js';

Cypress.Commands.add('checkMenuItem', (selector, expectedPath) => {
  cy.get(selector).click();
  cy.location('pathname').should('eq', expectedPath);
  cy.go('back');
});

const testFirstMenuSection = isMobile => {
  cy.get('[data-e2e-id="vetnav-level2--disability"').should('not.exist');
  cy.get(`#mega-menu-${isMobile ? 'desktop' : 'mobile'} #vetnav`).should(
    'not.exist',
  );
  cy.get('[data-e2e-id="va-benefits-and-health-care-0"]').click();
  cy.get('[data-e2e-id="vetnav-level2--disability"]').click();
  cy.get('[data-e2e-id="view-all-in-disability"]');
  cy.get('[data-e2e-id="vetnav-column-one-header"]');
  cy.get('[data-e2e-id="eligibility-0"]');
  cy.get('[data-e2e-id="about-va-1"]');
  cy.checkMenuItem('[data-e2e-id="find-a-va-location-2"]', '/find-locations');
};

const testSecondMenuSection = isMobile => {
  cy.get('[data-e2e-id="vetnav-main-column-header"]').should('not.exist');
  cy.get(`#mega-menu-${isMobile ? 'desktop' : 'mobile'} #vetnav`).should(
    'not.exist',
  );
  cy.get('[data-e2e-id="about-va-1"]').click();
  cy.get('[data-e2e-id="vetnav-main-column-header"]').contains(
    'VA organizations',
  );
  cy.get('[data-e2e-id="veterans-health-administration-0"]');
  cy.get('[data-e2e-id="vetnav-column-one-header"]').contains(
    'Innovation at VA',
  );
  cy.get('[data-e2e-id="va-open-data-2"]');
  cy.get('[data-e2e-id="vetnav-column-two-header"]').contains('Learn about VA');
  cy.get('[data-e2e-id="veterans-legacy-program-4"]');
  cy.get('[data-e2e-id="agency-financial-report"]');
};

const testFindLocationsLink = () => {
  cy.get('[data-e2e-id="find-a-va-location-2"]')
    .should('have.attr', 'href')
    .and('include', 'find-locations');
};

const testMobileMenuSections = () => {
  cy.get('[data-e2e-id="about-va-1"]').should('not.be.visible');
  cy.get('#mega-menu-desktop #vetnav').should('not.exist');

  // Open the menu.
  cy.get('.vetnav-controller-open').contains('Menu');
  cy.get('.vetnav-controller-open').click();
  cy.get('.vetnav-controller-close').contains('Close');

  // Check the links to make sure they all look right.
  cy.findByTestId('mobile-home-nav-link');
  cy.get('[data-e2e-id="about-va-1"]').click();
  cy.get('[data-e2e-id="vetnav-level2--va-organizations"]').click();
  cy.get('[data-e2e-id="all-va-offices-and-organizations-6"]');<commit_msg>Add regex check for megamenu urls, add additional url checks (#18862)<commit_after>// Relative imports.
import { mockUser } from '@@profile/tests/fixtures/users/user.js';

Cypress.Commands.add(
  'checkMenuItem',
  (selector, expectedPath, parentMenuSelector = false) => {
    if (parentMenuSelector) {
      cy.get(parentMenuSelector).click();
    }
    cy.get(selector).click();
    cy.location('pathname').should('match', new RegExp(`^/${expectedPath}/?$`));
    cy.go('back');
  },
);

const testFirstMenuSection = isMobile => {
  cy.get('[data-e2e-id="vetnav-level2--disability"').should('not.exist');
  cy.get(`#mega-menu-${isMobile ? 'desktop' : 'mobile'} #vetnav`).should(
    'not.exist',
  );
  cy.get('[data-e2e-id="va-benefits-and-health-care-0"]').click();
  cy.get('[data-e2e-id="vetnav-level2--disability"]').click();
  cy.get('[data-e2e-id="view-all-in-disability"]');
  cy.get('[data-e2e-id="vetnav-column-one-header"]');
  cy.get('[data-e2e-id="eligibility-0"]');
  cy.get('[data-e2e-id="about-va-1"]');
  cy.checkMenuItem('[data-e2e-id="find-a-va-location-2"]', 'find-locations');
  cy.checkMenuItem(
    '[data-e2e-id="how-to-apply-1"]',
    'health-care/how-to-apply',
    '[data-e2e-id="va-benefits-and-health-care-0"]',
  );
  cy.checkMenuItem(
    '[data-e2e-id="family-and-caregiver-health-benefits-2"]',
    'health-care/family-caregiver-benefits',
    '[data-e2e-id="va-benefits-and-health-care-0"]',
  );
  cy.checkMenuItem(
    '[data-e2e-id="view-your-lab-and-test-results-3"]',
    'health-care/view-test-and-lab-results',
    '[data-e2e-id="va-benefits-and-health-care-0"]',
  );
};

const testSecondMenuSection = isMobile => {
  cy.get('[data-e2e-id="vetnav-main-column-header"]').should('not.exist');
  cy.get(`#mega-menu-${isMobile ? 'desktop' : 'mobile'} #vetnav`).should(
    'not.exist',
  );
  cy.get('[data-e2e-id="about-va-1"]').click();
  cy.get('[data-e2e-id="vetnav-main-column-header"]').contains(
    'VA organizations',
  );
  cy.get('[data-e2e-id="veterans-health-administration-0"]');
  cy.get('[data-e2e-id="vetnav-column-one-header"]').contains(
    'Innovation at VA',
  );
  cy.get('[data-e2e-id="va-open-data-2"]');
  cy.get('[data-e2e-id="vetnav-column-two-header"]').contains('Learn about VA');
  cy.get('[data-e2e-id="veterans-legacy-program-4"]');
  cy.get('[data-e2e-id="agency-financial-report"]');
  cy.get('[data-e2e-id="about-va-1"]').click();

  cy.checkMenuItem(
    '[data-e2e-id="veterans-health-administration-0"]',
    'health',
    '[data-e2e-id="about-va-1"]',
  );
  cy.checkMenuItem(
    '[data-e2e-id="va-plans-budget-and-performance-2"]',
    'performance',
    '[data-e2e-id="about-va-1"]',
  );
};

const testFindLocationsLink = () => {
  cy.get('[data-e2e-id="find-a-va-location-2"]')
    .should('have.attr', 'href')
    .and('include', 'find-locations');
};

const testMobileMenuSections = () => {
  cy.get('[data-e2e-id="about-va-1"]').should('not.be.visible');
  cy.get('#mega-menu-desktop #vetnav').should('not.exist');

  // Open the menu.
  cy.get('.vetnav-controller-open').contains('Menu');
  cy.get('.vetnav-controller-open').click();
  cy.get('.vetnav-controller-close').contains('Close');

  // Check the links to make sure they all look right.
  cy.findByTestId('mobile-home-nav-link');
  cy.get('[data-e2e-id="about-va-1"]').click();
  cy.get('[data-e2e-id="vetnav-level2--va-organizations"]').click();
  cy.get('[data-e2e-id="all-va-offices-and-organizations-6"]');
{'fraction_non_alphanumeric': 0.25483870967741934, 'fraction_numerical': 0.017147707979626486, 'mean_word_length': 4.297661870503597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5711400', 'n_tokens_mistral': 2413, 'n_tokens_neox': 2376, 'n_words': 211}