Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions app/src/ModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */

import { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useEffect, useRef, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import { TextView, useAuth } from 'utopia-ui'

import { config } from './config'
Expand All @@ -15,6 +15,8 @@ interface ChapterProps {
map?: any
}

const ROOT_PATH = '/'

export function Welcome1({ clickAction1, map }: ChapterProps) {
const { isAuthenticated } = useAuth()
const navigate = useNavigate()
Expand Down Expand Up @@ -95,12 +97,26 @@ const close = () => {
}

export const ModalContent = ({ map }: { map: any }) => {
const { pathname } = useLocation()
const autoOpenedModal = useRef(false)

useEffect(() => {
const myModal = document.getElementById('my_modal_3') as HTMLDialogElement
if (map.info_open) {
const myModal = document.getElementById('my_modal_3')
if (!(myModal instanceof HTMLDialogElement)) {
return
}

if (map.info_open && pathname === ROOT_PATH && !myModal.open) {
myModal.showModal()
autoOpenedModal.current = true
return
}

if (pathname !== ROOT_PATH && autoOpenedModal.current && myModal.open) {
myModal.close()
autoOpenedModal.current = false
}
}, [map.info_open])
}, [map.info_open, pathname])

const [chapter, setChapter] = useState<number>(1)
// const setQuestsOpen = useSetQuestOpen()
Expand Down
39 changes: 39 additions & 0 deletions cypress/e2e/authentification/set-new-password.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// <reference types="cypress" />

describe('Utopia Map Authentication Set New Password', () => {
beforeEach(() => {
cy.clearCookies()
cy.clearLocalStorage()
cy.window().then((win) => {
win.sessionStorage.clear()
})

cy.intercept('GET', '**/items/maps*', (req) => {
req.continue((res) => {
if (Array.isArray(res.body?.data) && res.body.data[0]) {
res.body.data[0].info_open = true
}
})
}).as('getMap')
})

it('should keep the set new password dialog visible when startup info is enabled', () => {
cy.visit('/set-new-password?token=test-reset-token')
cy.wait('@getMap')

cy.get('h2').should('contain.text', 'Set new Password')
cy.get('input[type="password"]')
.should('be.visible')
.should('have.attr', 'placeholder', 'Password')
cy.get('button:contains("Set")').should('be.visible').and('not.be.disabled')

cy.get('dialog#my_modal_3').should('not.have.attr', 'open')
})

it('should still open the startup info modal on the root route', () => {
cy.visit('/')
cy.wait('@getMap')

cy.get('dialog#my_modal_3').should('have.attr', 'open')
})
})
Loading