recordedStepLine function ✓ 100.0%

Last updated: 2026-03-01T23:25:47.083Z

Metrics

LOC: 50 Complexity: 31 Params: 3 Coverage: 100.0% (20/20 lines, 31x executed)

Signature

recordedStepLine( step: RecordedStep, useSmartSelectors: boolean, ): : string

Architecture violations

View all

  • [warning] max-cyclomatic-complexity: 'recordedStepLine' has cyclomatic complexity 31 (max 10)

Source Code

function recordedStepLine(
  step: RecordedStep,
  useSmartSelectors: boolean,
): string {
  const sel =
    step.smartSelectors?.length && useSmartSelectors
      ? escapeString(pickBestSelector(step.smartSelectors, step.selector ?? ""))
      : escapeString(step.selector ?? "");
  const val = escapeString(step.value ?? "");
  const comment = step.label ? `  // ${step.label}` : "";

  switch (step.type) {
    case "navigate":
      return `    cy.visit('${escapeString(step.url ?? "")}');${comment}`;
    case "fill":
      return `    cy.get('${sel}').clear().type('${val}');${comment}`;
    case "click":
      return `    cy.get('${sel}').click();${comment}`;
    case "select":
      return `    cy.get('${sel}').select('${val}');${comment}`;
    case "check":
      return `    cy.get('${sel}').check();${comment}`;
    case "uncheck":
      return `    cy.get('${sel}').uncheck();${comment}`;
    case "clear":
      return `    cy.get('${sel}').clear();${comment}`;
    case "submit":
      return `    cy.get('${sel}').click();${comment}`;
    case "hover":
      return `    cy.get('${sel}').trigger('mouseover');${comment}`;
    case "press-key":
      return `    cy.get('body').type('{${(step.key ?? "").toLowerCase()}}');${comment}`;
    case "wait-for-element":
      return `    cy.get('${sel}', { timeout: ${step.waitTimeout ?? 5000} }).should('be.visible');${comment}`;
    case "wait-for-hidden":
      return `    cy.get('${sel}', { timeout: ${step.waitTimeout ?? 10000} }).should('not.exist');${comment}`;
    case "wait-for-url":
      return `    cy.url().should('include', '${escapeString(step.url ?? step.value ?? "")}');${comment}`;
    case "wait-for-network-idle":
      return `    cy.intercept('**').as('requests');\n    cy.wait('@requests');${comment}`;
    case "scroll":
      return step.scrollPosition
        ? `    cy.scrollTo(${step.scrollPosition.x}, ${step.scrollPosition.y});${comment}`
        : `    // scroll${comment}`;
    case "assert":
      return step.assertion
        ? assertionLine(step.assertion)
        : `    // assert${comment}`;
  }
}

Dependencies (Outgoing)

graph LR recordedStepLine["recordedStepLine"] escapeString["escapeString"] assertionLine["assertionLine"] recordedStepLine -->|calls| escapeString recordedStepLine -->|calls| assertionLine style recordedStepLine fill:#dbeafe,stroke:#2563eb,stroke-width:2px click recordedStepLine "741f3e787c830c95.html" click escapeString "5c2f25e3b4548c2d.html" click assertionLine "0f28f576e085ec59.html"
TargetType
escapeString calls
assertionLine calls

No incoming dependencies.