Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require ./jquery-prod.js
//= require jquery-ui
//= require foundation/js/foundation/foundation.js
//= require foundation/js/foundation/foundation.magellan.js
Expand Down
14 changes: 14 additions & 0 deletions app/assets/javascripts/jquery-prod.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Including jQuery in application.js causes errors when the AngularJS app is loaded in the
// Children's Council WordPress site, because this version of jQuery conflicts with a version
// included on the WordPress site. The current team did not put together the set of scripts
// loaded in application.js, so we are not yet clear on whether we actually need jQuery here.
// The major functions of the AngularJS app appear to still work without these requires. Since
// the error caused by the jQuery conflict is causing our end-to-end Cypress tests to fail,
// we are removing these requires in development so that the tests can pass in dev. Although the
// AngularJS app largely appears to work without these requires, we haven't yet had a chance to
// thoroughly investigate if there are any features that break without them, so we are leaving
// them in in production for now to be safe, until we can examine this further.
<% if Rails.env.production? %>
<%= require_asset 'jquery' %>
<%= require_asset 'jquery_ujs' %>
<% end %>
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
22 changes: 22 additions & 0 deletions cypress/integration/providers.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types="Cypress" />

context("Providers", () => {
beforeEach(() => {
// This is supposed to prevent Cypress from failing tests on JS errors,
// but Cypress has a bug that is causing this feature to be broken.
// See https://github.com/cypress-io/cypress/issues/987 for more details.
cy.on("uncaught:exception", err => {
return false
})
})

describe("Going directly to a provider page", () => {
it("should show the page", () => {
// Go to the provider page for Dan Dan Family Child Care
cy.visit("http://localhost:3000/providers/105")

// Check that the center name is shown
cy.contains("Dan Dan Family Child Care")
})
})
})
79 changes: 79 additions & 0 deletions cypress/integration/search.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/// <reference types="Cypress" />

context("Search", () => {
beforeEach(() => {
// This is supposed to prevent Cypress from failing tests on JS errors,
// but Cypress has a bug that is causing this feature to be broken.
// See https://github.com/cypress-io/cypress/issues/987 for more details.
cy.on("uncaught:exception", err => {
return false
})
})

describe("Searching with the default search criteria values from the search page", () => {
it("should lead to the results page and show some results", () => {
cy.visit("http://localhost:3000")

// Fill out the required "About You" info
cy.get("input[name='full_name']").type("Test Tester")
cy.get("#email").type("test@test.com")
cy.get("#zip-code").type("12345")
cy.get("#care-reason-1").select("Employment")

cy.get("label[for='agree']").click()
cy.get("#searchForm input[type='submit']").click()

cy.location("pathname").should("eq", "/providers")

cy.get("result").should("have.length.greaterThan", 1)
})
})

describe("Searching by editing search criteria values on the results page", () => {
it("should perform a new search and show some results", () => {
// Open the Filters modal
cy.contains("Show more filters & edit").click()

// Enter an address and search
cy.get("#near-address").type("2601 Mission St")
cy.get(".filters-modal input[value='Search']").click()

// A search request should be made
cy.server()
cy.route("POST", "/api/providers").as("providersSearchRequest")
cy.wait(["@providersSearchRequest"])

// Filters modal should close
cy.get("body").should("not.have.descendants", ".filters-modal")

// Multiple results should be displayed
cy.get("result").should("have.length.greaterThan", 1)
})
})

describe("Searching by name from the search page", () => {
it("should perform a new search and show some results", () => {
cy.visit("http://localhost:3000")

// Click on the name search tab
cy.contains("Search By Program Name").click()

// Enter part of the name of the owner's name of Dan Dan Family Child Care
cy.get('input[placeholder="Enter an owner\'s name or a school name."]').type("dangui")

// Fill out the required "About You" info
cy.get("input[name='full_name']").type("Test Tester")
cy.get("#email").type("test@test.com")
cy.get("#zip-code").type("12345")
cy.get("#care-reason-1").select("Employment")

cy.get("label[for='agree']").click()
cy.get("#searchForm input[type='submit']").click()

cy.location("pathname").should("eq", "/providers")

cy.get("result").should("have.length.greaterThan", 0)
cy.contains("Dan Dan Family Child Care")
})
})
})
17 changes: 17 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading