Skip to content
Open
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
20 changes: 19 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions src/modules/CaaSMapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ describe('CaaSMapper', () => {
})
})
it('should register a remote reference and return its remote reference key', () => {
const remotes = { someName: { id: 'remoteId', locale: 'de' } }
const remotes = {
someName: { id: 'remoteId', locale: 'de', contentMode: undefined },
}
const api = createApi()
api.remotes = remotes
const mapper = new CaaSMapper(api, 'de', {}, createLogger())
Expand Down Expand Up @@ -1659,9 +1661,9 @@ describe('CaaSMapper', () => {
it('should call resolveReferencesPerProject for all remote projects', async () => {
const api = createApi()
api.remotes = {
'remote-id1': { id: 'remote-id1', locale: 'de' },
'remote-id2': { id: 'remote-id2', locale: 'de' },
'remote-id3': { id: 'remote-id3', locale: 'de' },
'remote-id1': { id: 'remote-id1', locale: 'de', contentMode: undefined },
'remote-id2': { id: 'remote-id2', locale: 'de', contentMode: undefined },
'remote-id3': { id: 'remote-id3', locale: 'de', contentMode: undefined },
}
const mapper = new CaaSMapper(api, 'de', {}, createLogger())
mapper.resolveReferencesPerProject = jest.fn()
Expand Down Expand Up @@ -1696,7 +1698,9 @@ describe('CaaSMapper', () => {
})
it('should resolve remote media references', async () => {
const api = createApi()
api.remotes = { 'remote-id1': { id: 'remote-id1', locale: 'de' } }
api.remotes = {
'remote-id1': { id: 'remote-id1', locale: 'de', contentMode: undefined },
}
const mapper = new CaaSMapper(api, 'de', {}, createLogger())
const mediaPictures = await Promise.all([
mapper.mapMediaPicture(createMediaPicture('id1')),
Expand Down
16 changes: 15 additions & 1 deletion src/modules/FSXARemoteApi.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { faker } from '@faker-js/faker'
import { FSXAApiErrors, HttpStatus } from '../enums'
import { FSXAApiErrors, FSXAContentMode, HttpStatus } from '../enums'
import { FetchResponse, QueryBuilderQuery, SortParams } from '../types'
import { FSXARemoteApi } from './FSXARemoteApi'
import {
Expand Down Expand Up @@ -118,6 +118,20 @@ describe('FSXARemoteAPI', () => {
const expectedCaaSUrl = `${config.caasURL}/${config.tenantID}/${remoteProjectId}.${config.contentMode}.content`
expect(actualCaaSUrl).toStrictEqual(expectedCaaSUrl)
})
it('should use the remote contentMode if provided', () => {
const config = generateRandomConfig()
const remoteProjectId = config.remotes.remote.id

config.contentMode = FSXAContentMode.RELEASE
;(config.remotes.remote as any).contentMode = FSXAContentMode.PREVIEW

const remoteApi = new FSXARemoteApi(config)
const actualCaaSUrl = remoteApi.buildCaaSUrl({
remoteProject: remoteProjectId,
})
const expectedCaaSUrl = `${config.caasURL}/${config.tenantID}/${remoteProjectId}.preview.content`
expect(actualCaaSUrl).toStrictEqual(expectedCaaSUrl)
})
it('should return the correct caas url with a locale but no id', () => {
const locale = `${faker.location.countryCode().toLowerCase()}_${faker.location.countryCode().toLowerCase()}`
const config = generateRandomConfig()
Expand Down
8 changes: 7 additions & 1 deletion src/modules/FSXARemoteApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ export class FSXARemoteApi implements FSXAApi {
projectId = remoteProjectId
}

let baseURL = `${this.caasURL}/${this.tenantID}/${projectId}.${this.contentMode}.content`
let contentMode = this.contentMode
if (remoteProjectId) {
const remoteConfig = this.getRemoteConfigById(remoteProjectId)
contentMode = remoteConfig.contentMode || contentMode
}

let baseURL = `${this.caasURL}/${this.tenantID}/${projectId}.${contentMode}.content`
let encodedBaseURL = encodeURI(baseURL)

if (id) {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ export type RemoteProjectConfiguration = {
[name: string]: {
id: string
locale: string
contentMode?: 'preview' | 'release'
}
}

Expand Down