Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 15 additions & 4 deletions app/src/ModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */

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

import { config } from './config'
Expand Down Expand Up @@ -95,12 +95,23 @@ const close = () => {
}

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

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

if (map.info_open && pathname === '/') {
myModal.showModal()
return
}

if (myModal.open) {
myModal.close()
}
}, [map.info_open])
}, [map.info_open, pathname])

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

describe('Utopia Map 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')

cy.visit('/set-new-password?token=test-reset-token')
cy.wait('@getMap')
})

it('should keep the set new password dialog visible when startup info is enabled', () => {
cy.get('h2').should('contain.text', 'Set new Password')
cy.get('input[type="password"]')
.should('be.visible')
.should('have.attr', 'placeholder', 'Password')

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