<commit_before>/**
 DOM selectors
*/

function callStackPane() {
  return cy.get(".call-stack-pane");
}

function callStackFrameAtIndex(index) {
  return callStackPane().find(".frames .frame").eq(index);
}

function breakpointPane() {
  return cy.get(".breakpoints-pane .breakpoints-list");
}

function breakpointAtIndex(index) {
  return breakpointPane().find(".breakpoint").eq(index);
}

function commandBar() {
  return cy.get(".right-sidebar .command-bar");
}

function sourceFooter() {
  return cy.get(".source-footer");
}

function scopesPane() {
  return cy.get(".scopes-pane");
}

function scopeAtIndex(index) {
  return scopesPane().find(".scopes-list > .tree").children().eq(index);
}
/**
  DOM commands
*/

/**
  1. load the debugger and connect to the first chrome or firefox tab
  2. cy.navigate the browser tab to the right rul
  3. refresh the debugger to guarantee the data is correct

  the test delays are safeguards for the timebeing, but they should
  be able to be removed if the test waits for the elements to appear.
 */
function debugPage(urlPart, browser = "Firefox") {
  debugFirstTab(browser);
  cy.wait(1000);
  cy.navigate(urlPart)
  cy.wait(1000);
  toggleCallStack();
  toggleScopes();
}

function debugFirstTab(browser = "Firefox") {
  cy.visit("http://localhost:8000");
  cy.get(`.${browser} .tab`).first().click();
}

function goToSource(source) {
  cy.window().then(win => {
    win.dispatchEvent(Object.assign(new Event("keydown"), {
      key: "p", metaKey: true, ctrlKey: false, altKey: false, shiftKey: false
    }))
  });

  cy.get(".autocomplete input").type(source)
  cy.get(".autocomplete .results li").first().click()
}

function toggleBreakpoint(linenumber) {
  cy.window().then(win => {
    cy.wrap(win.cm)
      .invoke("scrollIntoView", { line: linenumber, ch: 0 });
  });

  cy.get(".CodeMirror")
    .contains(".CodeMirror-linenumber", linenumber).click();
}

function addWatchExpression(expression) {
  cy.get(".input-expression").type(`${expression}{enter}`)
}

function selectBreakpointInList(index) {
  breakpointAtIndex(index).click();
}

function toggleBreakpointInList(index) {
  breakpointAtIndex(index).find("input[type='checkbox']").click();
}

function toggleCallStack() {
  callStackPane().find("._header").click();
}<commit_msg>Add key event toggling for different platforms<commit_after>/**
 DOM selectors
*/

function callStackPane() {
  return cy.get(".call-stack-pane");
}

function callStackFrameAtIndex(index) {
  return callStackPane().find(".frames .frame").eq(index);
}

function breakpointPane() {
  return cy.get(".breakpoints-pane .breakpoints-list");
}

function breakpointAtIndex(index) {
  return breakpointPane().find(".breakpoint").eq(index);
}

function commandBar() {
  return cy.get(".right-sidebar .command-bar");
}

function sourceFooter() {
  return cy.get(".source-footer");
}

function scopesPane() {
  return cy.get(".scopes-pane");
}

function scopeAtIndex(index) {
  return scopesPane().find(".scopes-list > .tree").children().eq(index);
}
/**
  DOM commands
*/

/**
  1. load the debugger and connect to the first chrome or firefox tab
  2. cy.navigate the browser tab to the right rul
  3. refresh the debugger to guarantee the data is correct

  the test delays are safeguards for the timebeing, but they should
  be able to be removed if the test waits for the elements to appear.
 */
function debugPage(urlPart, browser = "Firefox") {
  debugFirstTab(browser);
  cy.wait(1000);
  cy.navigate(urlPart)
  cy.wait(1000);
  toggleCallStack();
  toggleScopes();
}

function debugFirstTab(browser = "Firefox") {
  cy.visit("http://localhost:8000");
  cy.get(`.${browser} .tab`).first().click();
}

function keyEvent(key, cmdOrCtrl) {
  const isMac = window.navigator.userAgent.includes("Mac")
  return Object.assign(new Event("keydown"), {
    key,
    metaKey: cmdOrCtrl && isMac,
    ctrlKey: cmdOrCtrl && !isMac,
    altKey: false,
    shiftKey: false
  })
}

function goToSource(source) {
  cy.window().then(win => {
    win.dispatchEvent(keyEvent("p", true))
  });

  cy.get(".autocomplete input").type(source)
  cy.get(".autocomplete .results li").first().click()
}

function toggleBreakpoint(linenumber) {
  cy.window().then(win => {
    cy.wrap(win.cm)
      .invoke("scrollIntoView", { line: linenumber, ch: 0 });
  });

  cy.get(".CodeMirror")
    .contains(".CodeMirror-linenumber", linenumber).click();
}

function addWatchExpression(expression) {
  cy.get(".input-expression").type(`${expression}{enter}`)
}

function selectBreakpointInList(index) {
  breakpointAtIndex(index).click();
}

function toggleBreakpointInList(index) {
  breakpointAtIndex(index).find("input[type='checkbox']").click();
}

function toggleCallStack() {
  callStackPane().find("._header").click();
}
{'fraction_non_alphanumeric': 0.16453841323006071, 'fraction_numerical': 0.006698764915218757, 'mean_word_length': 4.5429234338747095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5553155', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1514, 'n_words': 332}