Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI/CD deploy error #450

Merged
merged 5 commits into from
Aug 5, 2021
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
27 changes: 18 additions & 9 deletions src/lib/app-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,24 @@ function setOrgServicesConfig (supportedServices) {
* @returns {object} op['view'] metadata OR null
*/
async function buildExcShellViewExtensionMetadata (libConsoleCLI, aioConfig) {
const serviceProperties = await libConsoleCLI.getServicePropertiesFromWorkspace(
aioConfig.project.org.id,
aioConfig.project.id,
aioConfig.project.workspace
)
const services = serviceProperties.map(s => ({
name: s.name,
code: s.sdkCode
}))
let serviceProperties
let services
if (aioConfig.project.workspace.details) {
serviceProperties = aioConfig.project.workspace.details.services
}
if (serviceProperties) {
services = (Array.isArray(serviceProperties)) ? serviceProperties : JSON.parse(serviceProperties)
} else {
serviceProperties = await libConsoleCLI.getServicePropertiesFromWorkspace(
aioConfig.project.org.id,
aioConfig.project.id,
aioConfig.project.workspace
)
services = serviceProperties.map(s => ({
name: s.name,
code: s.sdkCode
}))
}
return {
services: Object.assign([], services),
profile: {
Expand Down
87 changes: 86 additions & 1 deletion test/commands/lib/app-helper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ test('setOrgServicesConfig', () => {
})

describe('buildExcShellViewExtensionMetadata', () => {
test('with service properties', async () => {
test('with service properties from console', async () => {
const mockConsoleCLIInstance = {
getServicePropertiesFromWorkspace: jest.fn()
}
Expand Down Expand Up @@ -604,6 +604,91 @@ describe('buildExcShellViewExtensionMetadata', () => {
})
expect(mockConsoleCLIInstance.getServicePropertiesFromWorkspace).toHaveBeenCalledWith('hola', 'bonjour', { id: 'yay', name: 'yo' })
})

test('with service properties in config', async () => {
const mockConsoleCLIInstance = {
getServicePropertiesFromWorkspace: jest.fn()
}
const mockAIOConfig = {
project: {
org: {
id: 'hola'
},
workspace: {
id: 'yay',
name: 'yo',
details: {
services: [
{
code: 'service1code',
name: 'service1'
},
{
code: 'service2code',
name: 'service2'
}
]
}
},
id: 'bonjour'
}
}
const res = await appHelper.buildExcShellViewExtensionMetadata(mockConsoleCLIInstance, mockAIOConfig)
expect(res).toEqual({
services: [
{ name: 'service1', code: 'service1code' },
{ name: 'service2', code: 'service2code' }
],
profile: {
client_id: 'firefly-app',
scope: 'ab.manage,additional_info.job_function,additional_info.projectedProductContext,additional_info.roles,additional_info,AdobeID,adobeio_api,adobeio.appregistry.read,audiencemanager_api,creative_cloud,mps,openid,read_organizations,read_pc.acp,read_pc.dma_tartan,read_pc,session'
}
})
expect(mockConsoleCLIInstance.getServicePropertiesFromWorkspace).toHaveBeenCalledTimes(0)
})

test('with service properties set as string', async () => {
const services = JSON.stringify([
{
code: 'service1code',
name: 'service1'
},
{
code: 'service2code',
name: 'service2'
}
])
const mockConsoleCLIInstance = {
getServicePropertiesFromWorkspace: jest.fn()
}
const mockAIOConfig = {
project: {
org: {
id: 'hola'
},
workspace: {
id: 'yay',
name: 'yo',
details: {
services: services
}
},
id: 'bonjour'
}
}
const res = await appHelper.buildExcShellViewExtensionMetadata(mockConsoleCLIInstance, mockAIOConfig)
expect(res).toEqual({
services: [
{ name: 'service1', code: 'service1code' },
{ name: 'service2', code: 'service2code' }
],
profile: {
client_id: 'firefly-app',
scope: 'ab.manage,additional_info.job_function,additional_info.projectedProductContext,additional_info.roles,additional_info,AdobeID,adobeio_api,adobeio.appregistry.read,audiencemanager_api,creative_cloud,mps,openid,read_organizations,read_pc.acp,read_pc.dma_tartan,read_pc,session'
}
})
expect(mockConsoleCLIInstance.getServicePropertiesFromWorkspace).toHaveBeenCalledTimes(0)
})
})

describe('buildExtensionPointPayloadWoMetadata', () => {
Expand Down