Skip to content

Commit

Permalink
perf(spec-paser): update $when in AC card to enhance compatibility (#…
Browse files Browse the repository at this point in the history
…11880)

Co-authored-by: rentu <[email protected]>
  • Loading branch information
SLdragon and SLdragon authored Jun 24, 2024
1 parent 4b23e7a commit f11682a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/spec-parser/src/adaptiveCardGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ export class AdaptiveCardGenerator {
{
type: "Image",
url: `\${${name}}`,
$when: `\${${name} != null}`,
$when: `\${${name} != null && ${name} != ''}`,
},
];
} else {
return [
{
type: "Image",
url: "${$data}",
$when: "${$data != null}",
$when: "${$data != null && $data != ''}",
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/spec-parser/src/adaptiveCardWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function inferPreviewCardTemplate(card: AdaptiveCard): PreviewCardTemplat
result.image = {
url: `\${${inferredProperties.imageUrl}}`,
alt: `\${if(${inferredProperties.imageUrl}, ${inferredProperties.imageUrl}, 'N/A')}`,
$when: `\${${inferredProperties.imageUrl} != null}`,
$when: `\${${inferredProperties.imageUrl} != null && ${inferredProperties.imageUrl} != ''}`,
};
}

Expand Down
8 changes: 4 additions & 4 deletions packages/spec-parser/test/adaptiveCardGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe("adaptiveCardGenerator", () => {
{
type: "Image",
url: "${photo_url}",
$when: "${photo_url != null}",
$when: "${photo_url != null && photo_url != ''}",
},
{
type: "TextBlock",
Expand Down Expand Up @@ -183,7 +183,7 @@ describe("adaptiveCardGenerator", () => {
{
type: "Image",
url: `\${image}`,
$when: `\${image != null}`,
$when: `\${image != null && image != ''}`,
},
],
},
Expand Down Expand Up @@ -520,7 +520,7 @@ describe("adaptiveCardGenerator", () => {
{
type: "Image",
url: "${$data}",
$when: "${$data != null}",
$when: "${$data != null && $data != ''}",
},
],
},
Expand Down Expand Up @@ -797,7 +797,7 @@ describe("adaptiveCardGenerator", () => {
{
type: "Image",
url: `\${iconUrl}`,
$when: `\${iconUrl != null}`,
$when: `\${iconUrl != null && iconUrl != ''}`,
},
],
},
Expand Down
6 changes: 3 additions & 3 deletions packages/spec-parser/test/adaptiveCardWrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("adaptiveCardWrapper", () => {
wrap: true,
},
{
$when: "${imageUrl != null}",
$when: "${imageUrl != null && imageUrl != ''}",
type: "Image",
url: "${imageUrl}",
},
Expand Down Expand Up @@ -257,7 +257,7 @@ describe("adaptiveCardWrapper", () => {
expect(result.image).to.be.deep.equal({
url: "${photoUrl}",
alt: "${if(photoUrl, photoUrl, 'N/A')}",
$when: "${photoUrl != null}",
$when: "${photoUrl != null && photoUrl != ''}",
});
});
});
Expand Down Expand Up @@ -333,7 +333,7 @@ describe("adaptiveCardWrapper", () => {
subtitle: "${if(petId, petId, 'N/A')}",
image: {
url: "${imageUrl}",
$when: "${imageUrl != null}",
$when: "${imageUrl != null && imageUrl != ''}",
alt: "${if(imageUrl, imageUrl, 'N/A')}",
},
},
Expand Down
6 changes: 3 additions & 3 deletions packages/spec-parser/test/manifestUpdater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ describe("updateManifestWithAiPlugin", () => {
wrap: true,
},
{
$when: "${imageUrl != null}",
$when: "${imageUrl != null && imageUrl != ''}",
type: "Image",
url: "${imageUrl}",
},
Expand Down Expand Up @@ -531,7 +531,7 @@ describe("updateManifestWithAiPlugin", () => {
wrap: true,
},
{
$when: "${imageUrl != null}",
$when: "${imageUrl != null && imageUrl != ''}",
type: "Image",
url: "${imageUrl}",
},
Expand Down Expand Up @@ -738,7 +738,7 @@ describe("updateManifestWithAiPlugin", () => {
type: "Container",
},
{
$when: "${imageUrl != null}",
$when: "${imageUrl != null && imageUrl != ''}",
type: "Image",
url: "${imageUrl}",
},
Expand Down

0 comments on commit f11682a

Please sign in to comment.