Skip to content

Commit 1cc7981

Browse files
committed
chore: fix the JS tests
1 parent c63e192 commit 1cc7981

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

app/frontend/editor/spec/__mocks__/page.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const page = {
1111
ogDescription: null,
1212
ogImageUrl: null,
1313
previewUrl: '/maglev/preview',
14+
liveUrl: '/',
1415
lockVersion: 1,
1516
translated: true,
1617
}

app/frontend/editor/store/__tests__/getters.spec.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import defaultState from '@/store/default-state'
55
import buildGetters from '@/store/getters'
66
import buildMutations from '@/store/mutations'
77
import MockedServices from '@/spec/__mocks__/services'
8-
import { page, normalizedPage } from '@/spec/__mocks__/page'
8+
import { page } from '@/spec/__mocks__/page'
99
import { sectionsContent, normalizedSectionsContent } from '@/spec/__mocks__/sections-content'
1010
import { site } from '@/spec/__mocks__/site'
1111
import { theme } from '@/spec/__mocks__/theme'
@@ -31,11 +31,11 @@ describe('Getters', () => {
3131
})
3232

3333
describe('#currentPagePath', () => {
34-
let freshNormalizedPage = null
35-
beforeEach(() => {
36-
freshNormalizedPage = structuredClone(normalizedPage)
37-
mockedServices.page.normalize = vi.fn(() => freshNormalizedPage)
38-
})
34+
// let freshNormalizedPage = null
35+
// beforeEach(() => {
36+
// freshNormalizedPage = structuredClone(normalizedPage)
37+
// mockedServices.page.normalize = vi.fn(() => freshNormalizedPage)
38+
// })
3939
describe('Given this is the home page', () => {
4040
it('returns the path of the page', () => {
4141
store.commit('SET_PAGE', page)
@@ -44,39 +44,38 @@ describe('Getters', () => {
4444
})
4545
describe('Given this is a random page', () => {
4646
it('returns the path of the page', () => {
47-
freshNormalizedPage.entities.page['1'].path = '/bonjour'
48-
freshNormalizedPage.entities.page['1'].liveUrl = '/fr/bonjour'
49-
store.commit('SET_PAGE', page)
47+
const freshPage = structuredClone(page)
48+
freshPage.path = '/bonjour'
49+
freshPage.liveUrl = '/fr/bonjour'
50+
store.commit('SET_PAGE', freshPage)
5051
expect(store.getters.currentPagePath).toStrictEqual('/fr/bonjour')
5152
})
5253
})
5354
describe('Given the liveUrl contains the domain name', () => {
5455
it('returns the path of the page', () => {
55-
freshNormalizedPage.entities.page['1'].liveUrl = 'https://example.com:8080/fr'
56-
freshNormalizedPage.entities.page['1'].path = 'index'
57-
store.commit('SET_PAGE', page)
56+
const freshPage = structuredClone(page)
57+
freshPage.liveUrl = 'https://example.com:8080/fr'
58+
freshPage.path = 'index'
59+
store.commit('SET_PAGE', freshPage)
5860
expect(store.getters.currentPagePath).toStrictEqual('/fr/index')
5961
})
6062
})
6163
})
6264

6365
describe('#currentPageUrl', () => {
64-
let freshNormalizedPage = null
65-
beforeEach(() => {
66-
freshNormalizedPage = structuredClone(normalizedPage)
67-
mockedServices.page.normalize = vi.fn(() => freshNormalizedPage)
68-
})
6966
describe('Given the page live URL is not prefixed with the base URL', () => {
7067
it('returns the url of the page', () => {
71-
freshNormalizedPage.entities.page['1'].liveUrl = '/hello-world'
72-
store.commit('SET_PAGE', page)
68+
const freshPage = structuredClone(page)
69+
freshPage.liveUrl = '/hello-world'
70+
store.commit('SET_PAGE', freshPage)
7371
expect(store.getters.currentPageUrl).toStrictEqual('http://localhost:3000/hello-world')
7472
})
7573
})
7674
describe('Given the page live URL is prefixed with the base URL', () => {
7775
it('returns the url of the page', () => {
78-
freshNormalizedPage.entities.page['1'].liveUrl = 'https://example.com:8080/fr'
79-
store.commit('SET_PAGE', page)
76+
const freshPage = structuredClone(page)
77+
freshPage.liveUrl = 'https://example.com:8080/fr'
78+
store.commit('SET_PAGE', freshPage)
8079
expect(store.getters.currentPageUrl).toStrictEqual('https://example.com:8080/fr')
8180
})
8281
})

0 commit comments

Comments
 (0)