Files
dc/client/cypress/e2e/metanav.cy.ts
T
dc 02a8590310
Build / Build-and-ng-test (pull_request) Successful in 7m14s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m4s
Build / Build-and-test-development (pull_request) Successful in 35m25s
fix(test): run metanav.cy.ts in CI and open a metadata object
`cy.get` inside `.within(<tree node>)` only searches that node, and the
metadata accordion renders in the content area - so `.clr-accordion-header-button`
was never found however long it retried. The spec queries the accordion at
document level, selects the first metadata type by its class rather than by
node index, and clicks the header button directly (Clarity puts
`clr-accordion-header-button` on the button itself).

The assertions are on the app's own markers: the single open panel
(`clr-accordion-panel-open`, `aria-expanded`), the association tree inside the
panel, and the attribute grid that `metanav/metadetails` fills.

metanav moves from EXCLUDED to SPECS in `.gitea/scripts/cypress-specs.sh`.

Closes #395.
2026-10-31 22:36:33 +00:00

71 lines
2.5 KiB
TypeScript

export {}
const hostUrl = Cypress.env('hosturl')
const appLocation = Cypress.env('appLocation')
const longerCommandTimeout = Cypress.env('longerCommandTimeout')
context('metanav tests: ', function () {
this.beforeAll(() => {
cy.visit(`${hostUrl}/SASLogon/logout`)
cy.loginAndUpdateValidKey(true)
})
this.beforeEach(() => {
// beforeAll has already logged in. Typing into the login form here failed
// once the session existed - the form is not on screen, so Cypress reported
// "the center of this element is hidden from view" and the whole suite was
// skipped behind that hook.
visitPage('view/metadata')
})
it('1 | Opens metadata object', () => {
openFirstMetadataType()
/**
* Query the accordion at document level. The panel renders in the content
* area, while `.within(<tree node>)` scopes every following `cy.get` to
* that node alone - which finds nothing however long it retries.
*/
cy.get('.clr-accordion-header-button', { timeout: longerCommandTimeout })
.should('have.length.greaterThan', 0)
.first()
// Clarity puts the class on the button itself, so it is the click target.
.click()
// The panel reports its own open state, so the assertion is on the app's
// marker rather than on the content happening to be present.
cy.get('.clr-accordion-panel-open').should('have.length', 1)
cy.get('.clr-accordion-header-button')
.first()
.should('have.attr', 'aria-expanded', 'true')
// Opening the panel loads the object's details: the association tree and
// the attribute grid both come from `metanav/metadetails`.
cy.get('.clr-accordion-inner-content clr-tree-node', {
timeout: longerCommandTimeout
}).should('have.length.greaterThan', 0)
cy.get('clr-dg-row').should('have.length.greaterThan', 0)
cy.get('clr-dg-cell').contains('Name')
})
this.afterEach(() => {
cy.visit(`${hostUrl}/SASLogon/logout`)
})
})
const openFirstMetadataType = () => {
cy.get('.app-loading', { timeout: longerCommandTimeout }).should('not.exist')
// The metadata types are the tree nodes after the search box; the search box
// is its own node (`.search-node`), so selecting by position would tie the
// spec to that detail. The <p> is the element that owns the click handler.
cy.get('.nav-tree clr-tree > clr-tree-node:not(.search-node) p', {
timeout: longerCommandTimeout
})
.first()
.click()
}
const visitPage = (url: string) => {
cy.visit(`${hostUrl}${appLocation}/#/${url}`)
}