-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add login tests * Add tests for client calendar add assignments * Add test for assignment allocation flow * Add feedback flow test * Ensure that auth spec is ran first Co-authored-by: elihuansen <[email protected]>
- Loading branch information
Showing
21 changed files
with
870 additions
and
30 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
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
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
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
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
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
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
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,5 @@ | ||
{ | ||
"includeShadowDom": true, | ||
"watchForFileChanges": false, | ||
"baseUrl": "http://localhost:3000" | ||
} |
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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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,39 @@ | ||
export function enterClientHomepage() { | ||
cy.visit('/'); | ||
cy.wait(1500); | ||
cy.get('[data-test=sign-in-email-input]').first().type('[email protected]', { force: true }); | ||
cy.get('[data-test=sign-in-password-input]').first().type('password123', { force: true }); | ||
cy.get('[data-test="sign-in-sign-in-button"]').first().click(); | ||
cy.wait(3000); | ||
} | ||
|
||
export function enterVolunteerHomepage() { | ||
cy.visit('/'); | ||
cy.wait(1500); | ||
cy.get('[data-test=sign-in-email-input]').first().type('[email protected]', { force: true }); | ||
cy.get('[data-test=sign-in-password-input]').first().type('password123', { force: true }); | ||
cy.get('[data-test="sign-in-sign-in-button"]').first().click(); | ||
cy.wait(3000); | ||
} | ||
|
||
export function enterAdminHomepage() { | ||
cy.visit('/'); | ||
cy.wait(1500); | ||
cy.get('[data-test=sign-in-email-input]').first().type('[email protected]', { force: true }); | ||
cy.get('[data-test=sign-in-password-input]').first().type('password123', { force: true }); | ||
cy.get('[data-test="sign-in-sign-in-button"]').first().click(); | ||
cy.wait(3000); | ||
} | ||
|
||
export function enterNonEnabledUserHomepage() { | ||
cy.visit('/'); | ||
cy.wait(1500); | ||
cy.get('[data-test=sign-in-email-input]').first().type('[email protected]', { force: true }); | ||
cy.get('[data-test=sign-in-password-input]').first().type('password123', { force: true }); | ||
cy.get('[data-test="sign-in-sign-in-button"]').first().click(); | ||
cy.wait(3000); | ||
} | ||
|
||
export function clickLogoutButton() { | ||
cy.get('[data-test=logout-button]').click({ force: true }); | ||
} |
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,40 @@ | ||
import { | ||
enterAdminHomepage, | ||
enterClientHomepage, | ||
enterNonEnabledUserHomepage, | ||
enterVolunteerHomepage, | ||
} from '../helpers/login-helpers'; | ||
|
||
describe('Login', () => { | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
}); | ||
|
||
it('should redirect to login page and show login form', () => { | ||
cy.location('pathname').should('equals', '/sign-in'); | ||
cy.get('amplify-authenticator').should('exist'); | ||
}); | ||
|
||
it('should show /registration for non-enabled users', () => { | ||
enterNonEnabledUserHomepage(); | ||
cy.location('pathname').should('equals', '/registration'); | ||
}); | ||
|
||
it('should show /client for clients', () => { | ||
enterClientHomepage(); | ||
cy.location('pathname').should('equals', '/client'); | ||
cy.get('.el-calendar__body'); | ||
cy.get('.el-table'); | ||
}); | ||
|
||
it('should show /admin for admin', () => { | ||
enterAdminHomepage(); | ||
cy.location('pathname').should('equals', '/admin'); | ||
}); | ||
|
||
it('should show /volunteer for volunteer', () => { | ||
enterVolunteerHomepage(); | ||
cy.location('pathname').should('equals', '/volunteer'); | ||
cy.get('.volunteer-cal'); | ||
}); | ||
}); |
86 changes: 86 additions & 0 deletions
86
sadeaf-web/cypress/integration/assignment-allocated-flow.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,86 @@ | ||
import { | ||
clickLogoutButton, | ||
enterAdminHomepage, | ||
enterClientHomepage, | ||
enterVolunteerHomepage, | ||
} from '../helpers/login-helpers'; | ||
|
||
describe('Correct Opt-In flow', () => { | ||
const newAssignmentName = 'Volunteer opt in success test'; | ||
|
||
it('should allow clients to create an assignment', () => { | ||
enterClientHomepage(); | ||
// open calendar on 21th day | ||
cy.get(':nth-child(5) > :nth-child(6) > .el-calendar-day').click(); | ||
// event name | ||
cy.get('.el-form > :nth-child(1) > .el-form-item__content > .el-input > .el-input__inner') | ||
.click() | ||
.type(newAssignmentName); | ||
// event skill | ||
cy.get('.el-checkbox-group > :nth-child(1)').click(); | ||
// event purpose | ||
cy.get('[data-test=client-create-event-purpose]').click().type('{downarrow}{enter}'); | ||
// event category | ||
cy.get('[data-test=client-create-event-category]').click().type('{downarrow}{enter}'); | ||
// event education | ||
cy.get('[data-test=client-create-event-education]').click().type('{downarrow}{enter}'); | ||
// assignment timing | ||
cy.get(':nth-child(2) > .el-form-item > .el-form-item__content > :nth-child(1) > .el-input__inner') | ||
.click() | ||
.focus() | ||
.type('{selectall}{backspace} 10:00 {enter}'); | ||
cy.get('.el-form-item__content > :nth-child(2) > .el-input__inner') | ||
.click() | ||
.focus() | ||
.type('{selectall}{backspace} 16:00 {enter}'); | ||
// address field | ||
cy.get('.el-autocomplete > .el-input > .el-input__inner') | ||
.click() | ||
.type('Singapore Management University') | ||
.wait(4000) | ||
.type('{downarrow}{enter}'); | ||
// submit | ||
cy.get('.el-form-item__content > .el-button-group > :nth-child(1)').click(); | ||
cy.get(':nth-child(5) > :nth-child(6) > .el-calendar-day').contains(newAssignmentName); | ||
clickLogoutButton(); | ||
}); | ||
|
||
it('should allow volunteers to opt in for an assignment created by a client', () => { | ||
enterVolunteerHomepage(); | ||
cy.get('#tab-pendingAssignments').click(); | ||
cy.get('#tab-pendingAssignments').click(); | ||
cy.wait(1000); | ||
cy.get(':nth-last-child(1) > .header > .el-button').eq(0).click({ force: true }); | ||
cy.get('.el-dialog__footer > div > .el-button').click(); | ||
cy.get('#tab-optInHistory').click(); | ||
cy.get('#pane-optInHistory > :nth-last-child(1) > .assignment-card').contains(newAssignmentName); | ||
clickLogoutButton(); | ||
}); | ||
|
||
it('should allow an admin to match the volunteer', () => { | ||
enterAdminHomepage(); | ||
cy.get( | ||
':nth-last-child(1)> .opt-in > .opt-in-details > .select-container > .el-select > .el-input > .el-input__inner' | ||
) | ||
.click() | ||
.type('{downarrow}{enter}', { force: true }); | ||
cy.get(':nth-last-child(1) > .opt-in > .opt-in-details > .select-container > .el-button').click({ force: true }); | ||
clickLogoutButton(); | ||
}); | ||
|
||
it('should show as matched on volunteer homepage', () => { | ||
enterVolunteerHomepage(); | ||
cy.get(':nth-child(5) > :nth-child(6) > .el-calendar-day').click(); | ||
cy.get('.el-dialog__body').contains(newAssignmentName); | ||
cy.get('.el-dialog__body').contains('MATCHED'); | ||
clickLogoutButton(); | ||
}); | ||
|
||
it('should show as matched on client homepage', () => { | ||
enterClientHomepage(); | ||
cy.get(':nth-child(5) > :nth-child(6) > .el-calendar-day').click(); | ||
cy.get('.el-dialog__body').contains(newAssignmentName); | ||
cy.get('.el-dialog__body').contains('MATCHED'); | ||
cy.get('.el-dialog__body').contains('Test Volunteer'); | ||
}); | ||
}); |
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,63 @@ | ||
import { enterClientHomepage } from '../helpers/login-helpers'; | ||
|
||
describe('Client Create New Assignment', () => { | ||
beforeEach(() => { | ||
enterClientHomepage(); | ||
// open calendar on 20th day | ||
cy.get(':nth-child(4) > :nth-child(5) > .el-calendar-day').click(); | ||
}); | ||
|
||
it('should error when submitting empty new assignment form', () => { | ||
cy.get('.el-form-item__content > .el-button-group > :nth-child(1)').click(); | ||
cy.get('.el-dialog__body').contains('Please enter a name for this Event'); | ||
cy.get('.el-dialog__body').contains('Please enter a purpose'); | ||
cy.get('.el-dialog__body').contains('Please enter an event skill!'); | ||
cy.get('.el-dialog__body').contains('Please enter a valid address'); | ||
cy.get('.el-dialog__body').contains('Minimum duration is 2 hours'); | ||
}); | ||
|
||
it('should error when submitting assignment timing <2hrs apart', () => { | ||
cy.get(':nth-child(2) > .el-form-item > .el-form-item__content > :nth-child(1) > .el-input__inner') | ||
.click() | ||
.focus() | ||
.type('{selectall}{backspace} 11:00'); | ||
cy.get('.el-form-item__content > :nth-child(2) > .el-input__inner') | ||
.click() | ||
.focus() | ||
.type('{selectall}{backspace} 12:00'); | ||
cy.get('.el-form-item__content > .el-button-group > :nth-child(1)').click(); | ||
cy.get('.el-dialog__body').contains('Minimum duration is 2 hours'); | ||
}); | ||
|
||
it('should submit the form when all fields are correctly filled', () => { | ||
// event name | ||
cy.get('.el-form > :nth-child(1) > .el-form-item__content > .el-input > .el-input__inner') | ||
.click() | ||
.type('Some new assignment'); | ||
// event skill | ||
cy.get('.el-checkbox-group > :nth-child(1)').click(); | ||
// event purpose | ||
cy.get('[data-test=client-create-event-purpose]').click().type('{downarrow}{enter}'); | ||
// event category | ||
cy.get('[data-test=client-create-event-category]').click().type('{downarrow}{enter}'); | ||
// event education | ||
cy.get('[data-test=client-create-event-education]').click().type('{downarrow}{enter}'); | ||
// assignment timing | ||
cy.get(':nth-child(2) > .el-form-item > .el-form-item__content > :nth-child(1) > .el-input__inner') | ||
.click() | ||
.focus() | ||
.type('{selectall}{backspace} 11:00 {enter}'); | ||
cy.get('.el-form-item__content > :nth-child(2) > .el-input__inner') | ||
.click() | ||
.focus() | ||
.type('{selectall}{backspace} 15:00 {enter}'); | ||
// address field | ||
cy.get('.el-autocomplete > .el-input > .el-input__inner') | ||
.click() | ||
.type('Singapore Management University') | ||
.wait(4000) | ||
.type('{downarrow}{enter}'); | ||
cy.get('.el-form-item__content > .el-button-group > :nth-child(1)').click(); | ||
cy.get(':nth-child(4) > :nth-child(5) > .el-calendar-day').contains('Some new assignment'); | ||
}); | ||
}); |
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,32 @@ | ||
import { enterAdminHomepage, enterClientHomepage } from '../helpers/login-helpers'; | ||
|
||
describe('Feedback Flow', () => { | ||
it('should allow clients to give feedback to fully completed assignments', () => { | ||
// note: there is already a fully completed assigment in mockdata.sql called Feedback Event | ||
enterClientHomepage(); | ||
cy.get('[data-test=client-feedback]').click(); | ||
cy.get( | ||
'.el-table__fixed-body-wrapper > .el-table__body > tbody > .el-table__row > .el-table_2_column_15 > .cell > .el-button' | ||
).click(); | ||
cy.get(':nth-child(3) > .el-form-item__content > .el-radio-group > [tabindex="0"] > .el-radio__input').click(); | ||
cy.get(':nth-child(4) > .el-form-item__content > .el-radio-group > [tabindex="0"] > .el-radio__input').click(); | ||
cy.get(':nth-child(7) > .el-form-item__content > .el-radio-group > [tabindex="0"] > .el-radio__input').click(); | ||
cy.get(':nth-child(8) > .el-form-item__content > .el-radio-group > [tabindex="0"] > .el-radio__input').click(); | ||
cy.get(':nth-child(12) > .el-form-item__content > .el-radio-group > [tabindex="0"] > .el-radio__input').click(); | ||
cy.get( | ||
':nth-child(19) > .el-form-item__content > .el-radio-group > :nth-child(1) > .el-radio > .el-radio__input' | ||
).click(); | ||
cy.get( | ||
':nth-child(20) > .el-form-item__content > .el-radio-group > :nth-child(1) > .el-radio > .el-radio__input' | ||
).click(); | ||
cy.get('.el-form-item__content > .el-button').click(); | ||
}); | ||
|
||
it('should allow admins to see completed feedback', () => { | ||
enterAdminHomepage(); | ||
cy.get('[data-test=admin-feedback]').click(); | ||
cy.get('.main').contains('Feedback Event'); | ||
cy.get('.main').contains('Test Client'); | ||
cy.get('.main').contains('Test Volunteer'); | ||
}); | ||
}); |
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,21 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
}; |
Oops, something went wrong.