-
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 #529 from DnD-Montreal/439-cypress-league-admin-event
Create Cypress Tests for League Admin Event Crud
- Loading branch information
Showing
4 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
cypress/integration/Event Management/league_admin_event_crud.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,56 @@ | ||
describe('League Admin Event CRUD Test Suite', () => { | ||
const event_title = 'Test Event' | ||
const event_edited_title = 'Test Edited Event' | ||
const event_location = 'Cypress Town' | ||
const event_edited_location = 'Cypress Town Edited' | ||
let last_url = '' | ||
|
||
before(() => { | ||
cy.refreshDatabase() | ||
cy.seed('FastSeeder') | ||
last_url = `${Cypress.config('baseUrl')}/admin/dashboard/` | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.seederLoginLeagueAdmin() | ||
cy.intercept('GET', last_url).as('last_url') | ||
cy.visit(last_url) | ||
cy.wait('@last_url') | ||
}) | ||
|
||
it('Event Index', () => { | ||
cy.contains('Events').click() | ||
cy.get('table[id="crudTable"]') | ||
last_url = `${Cypress.config('baseUrl')}/admin/event/` | ||
}) | ||
|
||
it('Event Creation', () => { | ||
cy.get(`a[href="${Cypress.config('baseUrl')}/admin/event/create"]`).click() | ||
cy.get('input[name="title"]').type(event_title) | ||
cy.get('textarea[name="description"]').type(event_title) | ||
cy.get('input[name="location"]').type(event_location) | ||
cy.get('button[type="submit"]').click() | ||
cy.contains(event_title) | ||
}) | ||
|
||
it('Event Delete', () => { | ||
cy.get('a[data-button-type="delete"]').eq(0).click() | ||
cy.contains('Item Deleted') | ||
}) | ||
|
||
it('Event Edit', () => { | ||
cy.get('i[class="la la-edit"]').eq(0).parent().click() | ||
cy.get('input[name="title"]').clear().type(event_edited_title) | ||
cy.get('textarea[name="description"]').clear().type(event_edited_title) | ||
cy.get('input[name="location"]').clear().type(event_edited_location) | ||
cy.get('button[type="submit"]').click() | ||
cy.contains(event_edited_title) | ||
}) | ||
|
||
it('Event Detail', () => { | ||
cy.get('i[class="la la-eye"]').eq(0).parent().click() | ||
cy.contains('Description:') | ||
cy.contains('Location:') | ||
cy.contains('Title:') | ||
}) | ||
}) |
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 |
---|---|---|
|
@@ -14,3 +14,20 @@ Cypress.Commands.add('seederLogin', () => { | |
cy.wait('@login') | ||
cy.get('[data-cy="user"]').should('contain', testusername) | ||
}) | ||
|
||
Cypress.Commands.add('seederLoginLeagueAdmin', () => { | ||
const testuser_email = '[email protected]' | ||
const testuser_password = 'password' | ||
const testusername = 'Test account' | ||
cy.intercept('GET', '/').as('landingpage') | ||
cy.intercept('POST', '/login').as('login') | ||
cy.visit('/') | ||
cy.wait('@landingpage') | ||
cy.get('[data-testid="PersonIcon"]').click() | ||
cy.contains('button', 'LOGIN').click() | ||
cy.get('#email').type(testuser_email) | ||
cy.get('#password').clear().type(testuser_password) | ||
cy.get('button[type="submit"]').click() | ||
cy.wait('@login') | ||
cy.get('[data-cy="user"]').should('contain', testusername) | ||
}) |
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 |
---|---|---|
|
@@ -35,7 +35,15 @@ public function run() | |
$dndmtl = League::factory()->create([ | ||
'name' => "DnD MTL" | ||
]); | ||
$users = User::factory(10)->create()->prepend($defaultUser); | ||
|
||
$leagueAdminUser = User::factory() | ||
->hasAttached(Role::where('name', Role::LEAGUE_ADMIN)->first(), ['league_id' => $dndmtl->id]) | ||
->create([ | ||
'email' => '[email protected]', | ||
'name' => "League Admin Test account" | ||
]); | ||
|
||
$users = User::factory(10)->create()->prepend($defaultUser)->prepend($leagueAdminUser); | ||
$dm = User::factory(5)->create(); | ||
$events = Event::factory(5)->create([ | ||
'league_id' => $dndmtl->id | ||
|
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 |
---|---|---|
|
@@ -33,7 +33,15 @@ public function run() | |
$dndmtl = League::factory()->create([ | ||
'name' => "DnD MTL" | ||
]); | ||
$users = User::factory(3)->create()->prepend($defaultUser); | ||
|
||
$leagueAdminUser = User::factory() | ||
->hasAttached(Role::where('name', Role::LEAGUE_ADMIN)->first(), ['league_id' => $dndmtl->id]) | ||
->create([ | ||
'email' => '[email protected]', | ||
'name' => "League Admin Test account" | ||
]); | ||
|
||
$users = User::factory(3)->create()->prepend($defaultUser)->prepend($leagueAdminUser); | ||
$dm = User::factory(2)->create(); | ||
$events = Event::factory(2)->create([ | ||
'league_id' => $dndmtl->id | ||
|