<commit_before>const {
  notifications,
  workflowStatus,
  editorStatus,
  publishTypes,
  colorError,
  colorNormal,
  textColorNormal,
} = require('./constants');

function login(user) {
  cy.viewport(1200, 1200);
  if (user) {
    cy.visit('/', {
      onBeforeLoad: () => {
        // https://github.com/cypress-io/cypress/issues/1208
        window.indexedDB.deleteDatabase('localforage');
        window.localStorage.setItem('netlify-cms-user', JSON.stringify(user));
        if (user.netlifySiteURL) {
          window.localStorage.setItem('netlifySiteURL', user.netlifySiteURL);
        }
      },
    });
    if (user.netlifySiteURL && user.email && user.password) {
      cy.get('input[name="email"]')
        .clear()
        .type(user.email);
      cy.get('input[name="password"]')
        .clear()
        .type(user.password);
      cy.contains('button', 'Login').click();
    }
  } else {
    cy.visit('/');
    cy.contains('button', 'Login').click();
  }
  cy.contains('a', 'New Post');
}

function assertNotification(message) {
  cy.get('.notif__container').within(() => {
    cy.contains(message);
    // eslint-disable-next-line cypress/no-unnecessary-waiting
    cy.wait(500);
    cy.contains(message).invoke('hide');
  });
}

function assertColorOn(cssProperty, color, opts) {
  if (opts.type && opts.type === 'label') {
    (opts.scope ? opts.scope : cy).contains('label', opts.label).should($el => {
      expect($el).to.have.css(cssProperty, color);
    });
  } else if (opts.type && opts.type === 'field') {
    const assertion = $el => expect($el).to.have.css(cssProperty, color);
    if (opts.isMarkdown) {
      (opts.scope ? opts.scope : cy)
        .contains('label', opts.label)
        .next()
        .children()
        .eq(0)
        .children()
        .eq(1)
        .should(assertion);
    } else {
      (opts.scope ? opts.scope : cy)
        .contains('label', opts.label)
        .next()
        .should(assertion);
    }
  } else if (opts.el) {
    opts.el.should($el => {
      expect($el).to.have.css(cssProperty, color);
    });
  }
}

function exitEditor() {
  cy.contains('a', 'Writing in').click();
}

function goToWorkflow() {
  cy.contains('a', 'Workflow').click();
}

function goToCollections() {
  cy.contains('a', 'Content').click();
}

function goToMediaLibrary() {
  cy.contains('button', 'Media').click();
}

function assertUnpublishedEntryInEditor() {
  cy.contains('button', 'Delete unpublished entry');
}

function assertPublishedEntryInEditor() {
  cy.contains('button', 'Delete published entry');
}

function assertUnpublishedChangesInEditor() {
  cy.contains('button', 'Delete unpublished changes');
}

function goToEntry(entry) {
  goToCollections();
  cy.get('a h2')
    .first()
    .contains(entry.title)
    .click();
}

function updateWorkflowStatus({ title }, fromColumnHeading, toColumnHeading) {
  cy.contains('h2', fromColumnHeading)
    .parent()
    .contains('a', title)
    .drag();
  cy.contains('h2', toColumnHeading)
    .parent()
    .drop();
  assertNotification(notifications.updated);
}

function publishWorkflowEntry({ title }, timeout) {
  cy.contains('h2', workflowStatus.ready, { timeout })
    .parent()
    .within(() => {
      cy.contains('a', title)
        .parent()
        .within(() => {
          cy.contains('button', 'Publish new entry').click({ force: true });
        });
    });
  assertNotification(notifications.published);
}

function deleteWorkflowEntry({ title }) {
  cy.contains('a', title)
    .parent()
    .within(() => {
      cy.contains('button', 'Delete new entry').click({ force: true });
    });

  assertNotification(notifications.deletedUnpublished);
}

const STATUS_BUTTON_TEXT = 'Status:';

