Skip to content

Commit 9140f08

Browse files
authored
Merge pull request #375 from pressbooks/dev
v2.2 release
2 parents aeabfff + 3c184ac commit 9140f08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+428
-273
lines changed

.github/workflows/pipeline.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
steps:
2424
- name: Checkout code
2525
uses: actions/checkout@v2
26+
with:
27+
fetch-depth: 2
2628

2729
- uses: actions/setup-node@v2
2830
with:
@@ -42,7 +44,13 @@ jobs:
4244
- name: Lint
4345
run: npm run lint
4446

47+
- uses: marceloprado/has-changed-path@v1
48+
id: code-changes
49+
with:
50+
paths: src e2e
51+
4552
- name: e2e Tests
53+
if: steps.code-changes.outputs.changed == 'true'
4654
uses: cypress-io/github-action@v2
4755
with:
4856
start: npm run dev

e2e/fixtures/bookCard.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"network": "pressbooks.lib.vt.edu | Pressbooks at Virginia Tech",
33
"title": "Significant Statistics",
4-
"wordCount": "275135",
4+
"wordCount": "275,135",
55
"size": "233.53",
66
"h5pActivities": "191",
77
"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",
@@ -15,4 +15,4 @@
1515
"h5p": "/assets/images/h5p.png",
1616
"notOriginal": "/assets/images/is-child.png",
1717
"cover": "https://pressbooks.lib.vt.edu/app/uploads/sites/12/2021/01/Option-2.png"
18-
}
18+
}

