Skip to content

Commit

Permalink
chore: fix cypress typings (#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson authored Aug 13, 2024
1 parent 81c2675 commit 10b52ee
Show file tree
Hide file tree
Showing 29 changed files with 282 additions and 288 deletions.
21 changes: 21 additions & 0 deletions v3/cypress/cypress.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export {}

declare global {
namespace Cypress {
interface Cypress {
// added to Cypress config via cypress.*.json configuration files
config(key: "index"): string
}
interface Chainable {
/**
* Custom commands defined in commands.ts
*/
clickMenuItem(item: string): void
clickToUnselect(subject: Array<{ x: number, y: number }>, options?: { delay: number }): void
checkDragAttributeHighlights(source: string, attribute: string, target: string, exists?: boolean): void
dragAttributeToTarget(source: string, attribute: string, target: string, targetNumber?: number): void
mouseMoveBy(subject: JQuery<HTMLElement>, targetRect: DOMRect, options?: { delay: number }): void
pointerMoveBy(subject: JQuery<HTMLElement>, targetRect: DOMRect, options?: { delay: number }): void
}
}
}
1 change: 1 addition & 0 deletions v3/cypress/e2e/adornments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ context("Graph adornments", () => {
// The exact value of left may vary slightly depending on browser, screen resolution, etc.
// The below checks that the value is within an expected range to accommodate these variations.
// Modeled after https://github.com/cypress-io/cypress/issues/14722#issuecomment-767367519
// @ts-expect-error -- type definition is incorrect: return value is property value not chained element
.should("have.css", "left").should((left: string) => {
expect(left).to.include("px")
expect(parseInt(left, 10)).to.be.within(271, 273)
Expand Down
81 changes: 21 additions & 60 deletions v3/cypress/e2e/axis.spec.ts

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions v3/cypress/e2e/calculator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ context("Calculator", () => {
c.changeComponentTitle("calculator", newCalculatorName)
c.getComponentTitle("calculator").should("have.text", newCalculatorName)

c.getIconFromToolshelf("calc").click()
c.getIconFromToolShelf("calc").click()
c.checkComponentDoesNotExist("calculator")

cy.log("Check undo/redo of close and open calculator component")
Expand All @@ -50,7 +50,7 @@ context("Calculator", () => {
toolbar.getRedoTool().click()
c.checkComponentDoesNotExist("calculator")

c.getIconFromToolshelf("calc").click()
c.getIconFromToolShelf("calc").click()
c.checkComponentExists("calculator")
c.getComponentTitle("calculator").should("contain", newCalculatorName)
})
Expand All @@ -71,7 +71,7 @@ context("Calculator", () => {
toolbar.getRedoTool().click()
c.checkComponentDoesNotExist("calculator")

c.getIconFromToolshelf("calc").click()
c.getIconFromToolShelf("calc").click()
c.checkComponentExists("calculator")
c.getComponentTitle("calculator").should("contain", newCalculatorName)
})
Expand Down
2 changes: 1 addition & 1 deletion v3/cypress/e2e/formula/formula-component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ context("Formula Engine", () => {
fh.editFormula("Formula", "a+2")
fh.verifyValues("Formula", [3, 4, 5, 5, 2])
})
it("Add and edit formula for an existng attribute", () => {
it("Add and edit formula for an existing attribute", () => {
fh.visitURL("?sample=four&dashboard")
fh.addFormula("b", "count(a)")
fh.verifyValues("b", [4, 4, 4, 4, 4])
Expand Down
18 changes: 9 additions & 9 deletions v3/cypress/e2e/graph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ context.skip("Test graph plot transitions", () => {

plots.forEach(test => {
it.skip(`${test.testName}`, () => {
c.getIconFromToolshelf("graph").click()
c.getIconFromToolShelf("graph").click()
c.moveComponent("graph", 1000)
test.axes.forEach(hash => {
hash.checks.forEach(check => {
Expand Down Expand Up @@ -70,7 +70,7 @@ context("Graph UI", () => {
cy.log(`Initial CODAP Graph Count: ${initialCount}`)

// perform an action that gets a new graph
c.getIconFromToolshelf("graph").click()
c.getIconFromToolShelf("graph").click()
// cy.wait(1000)
c.getComponentTitle("graph").should("contain", collectionName)
c.getComponentTitle("graph", 1).should("contain", collectionName)
Expand All @@ -90,12 +90,12 @@ context("Graph UI", () => {
it("creates graphs with new collection names when existing ones are closed", () => {
c.closeComponent("graph")
c.checkComponentDoesNotExist("graph")
c.getIconFromToolshelf("graph").click()
c.getIconFromToolShelf("graph").click()
c.getComponentTitle("graph").should("contain", collectionName)

c.closeComponent("graph")
c.checkComponentDoesNotExist("graph")
c.getIconFromToolshelf("graph").click()
c.getIconFromToolShelf("graph").click()
c.getComponentTitle("graph").should("contain", collectionName)
})
it("checks all graph tooltips", () => {
Expand Down Expand Up @@ -277,7 +277,7 @@ context("Graph UI", () => {
cy.get("[data-testid=parent-toggles-last]").click()
cy.wait(250)
cy.get("[data-testid=parent-toggles-last]").should("have.text", "☒ Last")
cy.get("[data-testid=parent-toggles-case-buttons-list]").find("button").then((buttons: HTMLButtonElement[]) => {
cy.get("[data-testid=parent-toggles-case-buttons-list]").find("button").then((buttons) => {
const lastButtonIndex = buttons.length - 1
buttons.each((i: number, button: HTMLButtonElement) => {
if (i !== lastButtonIndex) {
Expand Down Expand Up @@ -533,12 +533,12 @@ context("Graph UI", () => {
.trigger("mouseup", { force: true, view: win })
})
graph.getDisplayConfigButton().click()
cy.get("[data-testid=graph-bin-width-setting]").find("input").invoke("val").then((valueStr: string) => {
const valueNum = parseFloat(valueStr)
cy.get("[data-testid=graph-bin-width-setting]").find("input").invoke("val").then((value) => {
const valueNum = parseFloat(value as string)
expect(valueNum).to.be.closeTo(2.75, 0.25)
})
cy.get("[data-testid=graph-bin-alignment-setting]").find("input").invoke("val").then((valueStr: string) => {
const valueNum = parseFloat(valueStr)
cy.get("[data-testid=graph-bin-alignment-setting]").find("input").invoke("val").then((value) => {
const valueNum = parseFloat(value as string)
expect(valueNum).to.be.closeTo(4, 0.1)
})
})
Expand Down
4 changes: 3 additions & 1 deletion v3/cypress/e2e/hierarchical-table.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { TableTileElements as table } from "../support/elements/table-tile"
import hierarchical from '../fixtures/hierarchical.json'
type HierarchicalTest = typeof hierarchical.tests[number] & { only?: boolean }

const values = hierarchical.attributes

context("hierarchical collections", () => {
Expand All @@ -11,7 +13,7 @@ context("hierarchical collections", () => {
cy.wait(2500)
cy.log('Setup complete')
})
hierarchical.tests.forEach((h) => {
hierarchical.tests.forEach((h: HierarchicalTest) => {
// FIXME: enable skipped tests
const itOrSkip = h.skip ? it.skip : h.only ? it.only : it
itOrSkip(`${h.testName}`, () => {
Expand Down
20 changes: 10 additions & 10 deletions v3/cypress/e2e/map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ context("Map UI", () => {
cy.log("updates map title")

cfm.openLocalDoc(filename1)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
c.getComponentTitle("map").should("have.text", componentName)
c.changeComponentTitle("map", newComponentName)
c.getComponentTitle("map").should("have.text", newComponentName)

cy.log("creates maps with new component name")
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()

c.getComponentTitle("map").should("contain", componentName)
c.getComponentTitle("map", 1).should("contain", componentName)
})
it("checks all map tooltips", () => {
cfm.openLocalDoc(filename1)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
c.selectTile("map", 0)

toolbar.getToolShelfIcon("map").then($element => {
Expand Down Expand Up @@ -78,7 +78,7 @@ context("Map UI", () => {
// flaky test skipped in PR #1239, see PT #187534790
it.skip("checks numerical and categorical attributes for map legend", () => {
cfm.openLocalDoc(filename2)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
cy.dragAttributeToTarget("attribute", arrayOfAttributes[0], "map")

mlh.verifyLegendLabel(arrayOfAttributes[0])
Expand Down Expand Up @@ -117,7 +117,7 @@ context("Map UI", () => {
})
it("checks show/hide selected/unselected/all map boundaries", () => {
cfm.openLocalDoc(filename2)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
c.selectTile("map", 0)

map.selectHideShowButton()
Expand All @@ -142,7 +142,7 @@ context("Map UI", () => {
})
it("checks show/hide selected/unselected/all map points", () => {
cfm.openLocalDoc(filename1)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
c.selectTile("map", 0)

map.selectHideShowButton()
Expand All @@ -168,7 +168,7 @@ context("Map UI", () => {
// flaky test skipped in PR #1239, see PT #187534790
it.skip("checks show/hide map boundaries with legend selections", () => {
cfm.openLocalDoc(filename2)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
cy.dragAttributeToTarget("attribute", arrayOfAttributes[0], "map")

mlh.verifyCategoricalLegend(arrayOfValues[0].values.length)
Expand Down Expand Up @@ -209,7 +209,7 @@ context("Map UI", () => {
// flaky test skipped in PR #1239, see PT #187534790
it.skip("checks show/hide map points with legend selections", () => {
cfm.openLocalDoc(filename1)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
cy.wait(1000)
cy.dragAttributeToTarget("attribute", arrayOfAttributes[2], "map")

Expand Down Expand Up @@ -251,7 +251,7 @@ context("Map UI", () => {
// flaky test skipped in PR #1239, see PT #187534790
it.skip("checks legend attribute menu", () => {
cfm.openLocalDoc(filename2)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
cy.dragAttributeToTarget("attribute", arrayOfAttributes[0], "map")

mlh.verifyLegendLabel(arrayOfAttributes[0])
Expand Down Expand Up @@ -280,7 +280,7 @@ context("Map UI", () => {

it("shows connecting lines when Connecting Lines option is checked", () => {
cfm.openLocalDoc(filename1)
c.getIconFromToolshelf("map").click()
c.getIconFromToolShelf("map").click()
c.selectTile("map", 0)
cy.wait(2000)
cy.get("[data-testid=connecting-lines-map-1").find("path").should("have.length", 0)
Expand Down
6 changes: 3 additions & 3 deletions v3/cypress/e2e/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ context("codap plugins", () => {
webView.toggleAPITesterFilter()

cy.log("Broadcast dataContextCountChanged notifications when dataset is added to document")
table.createNewTableFromToolshelf()
table.createNewTableFromToolShelf()
webView.confirmAPITesterResponseContains(/"operation":\s"dataContextCountChanged/)
webView.clearAPITesterResponses()

cy.log("Broadcast dataContextDeleted notifications when dataset is deleted")
table.deleteDataSetFromToolshelf(1)
table.deleteDataSetFromToolShelf(1)
webView.confirmAPITesterResponseContains(/"operation":\s"dataContextDeleted/)
webView.confirmAPITesterResponseContains(/"deletedContext":\s"New\sDataset/)
webView.clearAPITesterResponses()
Expand Down Expand Up @@ -273,7 +273,7 @@ context("codap plugins", () => {
cy.log("Broadcast notifications involving dragging")
const url = `${Cypress.config("index")}?mouseSensor`
cy.visit(url)
table.createNewTableFromToolshelf()
table.createNewTableFromToolShelf()
table.addNewAttribute()
table.addNewAttribute()
openAPITester()
Expand Down
16 changes: 8 additions & 8 deletions v3/cypress/e2e/slider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ context("Slider UI", () => {
slider.checkPlayButtonIsPaused()
})
it("creates another slider from toolshelf", () => {
c.getIconFromToolshelf("slider").click()
c.getIconFromToolShelf("slider").click()

c.getComponentTitle("slider").should("contain", sliderName)
slider.getVariableName().should("have.text", sliderName)
Expand All @@ -165,7 +165,7 @@ context("Slider UI", () => {
})
it("checks editing variable name in one slider only affects that slider", () => {
const newSliderName = "xyz"
c.getIconFromToolshelf("slider").click()
c.getIconFromToolShelf("slider").click()

slider.changeVariableName(newSliderName, 1)
c.getComponentTitle("slider", 0).should("contain", sliderName)
Expand All @@ -175,14 +175,14 @@ context("Slider UI", () => {
})
it("checks editing variable value in one slider only affects that slider", () => {
const newVariableValue = "100"
c.getIconFromToolshelf("slider").click()
c.getIconFromToolShelf("slider").click()

slider.changeVariableValue(newVariableValue, 1)
slider.getVariableValue(0).should("contain", initialSliderValue)
slider.getVariableValue(1).should("contain", newVariableValue)
})
it("checks playing in one slider only plays that slider", () => {
c.getIconFromToolshelf("slider").click()
c.getIconFromToolShelf("slider").click()
slider.setAnimationRate(3, 1)

slider.checkPlayButtonIsPaused(0)
Expand All @@ -205,7 +205,7 @@ context("Slider UI", () => {
slider.checkPlayButtonIsPaused(1)
})
it("creates sliders with incrementing names", () => {
c.getIconFromToolshelf("slider").click()
c.getIconFromToolShelf("slider").click()

c.getComponentTitle("slider").should("contain", sliderName)
slider.getVariableName().should("have.text", sliderName)
Expand All @@ -217,7 +217,7 @@ context("Slider UI", () => {
slider.getVariableValue(1).should("contain", initialSliderValue)
slider.checkPlayButtonIsPaused(1)

c.getIconFromToolshelf("slider").click()
c.getIconFromToolShelf("slider").click()
c.getComponentTitle("slider", 2).should("contain", "v3")
slider.getVariableName(2).should("have.text", "v3")
slider.getVariableValue(2).should("contain", initialSliderValue)
Expand All @@ -226,7 +226,7 @@ context("Slider UI", () => {
it("reuses slider names after existing ones are closed", () => {
c.closeComponent("slider")
c.checkComponentDoesNotExist("slider")
c.getIconFromToolshelf("slider").click()
c.getIconFromToolShelf("slider").click()

c.getComponentTitle("slider").should("contain", "v1")
slider.getVariableName().should("have.text", "v1")
Expand All @@ -235,7 +235,7 @@ context("Slider UI", () => {

c.closeComponent("slider")
c.checkComponentDoesNotExist("slider")
c.getIconFromToolshelf("slider").click()
c.getIconFromToolShelf("slider").click()

c.getComponentTitle("slider").should("contain", "v1")
slider.getVariableName().should("have.text", "v1")
Expand Down
Loading

0 comments on commit 10b52ee

Please sign in to comment.