Skip to content

Commit

Permalink
Fix guest update profile
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWeathers committed Apr 11, 2023
1 parent dfcf085 commit cf30fe2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type userprofileUpdateRequestBody struct {
Locale string `json:"locale" validate:"len=2"`
Company string `json:"company" validate:"max=256"`
JobTitle string `json:"jobTitle" validate:"max=128"`
Email string `json:"email" validate:"email"`
Email string `json:"email" validate:"omitempty,email"`
}

// handleUserProfileUpdate attempts to update users profile
Expand Down
52 changes: 52 additions & 0 deletions e2e/tests/profile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,58 @@ test.describe('User Profile page', () => {
).not.toBeVisible()
})

test('Guest User can update profile', async ({
guestPage,
}) => {
const testCompanyName = "Test Update Company Guest"
const testJobTitle = "Test Engineer Guest"
const profilePage = new ProfilePage(guestPage.page)
await profilePage.goto()

await expect(profilePage.page.locator('[name=yourCompany]')).toHaveValue("")

await profilePage.page.locator('[name=yourCountry]').selectOption("US")
await profilePage.page.locator('[name=yourCompany]').fill(testCompanyName)
await profilePage.page.locator('[name=yourJobTitle]').fill(testJobTitle)

await profilePage.page
.locator('[name=updateProfile] [type=submit]')
.click()

await expect(profilePage.page.locator('[name=yourCountry]')).toHaveValue("US")
await expect(profilePage.page.locator('[name=yourCompany]')).toHaveValue(testCompanyName)
await expect(profilePage.page.locator('[name=yourJobTitle]')).toHaveValue(testJobTitle)

await expect(profilePage.page.locator(`[data-testid="notification-msg"]`))
.toHaveText("Profile updated")
})

test('Registered User can update profile', async ({
registeredPage,
}) => {
const testCompanyName = "Test Update Company"
const testJobTitle = "Test Engineer"
const profilePage = new ProfilePage(registeredPage.page)
await profilePage.goto()

await expect(profilePage.page.locator('[name=yourCompany]')).toHaveValue("")

await profilePage.page.locator('[name=yourCountry]').selectOption("US")
await profilePage.page.locator('[name=yourCompany]').fill(testCompanyName)
await profilePage.page.locator('[name=yourJobTitle]').fill(testJobTitle)

await profilePage.page
.locator('[name=updateProfile] [type=submit]')
.click()

await expect(profilePage.page.locator('[name=yourCountry]')).toHaveValue("US")
await expect(profilePage.page.locator('[name=yourCompany]')).toHaveValue(testCompanyName)
await expect(profilePage.page.locator('[name=yourJobTitle]')).toHaveValue(testJobTitle)

await expect(profilePage.page.locator(`[data-testid="notification-msg"]`))
.toHaveText("Profile updated")
})

test('Verified user should display existing API keys', async ({verifiedPage}) => {
const apiKeyName = 'Display API Keys Test'
const profilePage = new ProfilePage(verifiedPage.page)
Expand Down

0 comments on commit cf30fe2

Please sign in to comment.