Skip to content

Commit e907bd7

Browse files
committed
feat(cypress): enhance command interface with schema validation methods
- Added new commands for document and DOM schema validation, including methods to assert schema validity and log document structures. - Updated existing Cypress tests to use strict equality checks for schema validation results. - Introduced ESLint directive to disable undefined variable warnings in helper.js.
1 parent 5b8d36c commit e907bd7

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

packages/webapp/cypress/support/commands.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ registerDocumentValidator()
8686
type SelectionLevel = 'element' | 'parent' | 'section' | 'heading' | 'list' | 'document'
8787

8888
declare global {
89+
// eslint-disable-next-line @typescript-eslint/no-namespace
8990
namespace Cypress {
9091
interface Chainable {
9192
clearEditor(title?: string, sentencesCount?: number): Chainable<Element>
@@ -181,6 +182,27 @@ declare global {
181182
logResults: boolean
182183
}): Chainable<{ valid: boolean; errors: string[]; structure: any[] }>
183184

185+
// Schema validators (from schemaValidator.js)
186+
validateDocumentSchema(): Chainable<{
187+
valid: boolean
188+
errors: string[]
189+
errorCount?: number
190+
skipped?: boolean
191+
}>
192+
assertValidSchema(): Chainable<void>
193+
logDocumentStructure(): Chainable<void>
194+
195+
// DOM Schema validators (from domSchemaValidator.js)
196+
validateDOMSchema(): Chainable<{
197+
valid: boolean
198+
errors: string[]
199+
errorCount: number
200+
structure: any[]
201+
}>
202+
assertValidDOMSchema(): Chainable<void>
203+
logDOMStructure(): Chainable<void>
204+
assertFullSchemaValid(): Chainable<void>
205+
184206
createSelection(options: {
185207
editorSelector?: string
186208
startSection?: string | number | { title: string }
@@ -1238,6 +1260,7 @@ Cypress.Commands.add(
12381260
// =============================================================================
12391261

12401262
declare global {
1263+
// eslint-disable-next-line @typescript-eslint/no-namespace
12411264
namespace Cypress {
12421265
interface Chainable {
12431266
/**

packages/webapp/cypress/support/e2e.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ afterEach(function () {
5959
pmResult.errors.forEach((err) => cy.log(` ${err}`))
6060

6161
// STRICT: Fail the test
62-
expect(pmResult.valid, `ProseMirror Schema invalid:\n${pmResult.errors.join('\n')}`).to.be
63-
.true
62+
expect(
63+
pmResult.valid,
64+
`ProseMirror Schema invalid:\n${pmResult.errors.join('\n')}`
65+
).to.equal(true)
6466
}
6567
})
6668

@@ -78,7 +80,9 @@ afterEach(function () {
7880
})
7981

8082
// STRICT: Fail the test
81-
expect(domResult.valid, `DOM Schema invalid:\n${domResult.errors.join('\n')}`).to.be.true
83+
expect(domResult.valid, `DOM Schema invalid:\n${domResult.errors.join('\n')}`).to.equal(
84+
true
85+
)
8286
}
8387
})
8488
})

packages/webapp/cypress/support/helper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-undef */
12
import { LoremIpsum } from 'lorem-ipsum'
23

34
// Create singleton instance with configuration

0 commit comments

Comments
 (0)