-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
18 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 |
---|---|---|
|
@@ -29,15 +29,37 @@ describe('/account/settings', () => { | |
const username = Cypress.env('E2E_USERNAME') ?? 'user'; | ||
const password = Cypress.env('E2E_PASSWORD') ?? 'user'; | ||
|
||
beforeEach(() => { | ||
let account: { email: string }; | ||
|
||
before(() => { | ||
cy.login(username, password); | ||
cy.visit('/account/settings'); | ||
cy.authenticatedRequest({ | ||
method: 'GET', | ||
url: '/api/account', | ||
}).then(({ body }) => { | ||
account = body; | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.login(username, password); | ||
cy.visit('/account/settings'); | ||
cy.get(emailSettingsSelector).should('have.value', account.email); | ||
|
||
cy.intercept('POST', '/api/account').as('settingsSave'); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.login(username, password); | ||
cy.authenticatedRequest({ | ||
method: 'POST', | ||
url: '/api/account', | ||
body: account, | ||
}) | ||
.its('status') | ||
.should('eq', 200); | ||
}); | ||
|
||
it('should be accessible through menu', () => { | ||
cy.visit(''); | ||
cy.clickOnSettingsItem(); | ||
|
@@ -49,44 +71,40 @@ describe('/account/settings', () => { | |
// need to modify email because default email does not match regex in vue | ||
cy.get(emailSettingsSelector).clear().type('[email protected]'); | ||
cy.get(submitSettingsSelector).click(); | ||
cy.wait('@settingsSave').then(({ response }) => expect(response.statusCode).to.equal(200)); | ||
cy.wait('@settingsSave').then(({ response }) => expect(response?.statusCode).to.equal(200)); | ||
}); | ||
|
||
it("should be able to change 'user' lastname settings", () => { | ||
cy.get(lastNameSettingsSelector).clear().type('retspihj'); | ||
// need to modify email because default email does not match regex in vue | ||
cy.get(emailSettingsSelector).clear().type('[email protected]'); | ||
cy.get(submitSettingsSelector).click(); | ||
cy.wait('@settingsSave').then(({ response }) => expect(response.statusCode).to.equal(200)); | ||
cy.wait('@settingsSave').then(({ response }) => expect(response?.statusCode).to.equal(200)); | ||
}); | ||
|
||
it("should be able to change 'user' email settings", () => { | ||
cy.get(emailSettingsSelector).should('have.value', '[email protected]'); | ||
cy.get(emailSettingsSelector).clear().type('[email protected]'); | ||
cy.get(submitSettingsSelector).click(); | ||
cy.wait('@settingsSave').then(({ response }) => expect(response.statusCode).to.equal(200)); | ||
cy.wait('@settingsSave').then(({ response }) => expect(response?.statusCode).to.equal(200)); | ||
}); | ||
|
||
describe('if there is another user with an email', () => { | ||
let adminEmail: string; | ||
|
||
before(() => { | ||
cy.login(adminUsername, adminPassword); | ||
cy.visit('/account/settings'); | ||
cy.get(emailSettingsSelector).should('have.value', 'admin@localhost'); | ||
cy.get(emailSettingsSelector).clear().type('[email protected]'); | ||
cy.intercept({ | ||
method: 'POST', | ||
cy.authenticatedRequest({ | ||
method: 'GET', | ||
url: '/api/account', | ||
times: 1, | ||
}).as('settingsSave'); | ||
cy.get(submitSettingsSelector).click(); | ||
cy.wait('@settingsSave'); | ||
}).then(({ body }) => { | ||
adminEmail = body.email; | ||
}); | ||
}); | ||
|
||
it("should not be able to change 'user' email to same value", () => { | ||
cy.get(emailSettingsSelector).should('have.value', '[email protected]'); | ||
cy.get(emailSettingsSelector).clear().type('[email protected]'); | ||
cy.get(emailSettingsSelector).clear().type(adminEmail); | ||
cy.get(submitSettingsSelector).click(); | ||
cy.wait('@settingsSave').then(({ response }) => expect(response.statusCode).to.equal(400)); | ||
cy.wait('@settingsSave').then(({ response }) => expect(response?.statusCode).to.equal(400)); | ||
}); | ||
}); | ||
}); |