Skip to content
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
16 changes: 16 additions & 0 deletions src/utils/thumbnail.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { describe, expect, it } from "vitest";
import { fixture } from "../../tests/helper/fs";
import { Thumbnail } from "./thumbnail";

describe("thumbnail Smoke Test", () => {
it("should return localized package thumbnail", async () => {
const thumbnail = await Thumbnail.create(fixture("oo_project_1"), [], "en");

const data = await thumbnail?.provideThumbnail();

expect(data).toEqual(expect.objectContaining({
title: "Project 1",
description: "This is the description for Project 1.",
}));
});
});
10 changes: 5 additions & 5 deletions src/utils/thumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class Thumbnail implements ThumbnailProvider {

async provideThumbnail(): Promise<PackageThumbnail | undefined> {
const result: PackageThumbnail = {
title: this.wsPkgData.packageName,
title: this.wsPkgData.displayName,
icon: this.wsPkgData.icon,
description: this.wsPkgData.description,
flows: await this._provideFlowsThumbnail(),
Expand Down Expand Up @@ -343,7 +343,7 @@ export class Thumbnail implements ThumbnailProvider {
private async _provideFlowsThumbnail(): Promise<FlowThumbnail[]> {
const result: FlowThumbnail[] = [];
const flowsDir = path.join(this.wsPkgData.packageDir, "flows");
const flowNames = await fs.readdir(flowsDir);
const flowNames = await fs.readdir(flowsDir).catch(() => []);
for (const flowName of flowNames) {
const flowData = await FlowLikeData.create(this.wsPkgData, flowName, path.join(flowsDir, flowName), "flow");
if (flowData) {
Expand Down Expand Up @@ -563,7 +563,7 @@ class PkgData {

public readonly searchPaths: string[];

public readonly title: string | undefined;
public readonly displayName: string | undefined;
public readonly description: string | undefined;
public readonly icon: string | undefined;
public readonly blocksOrder: string[] | undefined;
Expand All @@ -582,8 +582,8 @@ class PkgData {
) {
this.searchPaths = depsQuery.searchPaths;
this.icon = this.resolveResourceURI(data.icon, packageDir);
this.title = data.title || data.name;
this.description = data.description;
this.displayName = this.localize(data.displayName) || data.name;
this.description = this.localize(data.description);
this.blocksOrder = data.ui?.blocks;
this.dependencies = isPlainObject(data.dependencies) ? data.dependencies : {};
}
Expand Down
4 changes: 4 additions & 0 deletions tests/fixtures/oo_project_1/oo-locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"displayName": "Project 1",
"description": "This is the description for Project 1."
}
4 changes: 4 additions & 0 deletions tests/fixtures/oo_project_1/package.oo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: project-1
version: 1.0.0
displayName: "%displayName%"
description: "%description%"
Loading