e2e/fixtures/selectableFilters.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"urlAlias": "subj",
3030
"search": {
3131
"searchTerm": "math",
32-
"filter": "Mathematical logic"
32+
"filter": "Applied mathematics"
3333
},
3434
"bookCards": {
3535
"filters": [ "Sociology", "Chemistry" ],
@@ -123,7 +123,7 @@
123123
"Dini Afrika ya Mashariki",
124124
"Jinsia na Mapenzi Afrika ya Mashariki"
125125
],
126-
"count": 2182
126+
"count": "2,182"
127127
}
128128
},
129129
"Collection": {

e2e/integration/bookCards.spec.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ describe('Book cards', function () {
7979
.first()
8080
.should('include.text','Written specifically for students in Boise State University’s Bachelor of Applied Science');
8181
});
82-
it('Check recommended attribute in the book cards', () => {
83-
search('Open Music Theory');
84-
cy.get(Elements.booksCards.recommended)
85-
.should('include.text', 'Recommended');
86-
});
8782
it('Check all book cards attributes from a particular book', () => {
8883
const attributesToCheck = [
8984
{

e2e/integration/filters/bookCardFilters.spec.js

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,40 @@ import Elements from '../../support/elements';
22

33
describe('BookCard Collections Filters', () => {
44
context('Desktop Resolution', () => {
5-
6-
it('Recommended filter toggle', () => {
7-
8-
cy.get(Elements.booksCards.recommended).should('have.class','text-pb-red');
9-
10-
cy.get(Elements.booksCards.recommended).click();
11-
12-
cy.algoliaQueryRequest('algoliaRequest');
13-
14-
cy.url().should('include','recommended=true');
15-
16-
cy.get(Elements.booksCards.recommended).should('have.length',10)
17-
.should('not.have.class','text-pb-red')
18-
.should('have.class','text-white');
19-
20-
cy.get(Elements.booksCards.recommended).first().click();
21-
22-
cy.algoliaQueryRequest('algoliaRequest');
23-
24-
cy.get(Elements.booksCards.recommended)
25-
.should('not.have.class','text-white');
26-
27-
});
28-
295
it('Collection filter toggle', () => {
306

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

339
cy.algoliaQueryRequest('algoliaRequest');
3410

35-
cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
36-
.parent()
37-
.next()
38-
.find('button')
11+
cy.get(Elements.booksCards.bookTags)
12+
.eq(1)
13+
.find('li:first-child button')
3914
.should('have.class', 'text-pb-red');
40-
cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
41-
.parent()
42-
.next()
43-
.next()
44-
.find('button')
15+
16+
cy.get(Elements.booksCards.bookTags)
17+
.eq(1)
18+
.find('li:nth-of-type(2) button')
4519
.should('have.class', 'text-white');
4620

47-
cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
48-
.parent()
49-
.next()
50-
.find('button')
21+
cy.get(Elements.booksCards.bookTags)
22+
.eq(1)
23+
.find('li:first-child button')
5124
.click();
5225

5326
cy.algoliaQueryRequest('algoliaRequest');
5427

55-
cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
56-
.parent()
57-
.next()
58-
.find('button')
59-
.should('have.class', 'text-white');
60-
61-
cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
62-
.parent()
63-
.next()
64-
.find('button')
28+
cy.get(Elements.booksCards.bookTags)
29+
.eq(1)
30+
.find('li:first-child button')
31+
.should('have.class', 'text-white')
6532
.click();
6633

6734
cy.algoliaQueryRequest('algoliaRequest');
6835

69-
cy.get(Elements.booksCards.recommended+':nth-of-type(1)')
70-
.parent()
71-
.next()
72-
.find('button')
36+
cy.get(Elements.booksCards.bookTags)
37+
.eq(1)
38+
.find('li:first-child button')
7339
.should('have.class', 'text-pb-red');
7440

7541
cy.url().should('include','?collec=OpenStax');

e2e/integration/filters/clearFilters.spec.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import {
22
clickAccordionClearFilter,
33
clickAccordionHeader,
4-
clickFilter
4+
clickFilter,
5+
perPage,
6+
search,
7+
sortBy
58
} from '../../support/common';
69
import Elements from '../../support/elements';
710

811
describe('Clear Filters',() => {
912
context('Desktop Resolution', () => {
1013
beforeEach(() => {
11-
1214
clickAccordionHeader('licenseCode');
1315

1416
clickFilter('licenseCode','cc-by', 'include');
1517
clickFilter('licenseCode','cc-by-nc-sa', 'include');
1618
clickFilter('licenseCode','all-rights-reserved', 'include');
17-
1819
});
1920

2021
it('Clear chip refinement', () => {
21-
2222
cy.url()
2323
.should('include','?license=CC%20BY');
2424

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

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

3837
it('Clear all refinements', () => {
39-
4038
cy.url()
4139
.should('include','?license=CC%20BY');
4240

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

53+
it('Clear all refinements should not reset search, per page, and sorting', () => {
54+
perPage(20);
55+
sortBy('Word count');
56+
search('education');
57+
58+
cy.url()
59+
.should('contain', 'q=')
60+
.should('contain', 'per_page=')
61+
.should('contain', 'sort=')
62+
.should('contain', 'license=');
63+
64+
cy.get('[data-cy=clear-all-filters]').click();
65+
66+
cy.algoliaQueryRequest('algoliaRequest');
67+
68+
cy.get('[data-cy=chip-filter]').should('have.length', 0);
69+
70+
cy.url()
71+
.should('contain', 'q=')
72+
.should('contain', 'per_page=')
73+
.should('contain', 'sort=')
74+
.should('not.contain', 'license=');
75+
});
76+
5577
it('Clear applied filters for specific facet when clicking "Clear filter" button inside the facet', () => {
5678
clickAccordionHeader('about');
5779

e2e/integration/filters/h5p.spec.js

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
clickAccordionHeader,
3-
encodeFacetFilterForURL,
43
fillNumericValue,
54
getNumericInput,
65
submitNumericFilter
@@ -13,8 +12,7 @@ describe('H5p Count Filters',() => {
1312
clickAccordionHeader('h5pActivities');
1413
});
1514

16-
it('Filter is applied & URL is updated by entering MIN value',()=>{
17-
15+
it('Filter is applied & URL is updated by entering MIN value',() => {
1816
fillNumericValue('h5pActivities','min',100);
1917

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

2725
cy.get(Elements.numberOfBooks)
2826
.contains( 'Results: 52');
29-
3027
});
3128

3229

33-
it('Filter is applied & URL is updated by entering MAX value',()=>{
34-
35-
36-
fillNumericValue('h5pActivities','max',10);
30+
it('Filter is applied & URL is updated by entering MAX value',() => {
31+
fillNumericValue('h5pActivities', 'max', 10);
3732

3833
submitNumericFilter('h5pActivities');
3934

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

4540
cy.get(Elements.numberOfBooks)
46-
.contains( 'Results: 2038');
47-
41+
.contains( 'Results: 2,038');
4842
});
4943

50-
it('Filter is applied & URL is updated by entering MIN and MAX values',()=>{
51-
44+
it('Filter is applied & URL is updated by entering MIN and MAX values',() => {
5245
fillNumericValue('h5pActivities','min',10);
5346

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

6356
cy.get(Elements.numberOfBooks)
6457
.contains( 'Results: 91');
65-
6658
});
6759

68-
it('Filter chips is applied/removed when include/exclude filter is applied/removed',()=>{
69-
60+
it('Filter chips is applied/removed when include/exclude filter is applied/removed',() => {
7061
fillNumericValue('h5pActivities','min',10);
7162

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

9081
cy.get('[data-cy=chip-filter]').should('have.length', 0);
91-
9282
});
9383

94-
it('Clicking a filter chip removes value from filter input and updates the URL',()=>{
95-
96-
84+
it('Clicking a filter chip removes value from filter input and updates the URL',() => {
9785
fillNumericValue('h5pActivities','min',10);
9886

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

120108
cy.get(Elements.numberOfBooks)
121109
.contains( 'Results: 297');
122-
123110
});
124111

125-
it('Make sure that min does not exceed max and max does not exceed min and no negative numbers are accepted',()=>{
126-
127-
112+
it('Make sure that min does not exceed max and max does not exceed min and no negative numbers are accepted',() => {
128113
fillNumericValue('h5pActivities','min',-10);
129114

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

160145
getNumericInput('h5pActivities','max').invoke('text').should('eq','');
161-
162146
});
163-
164147
});
165148
});

e2e/integration/filters/wordCount.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Word Count Filters',() => {
1919
.should('include','words=%3E%3D1000');
2020

2121
cy.get(Elements.numberOfBooks)
22-
.contains( 'Results: 1734');
22+
.contains( 'Results: 1,734');
2323

2424
});
2525

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

112112
cy.get(Elements.numberOfBooks)
113-
.contains( 'Results: 1734');
113+
.contains( 'Results: 1,734');
114114

115115
});
116116

e2e/integration/headerStatCounts.spec.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,19 @@ import Elements from '../support/elements';
44
describe('Welcome header book and network counts', () => {
55
context('Desktop resolution', () => {
66
beforeEach(() => {
7-
8-
cy.get(Elements.search.input).as('inputSearch').clear();
9-
cy.get(Elements.search.button).as('buttonSearch');
10-
11-
cy.wait('@fetching').then(({response}) => {
12-
13-
cy.wrap(response.body.nbHits).as('booksIndexed');
14-
cy.wrap(Object.keys(response.body.facets.networkName).length).as('networksIndexed');
15-
16-
});
17-
187
cy.get('[data-cy=total-books-indexed]').as('totalBooksIndexed');
198
cy.get('[data-cy=total-networks-indexed]').as('totalNetworksIndexed');
209
});
2110

2211
it('Shows the amount of books and networks indexed', function () {
23-
cy.get('@totalBooksIndexed').should('have.text', this.booksIndexed);
24-
cy.get('@totalNetworksIndexed').should('have.text', this.networksIndexed);
12+
cy.get('@totalBooksIndexed').should('have.text', '2,329');
13+
cy.get('@totalNetworksIndexed').should('have.text', 96);
2514
});
2615

2716
it('Does not change indexed amount after performing a search', function() {
2817
search('math science').then(() => {
29-
cy.get('@totalBooksIndexed').should('have.text', this.booksIndexed);
30-
cy.get('@totalNetworksIndexed').should('have.text', this.networksIndexed);
18+
cy.get('@totalBooksIndexed').should('have.text', '2,329');
19+
cy.get('@totalNetworksIndexed').should('have.text', 96);
3120
});
3221
});
3322
});

0 commit comments

Comments
 (0)