-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: for signup set make organization name optional and set a defaul…
…t one (#21083) * Set a default org name if they don't enter one * Add default org name tests * Name org input optional * Remove .only that the posthog-bot added * Don't show optional for organization name input * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Clean up first / last name inputs on sign up / settings * Update UI snapshots for `chromium` (1) * Update cypress signup tests * Update python tests for signup * Update UI snapshots for `chromium` (1) * Update signup.cy.ts * Update signupLogic.ts --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
06fdcb2
commit 804bcbb
Showing
9 changed files
with
78 additions
and
20 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 |
---|---|---|
|
@@ -12,7 +12,7 @@ describe('Signup', () => { | |
cy.get('[data-attr=signup-email]').type('[email protected]').should('have.value', '[email protected]') | ||
cy.get('[data-attr=password]').type('12345678').should('have.value', '12345678') | ||
cy.get('[data-attr=signup-start]').click() | ||
cy.get('[data-attr=signup-first-name]').type('Jane').should('have.value', 'Jane') | ||
cy.get('[data-attr=signup-name]').type('Jane Doe').should('have.value', 'Jane Doe') | ||
cy.get('[data-attr=signup-organization-name]').type('Hogflix Movies').should('have.value', 'Hogflix Movies') | ||
cy.get('[data-attr=signup-role-at-organization]').click() | ||
cy.get('.Popover li:first-child').click() | ||
|
@@ -39,18 +39,53 @@ describe('Signup', () => { | |
cy.get('.text-danger').should('not.contain', 'Password must be at least 8 characters') // Validation error removed on keystroke | ||
}) | ||
|
||
it('Can create user account', () => { | ||
it('Can create user account with first name, last name and organization name', () => { | ||
cy.intercept('POST', '/api/signup/').as('signupRequest') | ||
|
||
const email = `new_user+${Math.floor(Math.random() * 10000)}@posthog.com` | ||
cy.get('[data-attr=signup-email]').type(email).should('have.value', email) | ||
cy.get('[data-attr=password]').type('12345678').should('have.value', '12345678') | ||
cy.get('[data-attr=signup-start]').click() | ||
cy.get('[data-attr=signup-first-name]').type('Alice').should('have.value', 'Alice') | ||
cy.get('[data-attr=signup-name]').type('Alice Bob').should('have.value', 'Alice Bob') | ||
cy.get('[data-attr=signup-organization-name]').type('Hogflix SpinOff').should('have.value', 'Hogflix SpinOff') | ||
cy.get('[data-attr=signup-role-at-organization]').click() | ||
cy.get('.Popover li:first-child').click() | ||
cy.get('[data-attr=signup-role-at-organization]').contains('Engineering') | ||
cy.get('[data-attr=signup-submit]').click() | ||
|
||
cy.wait('@signupRequest').then((interception) => { | ||
expect(interception.request.body).to.have.property('first_name') | ||
expect(interception.request.body.first_name).to.equal('Alice') | ||
expect(interception.request.body).to.have.property('last_name') | ||
expect(interception.request.body.last_name).to.equal('Bob') | ||
expect(interception.request.body).to.have.property('organization_name') | ||
expect(interception.request.body.organization_name).to.equal('Hogflix SpinOff') | ||
}) | ||
|
||
// lazy regex for a guid | ||
cy.location('pathname').should('match', /\/verify_email\/[a-zA-Z0-9_.-]*/) | ||
}) | ||
|
||
it('Can create user account with just a first name', () => { | ||
cy.intercept('POST', '/api/signup/').as('signupRequest') | ||
|
||
const email = `new_user+${Math.floor(Math.random() * 10000)}@posthog.com` | ||
cy.get('[data-attr=signup-email]').type(email).should('have.value', email) | ||
cy.get('[data-attr=password]').type('12345678').should('have.value', '12345678') | ||
cy.get('[data-attr=signup-start]').click() | ||
cy.get('[data-attr=signup-name]').type('Alice').should('have.value', 'Alice') | ||
cy.get('[data-attr=signup-role-at-organization]').click() | ||
cy.get('.Popover li:first-child').click() | ||
cy.get('[data-attr=signup-role-at-organization]').contains('Engineering') | ||
cy.get('[data-attr=signup-submit]').click() | ||
|
||
cy.wait('@signupRequest').then((interception) => { | ||
expect(interception.request.body).to.have.property('first_name') | ||
expect(interception.request.body.first_name).to.equal('Alice') | ||
expect(interception.request.body).to.not.have.property('last_name') | ||
expect(interception.request.body).to.not.have.property('organization_name') | ||
}) | ||
|
||
// lazy regex for a guid | ||
cy.location('pathname').should('match', /\/verify_email\/[a-zA-Z0-9_.-]*/) | ||
}) | ||
|
@@ -74,7 +109,7 @@ describe('Signup', () => { | |
cy.get('.Toastify [data-attr="error-toast"]').contains('Inactive social login session.') | ||
}) | ||
|
||
it.only('Shows redirect notice if redirecting for maintenance', () => { | ||
it('Shows redirect notice if redirecting for maintenance', () => { | ||
cy.intercept('**/decide/*', (req) => | ||
req.reply( | ||
decideResponse({ | ||
|
Binary file modified
BIN
+2.19 KB
(100%)
frontend/__snapshots__/scenes-other-settings--settings-user--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.02 KB
(100%)
frontend/__snapshots__/scenes-other-settings--settings-user--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -43,6 +43,7 @@ def test_api_sign_up(self, mock_capture): | |
"/api/signup/", | ||
{ | ||
"first_name": "John", | ||
"last_name": "Doe", | ||
"email": "[email protected]", | ||
"password": "notsecure", | ||
"organization_name": "Hedgehogs United, LLC", | ||
|
@@ -62,8 +63,8 @@ def test_api_sign_up(self, mock_capture): | |
"id": user.pk, | ||
"uuid": str(user.uuid), | ||
"distinct_id": user.distinct_id, | ||
"last_name": "", | ||
"first_name": "John", | ||
"last_name": "Doe", | ||
"email": "[email protected]", | ||
"redirect_url": "/", | ||
"is_email_verified": False, | ||
|
@@ -72,6 +73,7 @@ def test_api_sign_up(self, mock_capture): | |
|
||
# Assert that the user was properly created | ||
self.assertEqual(user.first_name, "John") | ||
self.assertEqual(user.last_name, "Doe") | ||
self.assertEqual(user.email, "[email protected]") | ||
self.assertFalse(user.email_opt_in) | ||
self.assertTrue(user.is_staff) # True because this is the first user in the instance | ||
|
@@ -223,7 +225,7 @@ def test_signup_minimum_attrs(self, mock_capture): | |
self.assertEqual(user.first_name, "Jane") | ||
self.assertEqual(user.email, "[email protected]") | ||
self.assertTrue(user.email_opt_in) # Defaults to True | ||
self.assertEqual(organization.name, "Jane") | ||
self.assertEqual(organization.name, f"{user.first_name}'s Organization") | ||
self.assertTrue(user.is_staff) # True because this is the first user in the instance | ||
|
||
# Assert that the sign up event & identify calls were sent to PostHog analytics | ||
|