-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from DnD-Montreal/312-entry-management-cypres…
…s-tests Create Cypress Tests for Manage Entries
- Loading branch information
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
cypress/integration/Game Session Tracking/entry_management.js
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
describe('Manage Characters Test Suite', () => { | ||
let last_url = '' | ||
let number_of_entries = 0 | ||
|
||
before(() => { | ||
cy.refreshDatabase() | ||
cy.seed('FastSeeder') | ||
last_url = Cypress.Laravel.route('character.index') | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.seederLogin() | ||
cy.intercept('GET', last_url).as('last_url') | ||
cy.visit(last_url) | ||
cy.wait('@last_url') | ||
}) | ||
|
||
afterEach(() => { | ||
cy.url().then((urlString) => { | ||
last_url = urlString | ||
}) | ||
}) | ||
|
||
it('View Entries', () => { | ||
cy.get( | ||
`a[href^="${Cypress.config('baseUrl')}/${Cypress.Laravel.route( | ||
'character.index', | ||
)}/"]`, | ||
) | ||
.eq(1) | ||
.click() | ||
cy.contains('Date') | ||
cy.contains('Adventure Title') | ||
cy.contains('Session') | ||
cy.contains('Reward') | ||
cy.contains('Magic Items') | ||
cy.contains('Rows per page:') | ||
}) | ||
|
||
it('Create Character Entry', () => { | ||
cy.get('p[class^="MuiTablePagination-displayedRows"]') | ||
.invoke('text') | ||
.then((text) => { | ||
number_of_entries = parseInt(text.split(' ').pop()) + 1 | ||
}) | ||
.then(() => { | ||
cy.intercept('GET', `${Cypress.Laravel.route('entry.create')}*`).as( | ||
'entry_create_form', | ||
) | ||
cy.contains('button', 'Entry').click() | ||
cy.wait('@entry_create_form') | ||
cy.get('#adventures').click() | ||
cy.get('li[role=option]').eq(0).click() | ||
cy.get('#location').clear().type('Test location') | ||
cy.get('#length').clear().type('2') | ||
cy.get('#levels').clear().type('1') | ||
cy.get('#gp').clear().type('12') | ||
cy.get('#dungeon_master').clear().type('Test DM') | ||
cy.get('#notes').clear().type('Test notes') | ||
cy.contains('button', 'Continue').click() | ||
|
||
cy.contains('button', 'Creative') | ||
cy.contains('button', 'Flexible') | ||
cy.contains('button', 'Friendly') | ||
cy.contains('button', 'Helpful') | ||
cy.contains('button', 'Prepared') | ||
cy.contains('button', 'Continue').click() | ||
cy.contains('button', 'Create').click() | ||
cy.contains(`of ${number_of_entries}`) | ||
}) | ||
}) | ||
|
||
it('Edit Character Entry', () => { | ||
cy.get('svg[data-testid=EditIcon]').eq(0).click() | ||
cy.contains('Edit Entry') | ||
cy.get('#adventures').click() | ||
cy.get('li[role=option]').eq(1).click() | ||
cy.get('#location').clear().type('Other test location') | ||
cy.get('#length').clear().type('1') | ||
cy.get('#levels').clear().type('2') | ||
cy.get('#gp').clear().type('21') | ||
cy.get('#dungeon_master').clear().type('Other Test DM') | ||
cy.get('#notes').type('. More notes.') | ||
|
||
cy.contains('button', 'Continue').click() | ||
cy.contains('button', 'Save').click() | ||
cy.contains('Edit Entry').should('not.exist') | ||
}) | ||
|
||
it('Delete Character Entry', () => { | ||
let number_of_remaining_items = 0 | ||
cy.get('p[class^="MuiTablePagination-displayedRows"]') | ||
.invoke('text') | ||
.then((text) => { | ||
number_of_remaining_items = parseInt(text.split(' ').pop()) - 1 | ||
}) | ||
.then(() => { | ||
cy.get('svg[data-testid=DeleteIcon]').eq(0).click() | ||
cy.contains('button', 'Delete').click() | ||
cy.contains(`of ${number_of_remaining_items}`) | ||
}) | ||
}) | ||
}) |