-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* added narrative tests * Prelim changes * neatened up v1 use functions * removed visit / * Removed comment * Updated test * moved out html
- Loading branch information
1 parent
05d7f5f
commit 8095f29
Showing
1 changed file
with
24 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
describe('Narrative', function () { | ||
function loopThroughNarrative(narrativeItems) { | ||
const itemsCount = Object.keys(narrativeItems).length | ||
const itemsCount = Object.keys(narrativeItems).length; | ||
for (let i = 0; i < itemsCount-1; i++) { | ||
cy.get('.narrative__controls-right').eq(1).click() | ||
cy.get('.narrative__content-item.is-active').should('contain', narrativeItems[i+1].title) | ||
cy.get('.narrative__progress').eq(i+1).should('have.class', 'is-selected') | ||
} | ||
cy.get('.narrative__controls-right.is-disabled').should('exist') | ||
cy.get('.narrative__controls-right').eq(1).click(); | ||
cy.get('.narrative__content-item.is-active').should('contain', narrativeItems[i+1].title); | ||
cy.get('.narrative__progress').eq(i+1).should('have.class', 'is-selected'); | ||
}; | ||
cy.get('.narrative__controls-right.is-disabled').should('exist'); | ||
for (let i = itemsCount-2; i >= 0; i--) { | ||
cy.get('.narrative__controls-left').eq(1).click() | ||
cy.get('.narrative__content-item.is-active').should('contain', narrativeItems[i].title) | ||
cy.get('.narrative__progress').eq(i).should('have.class', 'is-selected') | ||
} | ||
cy.get('.narrative__controls-left.is-disabled').should('exist') | ||
} | ||
cy.get('.narrative__controls-left').eq(1).click(); | ||
cy.get('.narrative__content-item.is-active').should('contain', narrativeItems[i].title); | ||
cy.get('.narrative__progress').eq(i).should('have.class', 'is-selected'); | ||
}; | ||
cy.get('.narrative__controls-left.is-disabled').should('exist'); | ||
}; | ||
|
||
beforeEach(function () { | ||
cy.getData() | ||
cy.getData(); | ||
}); | ||
|
||
it('should display the narrative component', function () { | ||
const narrativeComponents = this.data.components.filter((component) => component._component === 'narrative') | ||
narrativeComponents.forEach((narrativeComponent) => { | ||
const narrativeComponents = this.data.components.filter(component => component._component === 'narrative'); | ||
const stripHtml = cy.helpers.stripHtml; | ||
narrativeComponents.forEach(narrativeComponent => { | ||
cy.visit(`/#/preview/${narrativeComponent._id}`); | ||
const bodyWithoutHtml = narrativeComponent.body.replace(/<[^>]*>/g, '') | ||
|
||
cy.testContainsOrNotExists('.narrative__title', narrativeComponent.displayTitle) | ||
cy.testContainsOrNotExists('.narrative__body', bodyWithoutHtml) | ||
cy.testContainsOrNotExists('.narrative__instruction', narrativeComponent.instruction) | ||
cy.testContainsOrNotExists('.narrative__body', stripHtml(narrativeComponent.body)); | ||
cy.testContainsOrNotExists('.narrative__title', stripHtml(narrativeComponent.displayTitle)); | ||
cy.testContainsOrNotExists('.narrative__instruction', stripHtml(narrativeComponent.instruction)); | ||
|
||
cy.testContainsOrNotExists('.narrative__content-item.is-active', narrativeComponent._items[0].title) | ||
cy.get('.narrative__progress').eq(0).should('have.class', 'is-selected') | ||
cy.get('.narrative__controls-left.is-disabled').should('exist') | ||
cy.testContainsOrNotExists('.narrative__content-item.is-active', narrativeComponent._items[0].title); | ||
cy.get('.narrative__progress').eq(0).should('have.class', 'is-selected'); | ||
cy.get('.narrative__controls-left.is-disabled').should('exist'); | ||
|
||
loopThroughNarrative(narrativeComponent._items) | ||
}) | ||
loopThroughNarrative(narrativeComponent._items); | ||
}); | ||
}); | ||
}); |