Skip to content

Commit

Permalink
FIX: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Jul 16, 2024
1 parent 1c6f145 commit dc6d097
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions pages/Search/Search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe(`Search`, function() {
cy.visit(`/search`)
cy.title().should(`equal`, `Nisinoon | Search`)
// Do not show results if a search was not submitted.
cy.get(`.results`).should(`not.exist`)
cy.get(`#results`).should(`not.exist`)
})

describe(`Quick Search`, function() {
Expand All @@ -23,79 +23,79 @@ describe(`Search`, function() {
cy.get(`form`).submit()
cy.get(`#search-box`).should(`have.value`, search)
cy.get(`.num-results`).should(`have.text`, `Showing results 1–2 of 2.`)
cy.get(`.results tbody tr`).should(`have.length`, 2)
cy.get(`#results tbody tr`).should(`have.length`, 2)
})

it(`case insensitive`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`ATIMW`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 2)
cy.get(`.results tbody tr`).should(`have.length`, 2)
cy.get(`#results tbody tr`).should(`have.length`, 2)
})

it(`Form (Project)`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`aamæhk`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 2)
cy.get(`.results tbody tr`).should(`have.length`, 2)
cy.get(`#results tbody tr`).should(`have.length`, 2)
})

it(`UR (Project)`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`αhso`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 1)
cy.get(`.results tbody tr`).should(`have.length`, 1)
cy.get(`#results tbody tr`).should(`have.length`, 1)
})

it(`Proto-Algonquian (Project)`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`(aa)ntep`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 1)
cy.get(`.results tbody tr`).should(`have.length`, 1)
cy.get(`#results tbody tr`).should(`have.length`, 1)
})

it(`Definition (Project)`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`motorize`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 1)
cy.get(`.results tbody tr`).should(`have.length`, 1)
cy.get(`#results tbody tr`).should(`have.length`, 1)
})

it(`Forms (Source)`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`gan̈ba8i`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 1)
cy.get(`.results tbody tr`).should(`have.length`, 1)
cy.get(`#results tbody tr`).should(`have.length`, 1)
})

it(`URs (Source)`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`iinoo'ei`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 1)
cy.get(`.results tbody tr`).should(`have.length`, 1)
cy.get(`#results tbody tr`).should(`have.length`, 1)
})

it(`Proto-Algonquian (Source)`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`-eʔs-`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 1)
cy.get(`.results tbody tr`).should(`have.length`, 1)
cy.get(`#results tbody tr`).should(`have.length`, 1)
})

it(`Definitions (Source)`, function() {
cy.visit(`/search`)
cy.get(`#search-box`).type(`motorisé`)
cy.get(`form`).submit()
cy.get(`.num-results`).should(`include.text`, 1)
cy.get(`.results tbody tr`).should(`have.length`, 1)
cy.get(`#results tbody tr`).should(`have.length`, 1)
})

})
Expand All @@ -108,10 +108,10 @@ describe(`Search`, function() {
cy.get(`form`).submit()

// Return 100 results by default
cy.get(`.results tbody tr`).should(`have.length`, 100)
cy.get(`#results tbody tr`).should(`have.length`, 100)

// Return first page of results by default
cy.get(`.results td`).first().should(`have.text`, `Abenaki`)
cy.get(`#results td`).first().should(`have.text`, `Abenaki`)
.next()
.should(`have.text`, `ôben-`)

Expand All @@ -124,23 +124,23 @@ describe(`Search`, function() {
// TODO: Once the "# of Results to Show" dropdown is implemented, test using that instead.
it(`limit`, function() {
cy.visit(`/search?limit=10&q=`)
cy.get(`.results tbody tr`).should(`have.length`, `10`)
cy.get(`#results tbody tr`).should(`have.length`, `10`)
})

// NB: Currently testing using querystring.
// TODO: Once the "# of Results to Show" dropdown is implemented, test using that instead.
// WARNING: Long-running test. Only run as needed.
it.skip(`limit: Infinity`, function() {
cy.visit(`/search?limit=Infinity&q=`)
cy.get(`.results tbody tr`).should(`have.length.of.at.least`, 12000)
cy.get(`#results tbody tr`).should(`have.length.of.at.least`, 12000)
})

it(`offset`, function() {
cy.visit(`/search`)
cy.get(`form`).submit()
cy.contains(`.pagination li`, `2`).click()
// NB: The 101st result in the database is currently Arapaho "-nooθ-".
cy.get(`.results td`).first().should(`have.text`, `Arapaho`)
cy.get(`#results td`).first().should(`have.text`, `Arapaho`)
.next()
.should(`have.text`, `-nooθ-`)
})
Expand All @@ -157,7 +157,7 @@ describe(`Search`, function() {

cy.contains(`th`, `Form`).first().should(`have.attr`, `aria-sort`)

cy.get(`.results td`).first().should(`have.text`, `Arapaho`)
cy.get(`#results td`).first().should(`have.text`, `Arapaho`)
.next()
.should(`have.text`, `θooxoneeʔ-`)

Expand Down

0 comments on commit dc6d097

Please sign in to comment.