function assertWorkflowStatusInEditor(status) {
  cy.contains('[role="button"]', STATUS_BUTTON_TEXT).as('setStatusButton');
  cy.get('@setStatusButton')
    .parent()
    .within(() => {
      cy.get('@setStatusButton').click();
      cy.contains('[role="menuitem"] span', status)
        .parent()<commit_msg>chore(ci): fix tests (#6244)<commit_after>const {
  notifications,
  workflowStatus,
  editorStatus,
  publishTypes,
  colorError,
  colorNormal,
  textColorNormal,
} = require('./constants');

function login(user) {
  cy.viewport(1200, 1200);
  if (user) {
    cy.visit('/', {
      onBeforeLoad: () => {
        // https://github.com/cypress-io/cypress/issues/1208
        window.indexedDB.deleteDatabase('localforage');
        window.localStorage.setItem('netlify-cms-user', JSON.stringify(user));
        if (user.netlifySiteURL) {
          window.localStorage.setItem('netlifySiteURL', user.netlifySiteURL);
        }
      },
    });
    if (user.netlifySiteURL && user.email && user.password) {
      cy.get('input[name="email"]')
        .clear()
        .type(user.email);
      cy.get('input[name="password"]')
        .clear()
        .type(user.password);
      cy.contains('button', 'Login').click();
    }
  } else {
    cy.visit('/');
    cy.contains('button', 'Login').click();
  }
  cy.contains('a', 'New Post');
}

function assertNotification(message) {
  cy.get('.notif__container').within(() => {
    cy.contains(message);
    // eslint-disable-next-line cypress/no-unnecessary-waiting
    cy.wait(500);
    cy.contains(message).invoke('hide');
  });
}

function assertColorOn(cssProperty, color, opts) {
  if (opts.type && opts.type === 'label') {
    (opts.scope ? opts.scope : cy).contains('label', opts.label).should($el => {
      expect($el).to.have.css(cssProperty, color);
    });
  } else if (opts.type && opts.type === 'field') {
    const assertion = $el => expect($el).to.have.css(cssProperty, color);
    if (opts.isMarkdown) {
      (opts.scope ? opts.scope : cy)
        .contains('label', opts.label)
        .next()
        .children()
        .eq(0)
        .children()
        .eq(1)
        .should(assertion);
    } else {
      (opts.scope ? opts.scope : cy)
        .contains('label', opts.label)
        .next()
        .should(assertion);
    }
  } else if (opts.el) {
    opts.el.should($el => {
      expect($el).to.have.css(cssProperty, color);
    });
  }
}

function exitEditor() {
  cy.contains('a', 'Writing in').click();
}

function goToWorkflow() {
  cy.contains('a', 'Workflow').click();
}

function goToCollections() {
  cy.contains('a', 'Content').click();
}

function goToMediaLibrary() {
  cy.contains('button', 'Media').click();
}

function assertUnpublishedEntryInEditor() {
  cy.contains('button', 'Delete unpublished entry');
}

function assertPublishedEntryInEditor() {
  cy.contains('button', 'Delete published entry');
}

function assertUnpublishedChangesInEditor() {
  cy.contains('button', 'Delete unpublished changes');
}

function goToEntry(entry) {
  goToCollections();
  cy.get('a h2')
    .first()
    .contains(entry.title)
    .click();
}

function updateWorkflowStatus({ title }, fromColumnHeading, toColumnHeading) {
  cy.contains('h2', fromColumnHeading)
    .parent()
    .contains('a', title)
    .drag();
  cy.contains('h2', toColumnHeading)
    .parent()
    .drop();
  assertNotification(notifications.updated);
}

function publishWorkflowEntry({ title }, timeout) {
  cy.contains('h2', workflowStatus.ready, { timeout })
    .parent()
    .within(() => {
      cy.contains('a', title)
        .parent()
        .within(() => {
          cy.contains('button', 'Publish new entry').click({ force: true });
        });
    });
  // assertNotification(notifications.published);
}

function deleteWorkflowEntry({ title }) {
  cy.contains('a', title)
    .parent()
    .within(() => {
      cy.contains('button', 'Delete new entry').click({ force: true });
    });

  assertNotification(notifications.deletedUnpublished);
}

const STATUS_BUTTON_TEXT = 'Status:';

function assertWorkflowStatusInEditor(status) {
  cy.contains('[role="button"]', STATUS_BUTTON_TEXT).as('setStatusButton');
  cy.get('@setStatusButton')
    .parent()
    .within(() => {
      cy.get('@setStatusButton').click();
      cy.contains('[role="menuitem"] span', status)
        .parent()
{'fraction_non_alphanumeric': 0.18423010166129433, 'fraction_numerical': 0.005702950657079098, 'mean_word_length': 3.173305742369374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '1741294', 'n_tokens_mistral': 2633, 'n_tokens_neox': 2590, 'n_words': 424}