Skip to content

Commit f030e35

Browse files
authored
refactor(appBuilder): move WalkthroughNode
1 parent f9665ce commit f030e35

File tree

4 files changed

+72
-50
lines changed

4 files changed

+72
-50
lines changed

packages/core/src/awsService/appBuilder/explorer/nodes/rootNode.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Commands } from '../../../../shared/vscode/commands2'
1313
import { AppNode } from './appNode'
1414
import { detectSamProjects } from '../detectSamProjects'
1515
import globals from '../../../../shared/extensionGlobals'
16+
import { WalkthroughNode } from './walkthroughNode'
1617

1718
export async function getAppNodes(): Promise<TreeNode[]> {
1819
// no active workspace, show buttons in welcomeview
@@ -37,29 +38,6 @@ export async function getAppNodes(): Promise<TreeNode[]> {
3738
return nodesToReturn
3839
}
3940

40-
/**
41-
* Create Open Walkthrough Node in App builder sidebar
42-
*
43-
*/
44-
export class WalkthroughNode implements TreeNode {
45-
public readonly id = 'walkthrough'
46-
public readonly resource = this
47-
public constructor() {}
48-
49-
public getTreeItem() {
50-
const itemLabel = localize('AWS.appBuilder.openWalkthroughTitle', 'Walkthrough of Application Builder')
51-
52-
const item = new vscode.TreeItem(itemLabel)
53-
item.contextValue = 'awsWalkthroughNode'
54-
item.command = {
55-
title: localize('AWS.appBuilder.openWalkthroughTitle', 'Walkthrough of Application Builder'),
56-
command: 'aws.toolkit.lambda.openWalkthrough',
57-
}
58-
59-
return item
60-
}
61-
}
62-
6341
export class AppBuilderRootNode implements TreeNode {
6442
public readonly id = 'appBuilder'
6543
public readonly resource = this
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as vscode from 'vscode'
7+
import { TreeNode } from '../../../../shared/treeview/resourceTreeDataProvider'
8+
import { localize } from '../../../../shared/utilities/vsCodeUtils'
9+
10+
/**
11+
* Create Open Walkthrough Node in App builder sidebar
12+
*
13+
*/
14+
export class WalkthroughNode implements TreeNode {
15+
public readonly id = 'walkthrough'
16+
public readonly resource: WalkthroughNode = this
17+
18+
// Constructor left empty intentionally for future extensibility
19+
public constructor() {}
20+
21+
/**
22+
* Generates the TreeItem for the Walkthrough Node.
23+
* This item will appear in the sidebar with a label and command to open the walkthrough.
24+
*/
25+
public getTreeItem() {
26+
const itemLabel = localize('AWS.appBuilder.openWalkthroughTitle', 'Walkthrough of Application Builder')
27+
28+
const item = new vscode.TreeItem(itemLabel)
29+
item.contextValue = 'awsWalkthroughNode'
30+
item.command = {
31+
title: localize('AWS.appBuilder.openWalkthroughTitle', 'Walkthrough of Application Builder'),
32+
command: 'aws.toolkit.lambda.openWalkthrough',
33+
}
34+
35+
return item
36+
}
37+
}

packages/core/src/test/shared/applicationBuilder/explorer/nodes/rootNode.test.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import * as VsCodeUtils from '../../../../../shared/utilities/vsCodeUtils'
1111
import * as DetectSamProjects from '../../../../../../src/awsService/appBuilder/explorer/detectSamProjects'
1212
import globals from '../../../../../shared/extensionGlobals'
1313

14-
import {
15-
AppBuilderRootNode,
16-
getAppNodes,
17-
WalkthroughNode,
18-
} from '../../../../../awsService/appBuilder/explorer/nodes/rootNode'
14+
import { AppBuilderRootNode, getAppNodes } from '../../../../../awsService/appBuilder/explorer/nodes/rootNode'
1915

2016
import { AppNode } from '../../../../../awsService/appBuilder/explorer/nodes/appNode'
2117

@@ -50,28 +46,6 @@ describe('getAppNodes', async () => {
5046
})
5147
})
5248

53-
describe('WalkthroughNode', () => {
54-
const walkthroughNode = new WalkthroughNode()
55-
describe('constructor', () => {
56-
it('should create a WalkthroughNode with correct properties', () => {
57-
assert.strictEqual(walkthroughNode.id, 'walkthrough')
58-
assert.strictEqual(walkthroughNode.resource, walkthroughNode)
59-
})
60-
})
61-
describe('getTreeItem', () => {
62-
it('should generate correct TreeItem', () => {
63-
const treeItem = walkthroughNode.getTreeItem()
64-
65-
assert.strictEqual(treeItem.label, 'Walkthrough of Application Builder')
66-
assert.strictEqual(treeItem.contextValue, 'awsWalkthroughNode')
67-
assert.deepStrictEqual(treeItem.command, {
68-
title: 'Walkthrough of Application Builder',
69-
command: 'aws.toolkit.lambda.openWalkthrough',
70-
})
71-
})
72-
})
73-
})
74-
7549
describe('AppBuilderRootNode', () => {
7650
let commandRegisterStub: sinon.SinonStub
7751
let openUrlStub: sinon.SinonStub
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import assert from 'assert'
6+
import { WalkthroughNode } from '../../../../../awsService/appBuilder/explorer/nodes/walkthroughNode'
7+
8+
describe('WalkthroughNode', () => {
9+
let walkthroughNode: WalkthroughNode
10+
11+
// Initialize a new instance before each test to ensure test isolation
12+
beforeEach(() => {
13+
walkthroughNode = new WalkthroughNode()
14+
})
15+
describe('constructor', () => {
16+
it('should create a WalkthroughNode with correct properties', () => {
17+
assert.strictEqual(walkthroughNode.id, 'walkthrough')
18+
assert.strictEqual(walkthroughNode.resource, walkthroughNode)
19+
})
20+
})
21+
describe('getTreeItem', () => {
22+
it('should generate correct TreeItem', () => {
23+
const treeItem = walkthroughNode.getTreeItem()
24+
25+
assert.strictEqual(treeItem.label, 'Walkthrough of Application Builder')
26+
assert.strictEqual(treeItem.contextValue, 'awsWalkthroughNode')
27+
assert.deepStrictEqual(treeItem.command, {
28+
title: 'Walkthrough of Application Builder',
29+
command: 'aws.toolkit.lambda.openWalkthrough',
30+
})
31+
})
32+
})
33+
})

0 commit comments

Comments
 (0)