export default class FormValidation { static assertRequired(chain: Cypress.Chainable>) { return this.#getHelperText(chain).should("have.text", "Required field"); } static assertMinValue( chain: Cypress.Chainable>, minValue: number ) { this.#getHelperText(chain).should( "have.text", `Must be greater than ${minValue}` ); } static assertMaxValue( chain: Cypress.Chainable>, maxValue: number ) { this.#getHelperText(chain).should( "have.text", `Must be less than ${maxValue}` ); } static #getHelperText(chain: Cypress.Chainable>) { // A regular ID selector doesn't work here so we have to query by attribute. return chain .invoke("attr", "id") .then((id) => cy.get(`[id="${id}-helper"]`)); } }