Skip to content

Commit 8b8a7ef

Browse files
authored
Fix todo tests (#363)
1 parent 205779c commit 8b8a7ef

File tree

4 files changed

+59
-22
lines changed

4 files changed

+59
-22
lines changed

src/services/extractToParameter/TemplateStructureUtils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { YamlSyntaxTree } from '../../context/syntaxtree/YamlSyntaxTree';
66
import { DocumentType } from '../../document/Document';
77
import { parseJson } from '../../document/JsonParser';
88
import { parseYaml } from '../../document/YamlParser';
9-
// import { LoggerFactory } from '../../telemetry/LoggerFactory';
10-
11-
// const log = LoggerFactory.getLogger('TemplateStructureUtils');
129

1310
/**
1411
* Result of searching for Parameters section in a CloudFormation template.

src/utils/ErrorStackInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ export function determineSensitiveInfo(): string[] {
2323
errorStackInfo = [];
2424
}
2525

26+
errorStackInfo = [__dirname.trim(), ...errorStackInfo];
2627
return errorStackInfo;
2728
}

tst/e2e/Completion.test.ts

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ Resources:
16741674
await client.closeDocument({ textDocument: { uri } });
16751675
});
16761676

1677-
it.todo('should show optional properties after required ones fulfilled', async () => {
1677+
it('should show optional properties after required ones fulfilled', async () => {
16781678
const template = getSimpleYamlTemplateText();
16791679
const updatedTemplate = `AWSTemplateFormatVersion: '2010-09-09'
16801680
Description: Lambda function ListBucketsCommand.
@@ -1696,7 +1696,7 @@ Resources:
16961696
return response.Buckets;
16971697
};
16981698
`;
1699-
const uri = await client.openJsonTemplate(template);
1699+
const uri = await client.openYamlTemplate(template);
17001700

17011701
await client.changeDocument({
17021702
textDocument: { uri, version: 2 },
@@ -1712,9 +1712,30 @@ Resources:
17121712
expect(completions?.items).toBeDefined();
17131713

17141714
const labels = completions.items.map((item: any) => item.label);
1715-
expect(labels).toContain('Architecture');
1716-
1717-
// works in functional testing and json, failing in YAML
1715+
expect(labels).toEqual([
1716+
'Description',
1717+
'TracingConfig',
1718+
'VpcConfig',
1719+
'RuntimeManagementConfig',
1720+
'ReservedConcurrentExecutions',
1721+
'SnapStart',
1722+
'FileSystemConfigs',
1723+
'FunctionName',
1724+
'KmsKeyArn',
1725+
'PackageType',
1726+
'CodeSigningConfigArn',
1727+
'Layers',
1728+
'Tags',
1729+
'ImageConfig',
1730+
'MemorySize',
1731+
'DeadLetterConfig',
1732+
'Timeout',
1733+
'LoggingConfig',
1734+
'RecursiveLoop',
1735+
'Environment',
1736+
'EphemeralStorage',
1737+
'Architectures',
1738+
]);
17181739

17191740
await client.closeDocument({ textDocument: { uri } });
17201741
});
@@ -3519,7 +3540,7 @@ Resources:
35193540
});
35203541

35213542
describe('Cross-Reference Completions', () => {
3522-
it.todo('should provide condition reference completions in resources', async () => {
3543+
it('should provide condition reference completions in resources', async () => {
35233544
const template = getSimpleJsonTemplateText();
35243545
const updatedTemplate = `{
35253546
"AWSTemplateFormatVersion": "2010-09-09",
@@ -3558,10 +3579,6 @@ Resources:
35583579
const labels = completions.items.map((item: any) => item.label);
35593580
expect(labels).toContain('CreateProdResources');
35603581

3561-
// todo: condition are not provided as completions
3562-
// although template validation throws error
3563-
// '' is not one of ['CreateProdResources']
3564-
35653582
await client.closeDocument({ textDocument: { uri } });
35663583
});
35673584
});
@@ -3787,8 +3804,29 @@ Resources:
37873804
expect(completions?.items).toBeDefined();
37883805

37893806
const labels = completions.items.map((item: any) => item.label);
3790-
expect(labels).toContain('Description');
3791-
expect(labels).toContain('Architectures');
3807+
expect(labels).toEqual([
3808+
'Description',
3809+
'TracingConfig',
3810+
'VpcConfig',
3811+
'RuntimeManagementConfig',
3812+
'ReservedConcurrentExecutions',
3813+
'SnapStart',
3814+
'FileSystemConfigs',
3815+
'KmsKeyArn',
3816+
'PackageType',
3817+
'CodeSigningConfigArn',
3818+
'Layers',
3819+
'Tags',
3820+
'ImageConfig',
3821+
'MemorySize',
3822+
'DeadLetterConfig',
3823+
'Timeout',
3824+
'LoggingConfig',
3825+
'RecursiveLoop',
3826+
'Environment',
3827+
'EphemeralStorage',
3828+
'Architectures',
3829+
]);
37923830

37933831
await client.closeDocument({ textDocument: { uri } });
37943832
});

tst/unit/services/extractToParameter/TemplateStructureUtils.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ Resources: {}`;
9797
expect(result?.exists).toBe(false);
9898
});
9999

100-
it.todo('should handle malformed YAML gracefully', () => {
101-
const malformedYaml = 'Parameters:\n - invalid: structure';
102-
103-
const result = utils.findParametersSection(malformedYaml, DocumentType.YAML);
104-
105-
expect(result).toBeDefined();
106-
expect(result?.exists).toBe(false);
100+
it('should handle malformed YAML gracefully', () => {
101+
expect(utils.findParametersSection('Parameters:\n - invalid: structure', DocumentType.YAML)?.exists).toBe(
102+
true,
103+
);
104+
105+
expect(utils.findParametersSection('Parameters:- invalid: structure', DocumentType.YAML)?.exists).toBe(
106+
false,
107+
);
107108
});
108109
});
109110

0 commit comments

Comments
 (0)