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
10 changes: 6 additions & 4 deletions packages/authentication/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# @baseapp-frontend/authentication

## 5.0.1

### Patch Changes

- Fix component tests after dependencies update.

## 5.0.0

### Major Changes

- **BREAKING:** Removed SSR support from authentication functions and hooks

- Added `'use client'` directive to `getUser` and `useJWTUser` - these are now client-side only
- Removed `noSSR` parameter from `getUser`, `useJWTUser`, and related types
- For server-side user retrieval, use the new `getUserSSR` function instead

- **BREAKING:** Removed deprecated functions and hooks

- Deleted `getUserAsync` function and all related tests
- Deleted `useUser` hook (deprecated) and all related tests
- Deleted `withUser` HOC and all related tests
- Updated exports in main index file to reflect removals

- **BREAKING:** Updated `useUpdateUser` token refresh API

- Now requires explicit `refreshToken` parameter for `refreshAccessToken` call
- Updated function signature to match new token utilities

Expand Down Expand Up @@ -463,7 +466,6 @@
### Patch Changes

- Redesigning `useLogout` hook

- It now returns an object instead of a function
- It now uses `resetQueries` instead of `invalidateQueries` in order to reset the user cache properly.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react'

import { CookieProvider } from '@baseapp-frontend/utils'
import { CookieProvider } from '@baseapp-frontend/utils/hooks/useCookie'

import { MinimalProfile } from '../../../../../types/profile'
import { CURRENT_PROFILE_KEY_NAME, CurrentProfileProvider } from '../../../../profile'
Expand All @@ -9,7 +9,7 @@ import { WithAuthenticationTestProvidersProps } from './types'
const withAuthenticationTestProviders =
<Props extends object>(Component: FC<Props>) =>
({ context, initialCookies, ...props }: Props & WithAuthenticationTestProvidersProps) => {
const currentProfile = context?.parameters?.initialProfile
const currentProfile = context?.parameters?.initialProfile ?? null

return (
<CookieProvider<{ [CURRENT_PROFILE_KEY_NAME]: MinimalProfile }>
Expand All @@ -18,7 +18,7 @@ const withAuthenticationTestProviders =
...initialCookies,
}}
>
<CurrentProfileProvider>
<CurrentProfileProvider initialCurrentProfile={currentProfile}>
<Component {...(props as Props)} {...context} />
</CurrentProfileProvider>
</CookieProvider>
Expand Down
2 changes: 1 addition & 1 deletion packages/authentication/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@baseapp-frontend/authentication",
"description": "Authentication modules.",
"version": "5.0.0",
"version": "5.0.1",
"main": "./index.ts",
"types": "dist/index.d.ts",
"sideEffects": false,
Expand Down
9 changes: 9 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @baseapp-frontend/components

## 1.2.2

### Patch Changes

- Fix component tests after dependencies update.
- Updated dependencies
- @baseapp-frontend/authentication@5.0.1
- @baseapp-frontend/design-system@1.0.19

