chore: wire Carplace into dev and production stacks
Build & Deploy / Build & Push Docker Image (push) Successful in 2m55s
Test / Type Check (all packages) (push) Successful in 54s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Failing after 48s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Storefront Unit Tests (push) Failing after 40s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Failing after 42s
Test / API Integration Tests (push) Successful in 1m0s
Build & Deploy / Build & Push Docker Image (push) Successful in 2m55s
Test / Type Check (all packages) (push) Successful in 54s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Failing after 48s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Storefront Unit Tests (push) Failing after 40s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Failing after 42s
Test / API Integration Tests (push) Successful in 1m0s
This commit is contained in:
@@ -49,7 +49,7 @@ describe('financialReportService', () => {
|
||||
pricingRulesTotal: 10,
|
||||
depositAmount: 500,
|
||||
totalAmount: 640,
|
||||
source: 'MARKETPLACE',
|
||||
source: 'CARPLACE',
|
||||
startDate: new Date('2026-06-18T10:00:00.000Z'),
|
||||
endDate: new Date('2026-06-20T10:00:00.000Z'),
|
||||
vehicle: { year: 2023, make: 'Renault', model: 'Clio', licensePlate: 'B-456' },
|
||||
|
||||
@@ -27,15 +27,15 @@ describe('platformContentService', () => {
|
||||
it('returns cloned default homepage content when the file does not exist or cannot be parsed', async () => {
|
||||
const service = await importFreshService()
|
||||
|
||||
const first = await service.getStorefrontHomepageContent()
|
||||
const first = await service.getCarplaceHomepageContent()
|
||||
first.en.heroTitle = 'Mutated by test'
|
||||
|
||||
const second = await service.getStorefrontHomepageContent()
|
||||
const second = await service.getCarplaceHomepageContent()
|
||||
expect(second.en.sections).toContain('hero')
|
||||
expect(second.en.heroTitle).not.toBe('Mutated by test')
|
||||
})
|
||||
|
||||
it('saves only the storefront homepage field while preserving unrelated platform content fields', async () => {
|
||||
it('saves only the Carplace homepage field while preserving unrelated platform content fields', async () => {
|
||||
const dataPath = path.join(tempDir, 'apps/api/src/data/platform-content.json')
|
||||
await writeFile(dataPath, JSON.stringify({ otherSetting: { keep: true } }), 'utf8').catch(async () => {
|
||||
await import('fs/promises').then((fs) => fs.mkdir(path.dirname(dataPath), { recursive: true }))
|
||||
@@ -43,13 +43,13 @@ describe('platformContentService', () => {
|
||||
})
|
||||
|
||||
const service = await importFreshService()
|
||||
const homepage = await service.getStorefrontHomepageContent()
|
||||
homepage.en.heroTitle = 'A better storefront title'
|
||||
const homepage = await service.getCarplaceHomepageContent()
|
||||
homepage.en.heroTitle = 'A better Carplace title'
|
||||
|
||||
await expect(service.saveStorefrontHomepageContent(homepage)).resolves.toBe(homepage)
|
||||
await expect(service.saveCarplaceHomepageContent(homepage)).resolves.toBe(homepage)
|
||||
|
||||
const raw = JSON.parse(await readFile(dataPath, 'utf8'))
|
||||
expect(raw.otherSetting).toEqual({ keep: true })
|
||||
expect(raw.storefrontHomepage.en.heroTitle).toBe('A better storefront title')
|
||||
expect(raw.carplaceHomepage.en.heroTitle).toBe('A better Carplace title')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { mkdir, readFile, writeFile } from 'fs/promises'
|
||||
import path from 'path'
|
||||
import { cloneStorefrontHomepageContent, type StorefrontHomepageConfig } from '@rentaldrivego/types'
|
||||
import {
|
||||
cloneCarplaceHomepageContent,
|
||||
type CarplaceHomepageConfig,
|
||||
} from '@rentaldrivego/types'
|
||||
|
||||
function resolveContentPath() {
|
||||
const cwd = process.cwd()
|
||||
@@ -12,7 +15,7 @@ function resolveContentPath() {
|
||||
const platformContentPath = resolveContentPath()
|
||||
|
||||
type PlatformContentFile = {
|
||||
storefrontHomepage?: StorefrontHomepageConfig
|
||||
carplaceHomepage?: CarplaceHomepageConfig
|
||||
}
|
||||
|
||||
async function readPlatformContentFile(): Promise<PlatformContentFile> {
|
||||
@@ -29,16 +32,16 @@ async function writePlatformContentFile(content: PlatformContentFile) {
|
||||
await writeFile(platformContentPath, JSON.stringify(content, null, 2))
|
||||
}
|
||||
|
||||
export async function getStorefrontHomepageContent() {
|
||||
export async function getCarplaceHomepageContent() {
|
||||
const content = await readPlatformContentFile()
|
||||
return content.storefrontHomepage ?? cloneStorefrontHomepageContent()
|
||||
return content.carplaceHomepage ?? cloneCarplaceHomepageContent()
|
||||
}
|
||||
|
||||
export async function saveStorefrontHomepageContent(homepage: StorefrontHomepageConfig) {
|
||||
export async function saveCarplaceHomepageContent(homepage: CarplaceHomepageConfig) {
|
||||
const content = await readPlatformContentFile()
|
||||
await writePlatformContentFile({
|
||||
...content,
|
||||
storefrontHomepage: homepage,
|
||||
carplaceHomepage: homepage,
|
||||
})
|
||||
return homepage
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user