Add Contact Us test

Created on 11 June 2023, about 1 year ago
Updated 5 July 2023, 12 months ago

Add a Contact Us test that uses a random code to match the corresponding email in Ethereal.email. When this test is complete, update the register test to find the correct email in ethereal.

The code below is a start for Cypress but doesn't work yet. Use these resources to improve the code:

describe('Validate Contact Us', {tags: ['contact-us', 'smoke']}, () => {

  it("(PER-1100) Contact Us form accepts correct input.", {defaultCommandTimeout: 1000 tags: ['contact-us', 'smoke']}, () => {
    const randomString = createRandomString(10)
    
    cy.log("**Fill out contact form.**")
    cy.visit('contact-us').then(() => {
      cy.get('#edit-name').type('Andrรฉ Angelantoni')
      cy.get('#edit-email').type('aangel100+001@gmail.com')
      cy.get('#edit-company-name').type('Performant Labs Inc.')

      // We will check for this later.
      cy.get('#edit-message').type(randomString)
      cy.contains('Send message').click()
    })

    cy.log("**Should see the thank-you page.**")
    cy.contains('Thank you')
    cy.visit(Cypress.env('url').login)

    // But there shouldn't be an error on it.
    // cy.get('.alert').should('not.exist')

    // Now check for the entry in the database.
    // Note that experiencing this problem and clearing isn't working:
    // https://github.com/cypress-io/cypress/issues/14590
    Cypress.session.clearSessionStorage

    cy.logInAs(Cypress.env('account').admin)
    cy.visit('admin/structure/webform/submissions/manage')

    // Check only some of them.
    var submissionIndex = 0

    // Rework this to exit correctly when randomString is found.
    cy.log("**Look through table for entry.**")
    cy.get('.webform-results-table > tbody > tr').each((row) => {
      cy.visit(row[0].dataset.webformHref)
      cy.get('#contact--message').then( (element) => {
        cy.wrap(element[0]).contains(randomString)
      })
      submissionIndex++
      // If we checked all of them with no success, fail the test
      if (submissionIndex == 10 ) return false  // Fail test.
    })
  })
})
๐Ÿ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States aangel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024