Skip to content

Commit

Permalink
chore: fix cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson committed Oct 2, 2024
1 parent 77fd0d4 commit 8ec8194
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
3 changes: 3 additions & 0 deletions v3/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import "./commands"
// add code coverage support
import "@cypress/code-coverage/support"

// add support for dispatching native events (https://github.com/dmtrKovalenko/cypress-real-events)
import "cypress-real-events"

// https://github.com/quasarframework/quasar/issues/2233#issuecomment-1006506083
Cypress.on("uncaught:exception", err => !err.message.includes("ResizeObserver"))

Expand Down
8 changes: 5 additions & 3 deletions v3/cypress/support/elements/table-tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,19 +387,21 @@ export const TableTileElements = {
},
addFormulaInModal(attributeName: string, formula: string) {
cy.get("[data-testid=attr-name-input]").invoke("attr", "value").should("eq", attributeName)
cy.get("[data-testid=formula-editor-input]").type(formula, {force:true})
cy.get("[data-testid=formula-editor-input] .cm-content").should("be.visible").and("have.focus")
cy.get("[data-testid=formula-editor-input] .cm-content").realType(formula)
cy.get("[data-testid=formula-editor-input] .cm-content").should("contain", formula)
cy.get("[data-testid=Apply-button]").click()
cy.get("[data-testid=attr-name-input]").should("not.exist")
},
clearFormulaInModal(attributeName: string) {
cy.get("[data-testid=attr-name-input]").invoke("attr", "value").should("eq", attributeName)
cy.get("[data-testid=formula-editor-input]").type(`{selectAll}{del}`)
cy.get("[data-testid=formula-editor-input] .cm-content").type(`{selectAll}{del}`)
cy.get("[data-testid=Apply-button]").click()
cy.get("[data-testid=attr-name-input]").should("not.exist")
},
checkFormulaInModal(attributeName: string, formula: string) {
cy.get("[data-testid=attr-name-input]").invoke("attr", "value").should("eq", attributeName)
cy.get("[data-testid=formula-editor-input]").should("have.text", formula)
cy.get("[data-testid=formula-editor-input] .cm-content").should("have.text", formula)
cy.get("[data-testid=Cancel-button]").click()
cy.get("[data-testid=attr-name-input]").should("not.exist")
},
Expand Down
2 changes: 1 addition & 1 deletion v3/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"types": ["cypress"]
"types": ["cypress", "cypress-real-events"]
},
"include": [
"./**/*"
Expand Down
17 changes: 17 additions & 0 deletions v3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^7.1.2",
"cypress": "^13.13.3",
"cypress-real-events": "^1.13.0",
"dotenv-webpack": "^8.1.0",
"eslint": "^8.57.0",
"eslint-config-react": "^1.1.7",
Expand Down
8 changes: 7 additions & 1 deletion v3/src/components/common/formula-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,17 @@ export function FormulaEditor({ formula, setFormula, options: _options }: IProps
const { attributes = true, constants = true, functions = true, globals = true, specials = true } = options || {}
const fullOptions: ICompletionOptions = { attributes, constants, functions, globals, specials }
view.dispatch({ effects: cmUpdateOptionsEffect.of(fullOptions) })

Check warning on line 234 in v3/src/components/common/formula-editor.tsx

View check run for this annotation

Codecov / codecov/patch

v3/src/components/common/formula-editor.tsx#L233-L234

Added lines #L233 - L234 were not covered by tests

// https://discuss.codemirror.net/t/how-to-autofocus-in-cm6/2966
const focusTimer = setInterval(() => {
view.focus()

Check warning on line 238 in v3/src/components/common/formula-editor.tsx

View check run for this annotation

Codecov / codecov/patch

v3/src/components/common/formula-editor.tsx#L237-L238

Added lines #L237 - L238 were not covered by tests
if (view.hasFocus) clearInterval(focusTimer)
}, 100)
}, [dataSet, options])

const handleFormulaChange = (value: string, viewUpdate: ViewUpdate) => setFormula(value)

Check warning on line 243 in v3/src/components/common/formula-editor.tsx

View check run for this annotation

Codecov / codecov/patch

v3/src/components/common/formula-editor.tsx#L243

Added line #L243 was not covered by tests

return <CodeMirror ref={cmRef} value={formula} data-test-id="formula-editor-input" height="70px"
return <CodeMirror ref={cmRef} value={formula} data-testid="formula-editor-input" height="70px"

Check warning on line 245 in v3/src/components/common/formula-editor.tsx

View check run for this annotation

Codecov / codecov/patch

v3/src/components/common/formula-editor.tsx#L245

Added line #L245 was not covered by tests
basicSetup={false} extensions={cmExtensionsSetup()}
onCreateEditor={handleCreateEditor} onChange={handleFormulaChange} />
}

0 comments on commit 8ec8194

Please sign in to comment.