Skip to content

Commit

Permalink
Merge pull request #634 from SlateFoundation/tests/request-hardening
Browse files Browse the repository at this point in the history
fix(e2e): add wait/assert for all XHR calls [SCHOOL-144]
  • Loading branch information
themightychris authored Dec 18, 2021
2 parents 698f10a + 4dbc0c6 commit 522a1e0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cypress/integration/teacher_demonstrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@ describe('Teacher demonstrations test', () => {
});

it('View single demonstration rubric as teacher', () => {
// set up XHR monitors
cy.intercept('GET', '/cbl/dashboards/demonstrations/teacher/bootstrap').as('getBootstrapData');
cy.intercept('GET', '/cbl/content-areas?summary=true').as('getCompetencyAreas');
cy.intercept('GET', '/people/*student-lists').as('getMyStudentLists');
cy.intercept('GET', '/people/*student-lists?sections=all').as('getAllStudentLists');
cy.intercept('GET', '/cbl/student-competencies?*').as('getStudentCompetencies');


// open student demonstrations dashboard
cy.visit('/cbl/dashboards/demonstrations/teacher');

// ensure bootstrap data is loaded
cy.wait('@getBootstrapData');
cy.get('@getBootstrapData.all').should('have.length', 1);

// verify teacher redirect
cy.location('hash').should('eq', '#_');
cy.get('.slate-appcontainer-bodyWrap .slate-placeholder ')
Expand All @@ -28,6 +39,10 @@ describe('Teacher demonstrations test', () => {
// click the selector
cy.get('#' + rubricSelector.el.dom.id).click();

// ensure competency areas are loaded
cy.wait('@getCompetencyAreas');
cy.get('@getCompetencyAreas.all').should('have.length', 1);

// verify and click first element of picker dropdown
cy.get('#' + rubricSelector.getPicker().id + ' .x-boundlist-item')
.contains('English Language Arts')
Expand All @@ -45,11 +60,19 @@ describe('Teacher demonstrations test', () => {
.focused()
.type('Exa');

// ensure student lists are loaded
cy.wait('@getMyStudentLists');
cy.get('@getMyStudentLists.all').should('have.length', 1);

// verify and click first element of picker dropdown
cy.get('#' + studentSelector.getPicker().id)
.contains('Example School')
.click();

// ensure student competencies are loaded
cy.wait('@getStudentCompetencies');
cy.get('@getStudentCompetencies.all').should('have.length', 1);

// verify hash updates
cy.location('hash').should('eq', '#ELA/group:example_school');

Expand All @@ -69,12 +92,20 @@ describe('Teacher demonstrations test', () => {
.closest('button')
.click('center', { force: true }) //scrollIntoView does not appear to be working

// ensure student lists are loaded
cy.wait('@getAllStudentLists');
cy.get('@getAllStudentLists.all').should('have.length', 1);

// verify and click empty section element of picker dropdown
cy.get('#' + studentSelector.getPicker().id)
.contains('Jarvus Innovations')
.scrollIntoView()
.click({force: true}); //scrollIntoView does not appear to be working

// ensure student competencies are loaded
cy.wait('@getStudentCompetencies');
cy.get('@getStudentCompetencies.all').should('have.length', 2);

// verify hash updates
cy.location('hash').should('eq', '#ELA/group:jarvus');

Expand Down

0 comments on commit 522a1e0

Please sign in to comment.