2023-02-16 09:23:27 +00:00
import { commonSelectors } from "Selectors/common" ;
import { commonText } from "Texts/common" ;
2023-06-14 09:30:21 +00:00
import { dashboardText } from "Texts/dashboard" ;
2023-02-16 09:23:27 +00:00
import {
verifyandModifyUserRole ,
verifyandModifySizeOftheCompany ,
} from "Support/utils/selfHostSignUp" ;
2024-04-30 13:08:54 +00:00
import { navigateToManageUsers , logout } from "Support/utils/common" ;
import { ssoSelector } from "Selectors/manageSSO" ;
import { ssoText } from "Texts/manageSSO" ;
2024-12-03 06:48:49 +00:00
import { onboardingSelectors } from "Selectors/onboarding" ;
2025-08-03 07:09:18 +00:00
import { fetchAndVisitInviteLink } from "Support/utils/manageUsers" ;
2024-12-03 06:48:49 +00:00
2023-02-16 09:23:27 +00:00
export const verifyConfirmEmailPage = ( email ) => {
cy . get ( commonSelectors . pageLogo ) . should ( "be.visible" ) ;
2024-12-03 06:48:49 +00:00
cy . get ( '[data-cy="check-your-mail-header"]' ) . verifyVisibleElement (
2023-02-16 09:23:27 +00:00
"have.text" ,
commonText . emailPageHeader
) ;
cy . get ( commonSelectors . onboardingPageDescription ) . verifyVisibleElement (
"have.text" ,
commonText . emailPageDescription ( email )
) ;
cy . get ( commonSelectors . spamMessage ) . verifyVisibleElement (
"have.text" ,
commonText . spamMessage
) ;
cy . get ( commonSelectors . onboardingSeperator ) . should ( "be.visible" ) ;
cy . get ( commonSelectors . onboardingSeperatorText ) . verifyVisibleElement (
"have.text" ,
commonText . onboardingSeperatorText
) ;
2024-12-03 06:48:49 +00:00
2023-02-16 09:23:27 +00:00
cy . get ( commonSelectors . resendEmailButton ) . should ( "be.visible" ) ;
2024-12-03 06:48:49 +00:00
cy . get ( '[data-cy="back-to-signup"]' ) . verifyVisibleElement (
2023-02-16 09:23:27 +00:00
"have.text" ,
2024-12-03 06:48:49 +00:00
"Back to sign up"
2023-02-16 09:23:27 +00:00
) ;
} ;
2025-08-03 07:09:18 +00:00
export const verifyOnboardingQuestions = ( workspaceName ) => {
bannerElementsVerification ( ) ;
onboardingStepOne ( ) ;
onboardingStepTwo ( workspaceName ) ;
onboardingStepThree ( ) ;
2023-02-16 09:23:27 +00:00
} ;
export const verifyInvalidInvitationLink = ( ) => {
cy . get ( commonSelectors . pageLogo ) . should ( "be.visible" ) ;
2024-12-09 07:40:09 +00:00
// cy.get(commonSelectors.emailImage).should("be.visible");
2023-02-16 09:23:27 +00:00
cy . get ( commonSelectors . onboardingPageHeader ) . verifyVisibleElement (
"have.text" ,
commonText . inalidInvitationLinkHeader
) ;
cy . get ( commonSelectors . onboardingPageDescription ) . verifyVisibleElement (
"have.text" ,
commonText . inalidInvitationLinkDescription
) ;
2024-12-03 06:48:49 +00:00
// cy.get(commonSelectors.backtoSignUpButton).verifyVisibleElement(
// "have.text",
// commonText.backtoSignUpButton
// );
2023-02-16 09:23:27 +00:00
} ;
2023-06-14 09:30:21 +00:00
2025-01-15 11:55:24 +00:00
export const userSignUp = ( fullName , email , workspaceName = "test" ) => {
2023-06-14 09:30:21 +00:00
let invitationLink ;
2025-08-03 07:09:18 +00:00
cy . intercept ( "GET" , "/api/login-configs/public" ) . as ( "publicConfig" ) ;
2023-07-05 08:38:18 +00:00
cy . visit ( "/" ) ;
2024-12-09 11:30:36 +00:00
cy . wait ( "@publicConfig" ) ;
2025-08-03 07:09:18 +00:00
cy . wait ( 2000 ) ;
2025-01-27 06:40:35 +00:00
cy . get ( commonSelectors . createAnAccountLink , { timout : 10000 } ) . click ( ) ;
2025-01-15 11:55:24 +00:00
cy . wait ( 2000 ) ;
2025-08-03 07:09:18 +00:00
cy . get ( onboardingSelectors . nameInput , { timeout : 1000 } ) . should (
"not.be.disabled"
) ;
2024-12-04 06:47:53 +00:00
cy . get ( onboardingSelectors . nameInput ) . clear ( ) ;
cy . get ( onboardingSelectors . nameInput ) . type ( fullName ) ;
2024-12-09 11:30:36 +00:00
cy . clearAndType ( onboardingSelectors . loginEmailInput , email ) ;
cy . clearAndType ( onboardingSelectors . loginPasswordInput , commonText . password ) ;
2023-06-14 09:30:21 +00:00
cy . get ( commonSelectors . signUpButton ) . click ( ) ;
2025-01-15 11:55:24 +00:00
cy . wait ( 2500 ) ;
2025-08-03 07:09:18 +00:00
cy . task ( "dbConnection" , {
2023-06-14 09:30:21 +00:00
dbconfig : Cypress . env ( "app_db" ) ,
sql : ` select invitation_token from users where email=' ${ email } '; ` ,
} ) . then ( ( resp ) => {
invitationLink = ` /invitations/ ${ resp . rows [ 0 ] . invitation _token } ` ;
2023-06-16 05:09:20 +00:00
cy . visit ( invitationLink ) ;
2025-01-15 11:55:24 +00:00
cy . wait ( 2500 ) ;
2024-01-23 12:34:59 +00:00
} ) ;
2025-08-03 07:09:18 +00:00
if ( Cypress . env ( "environment" ) == "Cloud" ) {
cy . clearAndType (
'[data-cy="onboarding-workspace-name-input"]' ,
workspaceName
) ;
2025-01-15 11:55:24 +00:00
cy . get ( '[data-cy="onboarding-submit-button"]' ) . click ( ) ;
}
2024-01-23 12:34:59 +00:00
} ;
export const inviteUser = ( firstName , email ) => {
2025-01-16 06:08:50 +00:00
cy . apiUserInvite ( firstName , email ) ;
2024-01-23 12:34:59 +00:00
fetchAndVisitInviteLink ( email ) ;
2024-04-30 13:08:54 +00:00
cy . wait ( 1000 ) ;
2024-12-09 07:40:09 +00:00
cy . get ( onboardingSelectors . loginPasswordInput ) . should ( "be.visible" ) ;
cy . clearAndType ( onboardingSelectors . loginPasswordInput , "password" ) ;
2024-05-16 00:19:10 +00:00
// cy.intercept("GET", "/api/organizations").as("org");
2024-12-09 07:40:09 +00:00
cy . get ( commonSelectors . continueButton ) . click ( ) ;
2024-05-16 00:19:10 +00:00
cy . wait ( 2000 ) ;
2024-01-23 12:34:59 +00:00
cy . get ( commonSelectors . acceptInviteButton ) . click ( ) ;
} ;
export const addNewUser = ( firstName , email ) => {
navigateToManageUsers ( ) ;
inviteUser ( firstName , email ) ;
} ;
2024-12-18 09:53:40 +00:00
export const roleBasedOnboarding = ( firstName , email , userRole ) => {
navigateToManageUsers ( ) ;
2025-01-16 06:08:50 +00:00
cy . apiUserInvite ( firstName , email , userRole ) ;
2024-12-18 09:53:40 +00:00
fetchAndVisitInviteLink ( email ) ;
cy . wait ( 1000 ) ;
cy . get ( onboardingSelectors . loginPasswordInput ) . should ( "be.visible" ) ;
cy . clearAndType ( onboardingSelectors . loginPasswordInput , "password" ) ;
// cy.intercept("GET", "/api/organizations").as("org");
cy . get ( commonSelectors . continueButton ) . click ( ) ;
cy . wait ( 2000 ) ;
cy . get ( commonSelectors . acceptInviteButton ) . click ( ) ;
} ;
2024-04-30 13:08:54 +00:00
export const visitWorkspaceInvitation = ( email , workspaceName ) => {
let workspaceId , userId , url , organizationToken ;
2025-08-03 07:09:18 +00:00
cy . task ( "dbConnection" , {
2024-04-30 13:08:54 +00:00
dbconfig : Cypress . env ( "app_db" ) ,
sql : ` select id from organizations where name=' ${ workspaceName } '; ` ,
} ) . then ( ( resp ) => {
workspaceId = resp . rows [ 0 ] . id ;
2025-08-03 07:09:18 +00:00
cy . task ( "dbConnection" , {
2024-04-30 13:08:54 +00:00
dbconfig : Cypress . env ( "app_db" ) ,
sql : ` select id from users where email=' ${ email } '; ` ,
} ) . then ( ( resp ) => {
userId = resp . rows [ 0 ] . id ;
2025-08-03 07:09:18 +00:00
cy . task ( "dbConnection" , {
2024-04-30 13:08:54 +00:00
dbconfig : Cypress . env ( "app_db" ) ,
sql : ` select invitation_token from organization_users where organization_id= ' ${ workspaceId } ' AND user_id=' ${ userId } '; ` ,
} ) . then ( ( resp ) => {
2024-05-27 11:55:49 +00:00
organizationToken = resp . rows [ 0 ] . invitation _token ;
url = ` /organization-invitations/ ${ organizationToken } ?oid= ${ workspaceId } ` ;
logout ( ) ;
cy . visit ( url ) ;
2024-04-30 13:08:54 +00:00
} ) ;
} ) ;
} ) ;
} ;
export const SignUpPageElements = ( ) => {
cy . get ( commonSelectors . pageLogo ) . should ( "be.visible" ) ;
2024-12-09 07:40:09 +00:00
cy . get ( commonSelectors . signUpSectionHeader ) . verifyVisibleElement (
2024-04-30 13:08:54 +00:00
"have.text" ,
"Sign up"
) ;
cy . get ( commonSelectors . signUpButton ) . verifyVisibleElement (
"have.text" ,
2024-12-03 06:48:49 +00:00
"Sign up"
2024-04-30 13:08:54 +00:00
) ;
2024-12-03 06:48:49 +00:00
// cy.get('[data-cy="signup-info"]').should(($el) => {
// expect($el.contents().first().text().trim()).to.eq(
// commonText.signInRedirectText
// );
// });
2024-12-23 09:21:27 +00:00
cy . get ( onboardingSelectors . signupNameLabel ) . verifyVisibleElement (
"have.text" ,
"Name *"
) ;
cy . get ( onboardingSelectors . nameInput ) . should ( "be.visible" ) ;
2024-12-03 06:48:49 +00:00
cy . get ( onboardingSelectors . emailLabel ) . verifyVisibleElement (
"have.text" ,
"Email *"
) ;
2024-12-09 07:40:09 +00:00
// cy.get(commonSelectors.loginPasswordLabel).verifyVisibleElement("have.text", "Password *");
2024-12-03 06:48:49 +00:00
2024-12-09 07:40:09 +00:00
cy . get ( onboardingSelectors . loginPasswordInput ) . should ( "be.visible" ) ;
2024-12-03 06:48:49 +00:00
2024-04-30 13:08:54 +00:00
cy . get ( commonSelectors . signInRedirectLink ) . verifyVisibleElement (
"have.text" ,
commonText . signInRedirectLink
) ;
cy . get ( commonSelectors . signUpTermsHelperText ) . should ( ( $el ) => {
expect ( $el . contents ( ) . first ( ) . text ( ) . trim ( ) ) . to . eq (
commonText . signUpTermsHelperText
) ;
} ) ;
cy . get ( commonSelectors . termsOfServiceLink )
. verifyVisibleElement ( "have.text" , commonText . termsOfServiceLink )
. and ( "have.attr" , "href" )
. and ( "equal" , "https://www.tooljet.com/terms" ) ;
cy . get ( commonSelectors . privacyPolicyLink )
. verifyVisibleElement ( "have.text" , commonText . privacyPolicyLink )
. and ( "have.attr" , "href" )
. and ( "equal" , "https://www.tooljet.com/privacy" ) ;
cy . get ( "body" ) . then ( ( $el ) => {
if ( $el . text ( ) . includes ( "Google" ) ) {
cy . get ( ssoSelector . googleSSOText ) . verifyVisibleElement (
"have.text" ,
ssoText . googleSignUpText
) ;
cy . get ( ssoSelector . gitSSOText ) . verifyVisibleElement (
"have.text" ,
ssoText . gitSignUpText
) ;
cy . get ( commonSelectors . onboardingSeperator ) . should ( "be.visible" ) ;
cy . get ( commonSelectors . onboardingSeperatorText ) . verifyVisibleElement (
"have.text" ,
commonText . onboardingSeperatorText
) ;
}
} ) ;
} ;
2024-05-27 11:55:49 +00:00
export const signUpLink = ( email ) => {
2024-12-23 09:21:27 +00:00
let invitationLink ;
2025-08-03 07:09:18 +00:00
cy . task ( "dbConnection" , {
2024-05-27 11:55:49 +00:00
dbconfig : Cypress . env ( "app_db" ) ,
sql : ` select invitation_token from users where email=' ${ email } '; ` ,
} ) . then ( ( resp ) => {
invitationLink = ` /invitations/ ${ resp . rows [ 0 ] . invitation _token } ` ;
cy . visit ( invitationLink ) ;
2024-12-09 07:40:09 +00:00
cy . wait ( 3000 ) ;
2025-08-03 07:09:18 +00:00
2024-05-27 11:55:49 +00:00
} ) ;
2024-12-23 09:21:27 +00:00
} ;
2025-02-17 12:17:15 +00:00
export const bannerElementsVerification = ( ) => {
const bannerElements = [
{ selector : commonSelectors . HostBanner } ,
{ selector : commonSelectors . pageLogo } ,
{ selector : onboardingSelectors . stepsDetails } ,
] ;
bannerElements . forEach ( ( element ) => {
cy . get ( element . selector ) . should ( "be.visible" ) ;
} ) ;
2025-08-03 07:09:18 +00:00
} ;
export const enableInstanceSignUp = ( allow = true ) => {
const value = allow ? "true" : "false" ;
cy . task ( "dbConnection" , {
dbconfig : Cypress . env ( "app_db" ) ,
sql : ` UPDATE instance_settings SET value = ' ${ value } ' WHERE key = 'ALLOW_PERSONAL_WORKSPACE';
UPDATE instance _settings SET value = '${value}' WHERE key = 'ENABLE_SIGNUP' ; ` ,
} ) ;
} ;
export const onboardingStepOne = ( ) => {
const companyPageTexts = [
{
selector : onboardingSelectors . tellUsAbit ,
text : "Tell us a bit about yourself" ,
} ,
{
selector : onboardingSelectors . pageDescription ,
text : "This information will help us improve ToolJet" ,
} ,
{
selector : '[data-cy="onboarding-company-name-label"]' ,
text : "Company name *" ,
} ,
{
selector : '[data-cy="onboarding-build-purpose-label"]' ,
text : "What would you like to build on ToolJet? *" ,
} ,
] ;
companyPageTexts . forEach ( ( item ) => {
cy . get ( item . selector ) . should ( "be.visible" ) . and ( "have.text" , item . text ) ;
} ) ;
cy . get ( onboardingSelectors . companyNameInput ) . should ( "be.visible" ) ;
cy . get ( onboardingSelectors . buildPurposeInput ) . should ( "be.visible" ) ;
cy . get ( onboardingSelectors . onboardingSubmitButton ) . verifyVisibleElement (
"have.attr" ,
"disabled"
) ;
cy . get ( onboardingSelectors . companyNameInput ) . type ( "Tooljet" ) ;
cy . get ( onboardingSelectors . onboardingSubmitButton ) . should (
"have.attr" ,
"disabled"
) ;
cy . get ( onboardingSelectors . buildPurposeInput ) . type ( "Exploring" ) ;
cy . get ( onboardingSelectors . onboardingSubmitButton ) . verifyVisibleElement (
"have.text" ,
"Continue"
) ;
cy . get ( onboardingSelectors . onboardingSubmitButton )
. should ( "be.enabled" )
. click ( ) ;
} ;
export const onboardingStepTwo = ( workspaceName = "My workspace" ) => {
cy . get ( commonSelectors . setUpworkspaceCheckPoint )
. should ( "be.visible" )
. and ( "have.text" , "Set up your workspace!" ) ;
cy . get ( onboardingSelectors . pageDescription ) . verifyVisibleElement (
"have.text" ,
"Set up workspaces to manage users, applications & resources across various teams"
) ;
cy . get ( commonSelectors . workspaceNameInputLabel )
. should ( "be.visible" )
. and ( "have.text" , commonText . workspaceNameInputLabel ) ;
cy . clearAndType ( commonSelectors . workspaceNameInputField , workspaceName ) ;
cy . get ( commonSelectors . OnbordingContinue )
. verifyVisibleElement ( "have.text" , "Continue" )
. click ( ) ;
} ;
export const onboardingStepThree = ( ) => {
cy . get (
` [data-cy="we've-created-a-sample-application-for-you!-header"] `
) . verifyVisibleElement (
"have.text" ,
"We've created a sample application for you!"
) ;
cy . get ( onboardingSelectors . pageDescription ) . verifyVisibleElement (
"have.text" ,
"The sample application comes with a sample PostgreSQL database for you to play around with. You can also get started quickly with pre-built applications from our template collection!"
) ;
cy . get ( onboardingSelectors . onboardingSubmitButton )
. verifyVisibleElement ( "have.text" , "Continue" )
. click ( ) ;
} ;