From f20f976847e39d7d1e13c6df9fb7cf36bda572cb Mon Sep 17 00:00:00 2001 From: aliraza556 Date: Sun, 27 Oct 2024 10:51:25 +0500 Subject: [PATCH] fix(cypress): test --- cypress/e2e/admin/signin.cy.ts | 12 +++-- src/components/App/index.tsx | 53 ++++++++++++------- src/components/AppContainer/index.tsx | 30 +++-------- .../OnboardingFlow/GraphDetailsStep/index.tsx | 7 ++- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/cypress/e2e/admin/signin.cy.ts b/cypress/e2e/admin/signin.cy.ts index 0fa11ba33..310bff01b 100644 --- a/cypress/e2e/admin/signin.cy.ts +++ b/cypress/e2e/admin/signin.cy.ts @@ -12,16 +12,20 @@ describe('Admin Login', () => { const title = `Testing NavFiber` const description = 'Testing Graph Description' - cy.get('[data-testid="onboarding-title"]').should('have.text', 'Welcome to SecondBrain!') + // Open settings modal + cy.get('div[data-testid="settings-modal"]').should('be.visible').click() + + // Asserting the settings label text + cy.get('[data-testid="setting-label"]').should('have.text', 'Admin Settings') // Efficiently interact with the about title - cy.get('#cy-graph-title-id').should('be.visible').click().type('{selectAll}').type(title) + cy.get('#cy-about-title-id').should('be.visible').click().type('{selectAll}').type(title) // Efficiently interact with the about description - cy.get('#cy-graph-description-id').should('be.visible').click().type('{selectAll}').type(description) + cy.get('#cy-about-id').should('be.visible').click().type('{selectAll}').type(description) // Submit the form - cy.get('#onboarding-confirm-cta').click() + cy.get('#add-node-submit-cta').click() cy.wait('@updateAbout') cy.wait(1000) diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index bf355b12b..8265c14b9 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -15,6 +15,7 @@ import { useAppStore } from '~/stores/useAppStore' import { useDataStore } from '~/stores/useDataStore' import { useFeatureFlagStore } from '~/stores/useFeatureFlagStore' import { useUpdateSelectedNode } from '~/stores/useGraphStore' +import { useModal } from '~/stores/useModalStore' import { useTeachStore } from '~/stores/useTeachStore' import { useUserStore } from '~/stores/useUserStore' import { @@ -29,6 +30,7 @@ import { colors } from '~/utils/colors' import { updateBudget } from '~/utils/setBudget' import version from '~/utils/versionHelper' import { ModalsContainer } from '../ModalsContainer' +import { OnboardingModal } from '../ModalsContainer/OnboardingFlow' import { ActionsToolbar } from './ActionsToolbar' import { AppBar } from './AppBar' import { DeviceCompatibilityNotice } from './DeviceCompatibilityNotification' @@ -56,9 +58,10 @@ const LazySideBar = lazy(() => import('./SideBar').then(({ SideBar }) => ({ defa export const App = () => { const [searchParams] = useSearchParams() const query = searchParams.get('q') - const { setBudget, setNodeCount } = useUserStore((s) => s) + const { setBudget, setNodeCount, isAdmin } = useUserStore((s) => s) const queueRef = useRef(null) const timerRef = useRef(null) + const { open, visible } = useModal('onboardingFlow') const { setSidebarOpen, @@ -68,6 +71,7 @@ export const App = () => { setTranscriptOpen, universeQuestionIsOpen, setUniverseQuestionIsOpen, + appMetaData, } = useAppStore((s) => s) const setTeachMeAnswer = useTeachStore((s) => s.setTeachMeAnswer) @@ -322,10 +326,16 @@ export const App = () => { }, [runningProjectId, setRunningProjectMessages]) useEffect(() => { - if (!splashDataLoading) { - setUniverseQuestionIsOpen() + if (isAdmin && !appMetaData?.title && !visible) { + open() // Open the onboarding modal if conditions are met } - }, [setUniverseQuestionIsOpen, splashDataLoading]) + }, [isAdmin, appMetaData?.title, open, visible]) + + useEffect(() => { + if (!splashDataLoading && !visible) { + setUniverseQuestionIsOpen() // Set universe question open only if onboarding is not visible + } + }, [setUniverseQuestionIsOpen, splashDataLoading, visible]) return ( <> @@ -336,22 +346,25 @@ export const App = () => {