Skip to content

Commit

Permalink
Merge pull request #375 from pressbooks/dev
Browse files Browse the repository at this point in the history
v2.2 release
  • Loading branch information
fdalcin authored Jul 6, 2021
2 parents aeabfff + 3c184ac commit 9140f08
Show file tree
Hide file tree
Showing 44 changed files with 428 additions and 273 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2

- uses: actions/setup-node@v2
with:
Expand All @@ -42,7 +44,13 @@ jobs:
- name: Lint
run: npm run lint

- uses: marceloprado/has-changed-path@v1
id: code-changes
with:
paths: src e2e

- name: e2e Tests
if: steps.code-changes.outputs.changed == 'true'
uses: cypress-io/github-action@v2
with:
start: npm run dev
Expand Down
4 changes: 2 additions & 2 deletions e2e/fixtures/bookCard.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"network": "pressbooks.lib.vt.edu | Pressbooks at Virginia Tech",
"title": "Significant Statistics",
"wordCount": "275135",
"wordCount": "275,135",
"size": "233.53",
"h5pActivities": "191",
"authors": "Adapted by John Morgan Russell, from Barbara Illowsky and Susan Dean, David Diez, Mine Cetinkaya-Rundel and Christopher D. Barr, Julie Vu and David Harrington",
Expand All @@ -15,4 +15,4 @@
"h5p": "/assets/images/h5p.png",
"notOriginal": "/assets/images/is-child.png",
"cover": "https://pressbooks.lib.vt.edu/app/uploads/sites/12/2021/01/Option-2.png"
}
}
4 changes: 2 additions & 2 deletions e2e/fixtures/selectableFilters.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"urlAlias": "subj",
"search": {
"searchTerm": "math",
"filter": "Mathematical logic"
"filter": "Applied mathematics"
},
"bookCards": {
"filters": [ "Sociology", "Chemistry" ],
Expand Down Expand Up @@ -123,7 +123,7 @@
"Dini Afrika ya Mashariki",
"Jinsia na Mapenzi Afrika ya Mashariki"
],
"count": 2182
"count": "2,182"
}
},
"Collection": {
Expand Down
5 changes: 0 additions & 5 deletions e2e/integration/bookCards.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ describe('Book cards', function () {
.first()
.should('include.text','Written specifically for students in Boise State University’s Bachelor of Applied Science');
});
it('Check recommended attribute in the book cards', () => {
search('Open Music Theory');
cy.get(Elements.booksCards.recommended)
.should('include.text', 'Recommended');
});
it('Check all book cards attributes from a particular book', () => {
const attributesToCheck = [
{
Expand Down
68 changes: 17 additions & 51 deletions e2e/integration/filters/bookCardFilters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,40 @@ import Elements from '../../support/elements';

describe('BookCard Collections Filters', () => {
context('Desktop Resolution', () => {

it('Recommended filter toggle', () => {

cy.get(Elements.booksCards.recommended).should('have.class','text-pb-red');

cy.get(Elements.booksCards.recommended).click();

cy.algoliaQueryRequest('algoliaRequest');

cy.url().should('include','recommended=true');

cy.get(Elements.booksCards.recommended).should('have.length',10)
.should('not.have.class','text-pb-red')
.should('have.class','text-white');

cy.get(Elements.booksCards.recommended).first().click();

cy.algoliaQueryRequest('algoliaRequest');

cy.get(Elements.booksCards.recommended)
.should('not.have.class','text-white');

});

it('Collection filter toggle', () => {

cy.visit('/?collec=OpenStax');

cy.algoliaQueryRequest('algoliaRequest');

cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
.parent()
.next()
.find('button')
cy.get(Elements.booksCards.bookTags)
.eq(1)
.find('li:first-child button')
.should('have.class', 'text-pb-red');
cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
.parent()
.next()
.next()
.find('button')

cy.get(Elements.booksCards.bookTags)
.eq(1)
.find('li:nth-of-type(2) button')
.should('have.class', 'text-white');

cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
.parent()
.next()
.find('button')
cy.get(Elements.booksCards.bookTags)
.eq(1)
.find('li:first-child button')
.click();

cy.algoliaQueryRequest('algoliaRequest');

cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
.parent()
.next()
.find('button')
.should('have.class', 'text-white');

cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
.parent()
.next()
.find('button')
cy.get(Elements.booksCards.bookTags)
.eq(1)
.find('li:first-child button')
.should('have.class', 'text-white')
.click();

cy.algoliaQueryRequest('algoliaRequest');

cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
.parent()
.next()
.find('button')
cy.get(Elements.booksCards.bookTags)
.eq(1)
.find('li:first-child button')
.should('have.class', 'text-pb-red');

cy.url().should('include','?collec=OpenStax');
Expand Down
34 changes: 28 additions & 6 deletions e2e/integration/filters/clearFilters.spec.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {
clickAccordionClearFilter,
clickAccordionHeader,
clickFilter
clickFilter,
perPage,
search,
sortBy
} from '../../support/common';
import Elements from '../../support/elements';

describe('Clear Filters',() => {
context('Desktop Resolution', () => {
beforeEach(() => {

clickAccordionHeader('licenseCode');

clickFilter('licenseCode','cc-by', 'include');
clickFilter('licenseCode','cc-by-nc-sa', 'include');
clickFilter('licenseCode','all-rights-reserved', 'include');

});

it('Clear chip refinement', () => {

cy.url()
.should('include','?license=CC%20BY');

Expand All @@ -32,11 +32,9 @@ describe('Clear Filters',() => {

cy.url()
.should('include','?license=CC%20BY-NC-SA%26%26All%20Rights%20Reserved');

});

it('Clear all refinements', () => {

cy.url()
.should('include','?license=CC%20BY');

Expand All @@ -52,6 +50,30 @@ describe('Clear Filters',() => {
.should('not.contain','?');
});

it('Clear all refinements should not reset search, per page, and sorting', () => {
perPage(20);
sortBy('Word count');
search('education');

cy.url()
.should('contain', 'q=')
.should('contain', 'per_page=')
.should('contain', 'sort=')
.should('contain', 'license=');

cy.get('[data-cy=clear-all-filters]').click();

cy.algoliaQueryRequest('algoliaRequest');

cy.get('[data-cy=chip-filter]').should('have.length', 0);

cy.url()
.should('contain', 'q=')
.should('contain', 'per_page=')
.should('contain', 'sort=')
.should('not.contain', 'license=');
});

it('Clear applied filters for specific facet when clicking "Clear filter" button inside the facet', () => {
clickAccordionHeader('about');

Expand Down
33 changes: 8 additions & 25 deletions e2e/integration/filters/h5p.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
clickAccordionHeader,
encodeFacetFilterForURL,
fillNumericValue,
getNumericInput,
submitNumericFilter
Expand All @@ -13,8 +12,7 @@ describe('H5p Count Filters',() => {
clickAccordionHeader('h5pActivities');
});

it('Filter is applied & URL is updated by entering MIN value',()=>{

it('Filter is applied & URL is updated by entering MIN value',() => {
fillNumericValue('h5pActivities','min',100);

submitNumericFilter('h5pActivities');
Expand All @@ -26,14 +24,11 @@ describe('H5p Count Filters',() => {

cy.get(Elements.numberOfBooks)
.contains( 'Results: 52');

});


it('Filter is applied & URL is updated by entering MAX value',()=>{


fillNumericValue('h5pActivities','max',10);
it('Filter is applied & URL is updated by entering MAX value',() => {
fillNumericValue('h5pActivities', 'max', 10);

submitNumericFilter('h5pActivities');

Expand All @@ -43,12 +38,10 @@ describe('H5p Count Filters',() => {
.should('include','h5p=%3E%3D0%26%26%3C%3D10');

cy.get(Elements.numberOfBooks)
.contains( 'Results: 2038');

.contains( 'Results: 2,038');
});

it('Filter is applied & URL is updated by entering MIN and MAX values',()=>{

it('Filter is applied & URL is updated by entering MIN and MAX values',() => {
fillNumericValue('h5pActivities','min',10);

fillNumericValue('h5pActivities','max',20);
Expand All @@ -62,11 +55,9 @@ describe('H5p Count Filters',() => {

cy.get(Elements.numberOfBooks)
.contains( 'Results: 91');

});

it('Filter chips is applied/removed when include/exclude filter is applied/removed',()=>{

it('Filter chips is applied/removed when include/exclude filter is applied/removed',() => {
fillNumericValue('h5pActivities','min',10);

fillNumericValue('h5pActivities','max',20);
Expand All @@ -88,12 +79,9 @@ describe('H5p Count Filters',() => {
cy.algoliaQueryRequest('algoliaRequest');

cy.get('[data-cy=chip-filter]').should('have.length', 0);

});

it('Clicking a filter chip removes value from filter input and updates the URL',()=>{


it('Clicking a filter chip removes value from filter input and updates the URL',() => {
fillNumericValue('h5pActivities','min',10);

fillNumericValue('h5pActivities','max',20);
Expand All @@ -119,12 +107,9 @@ describe('H5p Count Filters',() => {

cy.get(Elements.numberOfBooks)
.contains( 'Results: 297');

});

it('Make sure that min does not exceed max and max does not exceed min and no negative numbers are accepted',()=>{


it('Make sure that min does not exceed max and max does not exceed min and no negative numbers are accepted',() => {
fillNumericValue('h5pActivities','min',-10);

submitNumericFilter('h5pActivities');
Expand Down Expand Up @@ -158,8 +143,6 @@ describe('H5p Count Filters',() => {
.should('include','h5p=%3E%3D100');

getNumericInput('h5pActivities','max').invoke('text').should('eq','');

});

});
});
4 changes: 2 additions & 2 deletions e2e/integration/filters/wordCount.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Word Count Filters',() => {
.should('include','words=%3E%3D1000');

cy.get(Elements.numberOfBooks)
.contains( 'Results: 1734');
.contains( 'Results: 1,734');

});

Expand Down Expand Up @@ -110,7 +110,7 @@ describe('Word Count Filters',() => {
.should('not.include','20000');

cy.get(Elements.numberOfBooks)
.contains( 'Results: 1734');
.contains( 'Results: 1,734');

});

Expand Down
19 changes: 4 additions & 15 deletions e2e/integration/headerStatCounts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,19 @@ import Elements from '../support/elements';
describe('Welcome header book and network counts', () => {
context('Desktop resolution', () => {
beforeEach(() => {

cy.get(Elements.search.input).as('inputSearch').clear();
cy.get(Elements.search.button).as('buttonSearch');

cy.wait('@fetching').then(({response}) => {

cy.wrap(response.body.nbHits).as('booksIndexed');
cy.wrap(Object.keys(response.body.facets.networkName).length).as('networksIndexed');

});

cy.get('[data-cy=total-books-indexed]').as('totalBooksIndexed');
cy.get('[data-cy=total-networks-indexed]').as('totalNetworksIndexed');
});

it('Shows the amount of books and networks indexed', function () {
cy.get('@totalBooksIndexed').should('have.text', this.booksIndexed);
cy.get('@totalNetworksIndexed').should('have.text', this.networksIndexed);
cy.get('@totalBooksIndexed').should('have.text', '2,329');
cy.get('@totalNetworksIndexed').should('have.text', 96);
});

it('Does not change indexed amount after performing a search', function() {
search('math science').then(() => {
cy.get('@totalBooksIndexed').should('have.text', this.booksIndexed);
cy.get('@totalNetworksIndexed').should('have.text', this.networksIndexed);
cy.get('@totalBooksIndexed').should('have.text', '2,329');
cy.get('@totalNetworksIndexed').should('have.text', 96);
});
});
});
Expand Down
Loading

0 comments on commit 9140f08

Please sign in to comment.