Skip to content

Commit

Permalink
test: fix request access modal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Nov 27, 2024
1 parent 51532af commit 42e800f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const RequestAccessLoginMessage = ({ handleClose }: { handleClose: () => void })
variant="link"
onClick={() => oidcLogin(encodeReturnToPathInStateQueryParam(`${pathname}${search}`))}
className="p-0 align-baseline">
log in
Log In
</Button>{' '}
to request access.
</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { RequestAccessModal } from '../../../../../../src/sections/file/file-action-buttons/access-file-menu/RequestAccessModal'
import { UserMother } from '../../../../users/domain/models/UserMother'
import { UserRepository } from '../../../../../../src/users/domain/repositories/UserRepository'
import { SessionProvider } from '../../../../../../src/sections/session/SessionProvider'
import { Route } from '../../../../../../src/sections/Route.enum'
import { FilePreviewMother } from '../../../../files/domain/models/FilePreviewMother'

Expand All @@ -22,9 +19,8 @@ describe('RequestAccessModal', () => {
cy.findByRole('dialog').should('exist')
cy.findAllByText('Request Access').should('exist')

cy.findByRole('link', { name: 'Log In' })
.should('exist')
.should('have.attr', 'href', Route.LOG_IN_JSF)
cy.findByRole('button', { name: 'Log In' }).should('exist')

cy.findByRole('link', { name: 'Sign Up' })
.should('exist')
.should('have.attr', 'href', Route.SIGN_UP_JSF)
Expand All @@ -35,16 +31,8 @@ describe('RequestAccessModal', () => {

it('shows request access modal when button is clicked and user is logged in', () => {
const file = FilePreviewMother.create()
const user = UserMother.create()
const userRepository = {} as UserRepository
userRepository.getAuthenticated = cy.stub().resolves(user)
userRepository.removeAuthenticated = cy.stub().resolves()

cy.customMount(
<SessionProvider repository={userRepository}>
<RequestAccessModal fileId={file.id} />
</SessionProvider>
)

cy.mountAuthenticated(<RequestAccessModal fileId={file.id} />)

cy.findByRole('button', { name: 'Request Access' }).click()

Expand Down

0 comments on commit 42e800f

Please sign in to comment.