-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/multiple-templates-rewrites-plp
- Loading branch information
Showing
9 changed files
with
188 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "3.0.55", | ||
"version": "3.0.57", | ||
"npmClient": "yarn", | ||
"command": { | ||
"publish": { | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Inter } from 'next/font/google' | ||
|
||
const customFont = Inter({ | ||
display: 'swap', | ||
variable: '--fs-font-inter', | ||
weight: ['400', '500', '600', '700', '900'], | ||
subsets: ['latin'], // Either define subsets or set preload to false https://nextjs.org/docs/messages/google-fonts-missing-subsets | ||
}) | ||
|
||
export default customFont |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { clientCMS, getCMSPage } from '../../../src/server/cms' | ||
import { jest } from '@jest/globals' | ||
import { ContentData } from '@vtex/client-cms' | ||
|
||
describe('CMS Integration', () => { | ||
const mockData = (count = 1) => { | ||
const data: ContentData[] = [] | ||
for (let i = 0; i < count; i = i + 1) { | ||
data.push({ | ||
id: `data-id-${i}`, | ||
name: `data-name-${i}`, | ||
status: `data-status-${i}`, | ||
type: `data-type-${i}`, | ||
sections: [], | ||
releaseId: `release-${i}`, | ||
}) | ||
} | ||
return data | ||
} | ||
|
||
describe('getCMSPage', () => { | ||
it('returns the first page if there is only one page', async () => { | ||
const mockFunction = jest.fn(() => { | ||
return Promise.resolve({ | ||
data: mockData(3), | ||
hasNextPage: false, | ||
totalItems: 3, | ||
}) | ||
}) | ||
clientCMS.getCMSPagesByContentType = mockFunction | ||
|
||
const result = await getCMSPage( | ||
{ contentType: 'plp' }, | ||
{ cmsClient: clientCMS } | ||
) | ||
|
||
expect(mockFunction.mock.calls.length).toBe(1) | ||
expect(result.data.length).toBe(3) | ||
}) | ||
|
||
it('loads multiple pages', async () => { | ||
const mockFunction: jest.Mock<typeof clientCMS.getCMSPagesByContentType> = | ||
jest.fn() | ||
|
||
mockFunction.mockImplementationOnce(() => { | ||
return Promise.resolve({ | ||
data: mockData(10), | ||
hasNextPage: true, | ||
totalItems: 15, | ||
}) | ||
}) | ||
mockFunction.mockImplementationOnce(() => { | ||
return Promise.resolve({ | ||
data: mockData(5), | ||
hasNextPage: false, | ||
totalItems: 15, | ||
}) | ||
}) | ||
|
||
clientCMS.getCMSPagesByContentType = mockFunction | ||
|
||
const result = await getCMSPage( | ||
{ contentType: 'plp' }, | ||
{ cmsClient: clientCMS, cache: {} } | ||
) | ||
|
||
expect(mockFunction.mock.calls.length).toBe(2) | ||
expect(result.data.length).toBe(15) | ||
}) | ||
|
||
it('it makes no request if the cache is filled', async () => { | ||
const mockFunction: jest.Mock<typeof clientCMS.getCMSPagesByContentType> = | ||
jest.fn() | ||
|
||
mockFunction.mockImplementationOnce(() => { | ||
return Promise.resolve({ | ||
data: mockData(10), | ||
hasNextPage: true, | ||
totalItems: 15, | ||
}) | ||
}) | ||
|
||
clientCMS.getCMSPagesByContentType = mockFunction | ||
|
||
const cache = { plp: { data: [] } } | ||
const result = await getCMSPage( | ||
{ contentType: 'plp' }, | ||
{ cmsClient: clientCMS, cache: cache } | ||
) | ||
|
||
expect(mockFunction.mock.calls.length).toBe(0) | ||
expect(result.data.length).toBe(0) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9146,7 +9146,7 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.12.1.tgz#c62d5ac54dbd409cc6520b0b39de374b3d59d0dd" | ||
integrity sha512-umt4f5NnMK46ChM2coO36PTFhHouBrK9stWWBczERguwYrGnPNxJ9dimU6IyOBfOkC6Izhkg4H8+F51W/8CYDg== | ||
|
||
graphql@^15.0.0, graphql@^15.6.0: | ||
graphql@^15.6.0: | ||
version "15.8.0" | ||
resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.8.0.tgz#33410e96b012fa3bdb1091cc99a94769db212b38" | ||
integrity sha512-5gghUc24tP9HRznNpV2+FIoq3xKkj5dTQqf4v0CpdPbFVwFkWoxOM+o+2OC9ZSvjEMTjfmG9QT+gcvggTwW1zw== | ||
|