-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NV-3735]: Improve launch darkly (#5517)
Use async LaunchDarkly initialization, but ensure it works with self-hosted Why? Conditional routing (enabling routes based on feature flags) for Information Architecture is inconsistent, and causes issues with certain routes Resolves NV-3735
- Loading branch information
1 parent
070e138
commit 8c4490d
Showing
16 changed files
with
291 additions
and
50 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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import * as capitalize from 'lodash.capitalize'; | ||
import { JobTitleEnum, jobTitleToLabelMapper } from '@novu/shared'; | ||
import { FeatureFlagsKeysEnum, JobTitleEnum, jobTitleToLabelMapper } from '@novu/shared'; | ||
|
||
describe('User Sign-up and Login', function () { | ||
beforeEach(function () { | ||
cy.mockFeatureFlags({ [FeatureFlagsKeysEnum.IS_INFORMATION_ARCHITECTURE_ENABLED]: false }); | ||
}); | ||
describe('Sign up', function () { | ||
beforeEach(function () { | ||
cy.clearDatabase(); | ||
|
@@ -10,7 +13,9 @@ describe('User Sign-up and Login', function () { | |
|
||
it('should allow a visitor to sign-up, login, and logout', function () { | ||
cy.intercept('**/organization/**/switch').as('appSwitch'); | ||
cy.visit('/auth/signup'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/signup'); | ||
}); | ||
cy.getByTestId('fullName').type('Test User'); | ||
cy.getByTestId('email').type('[email protected]'); | ||
cy.getByTestId('password').type('usEr_password_123!'); | ||
|
@@ -30,7 +35,9 @@ describe('User Sign-up and Login', function () { | |
}); | ||
|
||
it('should show account already exists when signing up with already registered mail', function () { | ||
cy.visit('/auth/signup'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/signup'); | ||
}); | ||
cy.getByTestId('fullName').type('Test User'); | ||
cy.getByTestId('email').type('[email protected]'); | ||
cy.getByTestId('password').type('usEr_password_123!'); | ||
|
@@ -40,7 +47,9 @@ describe('User Sign-up and Login', function () { | |
}); | ||
|
||
it('should show invalid email error when signing up with invalid email', function () { | ||
cy.visit('/auth/signup'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/signup'); | ||
}); | ||
cy.getByTestId('fullName').type('Test User'); | ||
cy.getByTestId('email').type('[email protected]'); | ||
cy.getByTestId('password').type('usEr_password_123!'); | ||
|
@@ -54,7 +63,9 @@ describe('User Sign-up and Login', function () { | |
if (!isCI) return; | ||
|
||
cy.intercept('**/organization/**/switch').as('appSwitch'); | ||
cy.visit('/auth/signup'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/signup'); | ||
}); | ||
|
||
cy.loginWithGitHub(); | ||
|
||
|
@@ -82,7 +93,9 @@ describe('User Sign-up and Login', function () { | |
const gitHubUserEmail = Cypress.env('GITHUB_USER_EMAIL'); | ||
|
||
cy.intercept('**/organization/**/switch').as('appSwitch'); | ||
cy.visit('/auth/signup'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/signup'); | ||
}); | ||
cy.getByTestId('fullName').type('Test User'); | ||
cy.getByTestId('email').type(gitHubUserEmail); | ||
cy.getByTestId('password').type('usEr_password_123!'); | ||
|
@@ -115,13 +128,19 @@ describe('User Sign-up and Login', function () { | |
}); | ||
|
||
it('should request a password reset flow', function () { | ||
cy.visit('/auth/reset/request'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/reset/request'); | ||
}); | ||
cy.getByTestId('email').type(this.session.user.email); | ||
cy.getByTestId('submit-btn').click(); | ||
cy.getByTestId('success-screen-reset').should('be.visible'); | ||
|
||
cy.task('passwordResetToken', this.session.user._id).then((token) => { | ||
cy.visit('/auth/reset/' + token); | ||
}); | ||
|
||
// unfortunately there seems to be a timing issue in in which inputs are disabled | ||
cy.wait(500); | ||
cy.getByTestId('password').type('A123e3e3e3!'); | ||
cy.getByTestId('password-repeat').focus().type('A123e3e3e3!'); | ||
|
||
|
@@ -137,18 +156,24 @@ describe('User Sign-up and Login', function () { | |
|
||
it('should redirect to the dashboard page when a token exists in query', function () { | ||
cy.initializeSession({ disableLocalStorage: true }).then((session) => { | ||
cy.visit('/auth/login?token=' + session.token); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/login?token=' + session.token); | ||
}); | ||
cy.location('pathname').should('equal', '/workflows'); | ||
}); | ||
}); | ||
|
||
it('should be redirect login with no auth', function () { | ||
cy.visit('/'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/'); | ||
}); | ||
cy.location('pathname').should('equal', '/auth/login'); | ||
}); | ||
|
||
it('should successfully login the user', function () { | ||
cy.visit('/auth/login'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/login'); | ||
}); | ||
|
||
cy.getByTestId('email').type('[email protected]'); | ||
cy.getByTestId('password').type('123qwe!@#'); | ||
|
@@ -157,7 +182,9 @@ describe('User Sign-up and Login', function () { | |
}); | ||
|
||
it('should show incorrect email or password error when authenticating with bad credentials', function () { | ||
cy.visit('/auth/login'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/login'); | ||
}); | ||
|
||
cy.getByTestId('email').type('[email protected]'); | ||
cy.getByTestId('password').type('123456'); | ||
|
@@ -166,7 +193,9 @@ describe('User Sign-up and Login', function () { | |
}); | ||
|
||
it('should show invalid email error when authenticating with invalid email', function () { | ||
cy.visit('/auth/login'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/login'); | ||
}); | ||
|
||
cy.getByTestId('email').type('[email protected]'); | ||
cy.getByTestId('password').type('123456'); | ||
|
@@ -175,7 +204,9 @@ describe('User Sign-up and Login', function () { | |
}); | ||
|
||
it('should show incorrect email or password error when authenticating with non-existing email', function () { | ||
cy.visit('/auth/login'); | ||
cy.waitLoadFeatureFlags(() => { | ||
cy.visit('/auth/login'); | ||
}); | ||
|
||
cy.getByTestId('email').type('[email protected]'); | ||
cy.getByTestId('password').type('123456'); | ||
|
@@ -197,6 +228,8 @@ describe('User Sign-up and Login', function () { | |
cy.getByTestId('password').type('123qwe!@#'); | ||
cy.getByTestId('submit-btn').click(); | ||
|
||
cy.waitLoadFeatureFlags(); | ||
|
||
cy.location('pathname').should('equal', '/workflows'); | ||
|
||
// setting current time in future, to simulate expired token | ||
|
@@ -207,6 +240,8 @@ describe('User Sign-up and Login', function () { | |
|
||
cy.visit('/subscribers'); | ||
|
||
cy.waitLoadFeatureFlags(); | ||
|
||
// checking if token is removed from local storage | ||
cy.getLocalStorage('auth_token').should('be.null'); | ||
// checking if user is redirected to login page | ||
|
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
Oops, something went wrong.