## 1.2.1

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {
commentDeleteMockData,
commentEditMockData,
commentsNextPageMockData,
commentsTestMockData,
commentsWithElevenRepliesMockData,
commentsWithNextPageMockData,
likeACommentMockData,
pinACommentMockData,
replytoCommentMockData,
Expand All @@ -17,29 +20,27 @@ import {
unlikeACommentMockData,
unpinACommentMockData,
} from './__mocks__/requests'
import {
commentCreateResolver,
commentReplyResolver,
commentsResolver,
commentsWithElevenRepliesResolver,
commentsWithNextPageResolver,
} from './__mocks__/resolvers'
import { commentCreateResolver, commentReplyResolver } from './__mocks__/resolvers'
import CommentsForTesting from './__utils__/CommentsForTesting'

describe('Comments', () => {
it('should render comments and be able to interact with it', () => {
const { environment, resolveMostRecentOperation } = createTestEnvironment()
cy.mockNextRouter()
.then((router) => {
cy.mount(
<AppRouterContext.Provider value={router}>
<CommentsForTesting environment={environment} />
</AppRouterContext.Provider>,
)
})
.then(() => {
resolveMostRecentOperation({ mockResolvers: commentsResolver })
})
const { environment, resolveMostRecentOperation, queueOperationResolver } =
createTestEnvironment()

queueOperationResolver({
queryName: 'CommentsForTestingQuery',
data: commentsTestMockData,
})

cy.mockNextRouter().then((router) => {
cy.mount(
<AppRouterContext.Provider value={router}>
<CommentsForTesting environment={environment} />
</AppRouterContext.Provider>,
)
})

cy.findByText('This is a regular comment.').should('exist')

cy.step('Create a comment and check if it was created')
Expand Down Expand Up @@ -184,27 +185,31 @@ describe('Comments', () => {
})

it('should render more comments when the bottom is reached', () => {
const { environment, resolveMostRecentOperation } = createTestEnvironment()
const { environment, resolveMostRecentOperation, queueOperationResolver } =
createTestEnvironment()

queueOperationResolver({
queryName: 'CommentsForTestingQuery',
data: commentsWithNextPageMockData,
})

cy.viewport(500, 350)

cy.mockNextRouter()
.then((router) => {
cy.mount(
<AppRouterContext.Provider value={router}>
<CommentsForTesting environment={environment} />
</AppRouterContext.Provider>,
)
})
.then(() => {
resolveMostRecentOperation({ mockResolvers: commentsWithNextPageResolver })
})
cy.mockNextRouter().then((router) => {
cy.mount(
<AppRouterContext.Provider value={router}>
<CommentsForTesting environment={environment} />
</AppRouterContext.Provider>,
)
})

cy.step('See the first four comments')
cy.findByText('First comment').should('exist')
cy.findByText('Second comment').should('exist')
cy.findByText('Third comment').should('exist')
cy.findByText('Fourth comment').should('exist')
cy.findByLabelText('loading more comments').should('not.exist')

cy.findByText('Fifth comment').should('not.exist')
cy.findByText('Sixth comment').should('not.exist')
cy.findByText('Seventh comment').should('not.exist')
Expand All @@ -215,10 +220,12 @@ describe('Comments', () => {
cy.step('Scroll to the bottom and see the next 5 comments')

cy.findByText('Fourth comment').should('exist').scrollIntoView()
cy.wait(100)
cy.findByText('Fifth comment').should('exist').scrollIntoView()

cy.findByLabelText('loading more comments')
.should('exist')
.scrollIntoView()
.then(() => {
resolveMostRecentOperation({ data: commentsNextPageMockData })
})
Expand All @@ -240,18 +247,21 @@ describe('Comments', () => {
}
cy.stub(Router, 'useRouter').returns(router)
cy.viewport(500, 1000)
const { environment, resolveMostRecentOperation } = createTestEnvironment()
cy.mockNextRouter()
.then((router) => {
cy.mount(
<AppRouterContext.Provider value={router}>
<CommentsForTesting environment={environment} />
</AppRouterContext.Provider>,
)
})
.then(() => {
resolveMostRecentOperation({ mockResolvers: commentsWithElevenRepliesResolver })
})
const { environment, resolveMostRecentOperation, queueOperationResolver } =
createTestEnvironment()

queueOperationResolver({
queryName: 'CommentsForTestingQuery',
data: commentsWithElevenRepliesMockData,
})
cy.mockNextRouter().then((router) => {
cy.mount(
<AppRouterContext.Provider value={router}>
<CommentsForTesting environment={environment} />
</AppRouterContext.Provider>,
)
})

cy.step('See the first comment and its replies')
cy.findByRole('button', { name: /reply to comment comment-with-eleven-replies/i })
.click()
Expand Down
Loading
Loading