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
3 changes: 0 additions & 3 deletions src/services/extractToParameter/TemplateStructureUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import { YamlSyntaxTree } from '../../context/syntaxtree/YamlSyntaxTree';
import { DocumentType } from '../../document/Document';
import { parseJson } from '../../document/JsonParser';
import { parseYaml } from '../../document/YamlParser';
// import { LoggerFactory } from '../../telemetry/LoggerFactory';

// const log = LoggerFactory.getLogger('TemplateStructureUtils');

/**
* Result of searching for Parameters section in a CloudFormation template.
Expand Down
1 change: 1 addition & 0 deletions src/utils/ErrorStackInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export function determineSensitiveInfo(): string[] {
errorStackInfo = [];
}

errorStackInfo = [__dirname.trim(), ...errorStackInfo];
return errorStackInfo;
}
62 changes: 50 additions & 12 deletions tst/e2e/Completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,7 @@ Resources:
await client.closeDocument({ textDocument: { uri } });
});

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

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

const labels = completions.items.map((item: any) => item.label);
expect(labels).toContain('Architecture');

// works in functional testing and json, failing in YAML
expect(labels).toEqual([
'Description',
'TracingConfig',
'VpcConfig',
'RuntimeManagementConfig',
'ReservedConcurrentExecutions',
'SnapStart',
'FileSystemConfigs',
'FunctionName',
'KmsKeyArn',
'PackageType',
'CodeSigningConfigArn',
'Layers',
'Tags',
'ImageConfig',
'MemorySize',
'DeadLetterConfig',
'Timeout',
'LoggingConfig',
'RecursiveLoop',
'Environment',
'EphemeralStorage',
'Architectures',
]);

await client.closeDocument({ textDocument: { uri } });
});
Expand Down Expand Up @@ -3519,7 +3540,7 @@ Resources:
});

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

// todo: condition are not provided as completions
// although template validation throws error
// '' is not one of ['CreateProdResources']

await client.closeDocument({ textDocument: { uri } });
});
});
Expand Down Expand Up @@ -3787,8 +3804,29 @@ Resources:
expect(completions?.items).toBeDefined();

const labels = completions.items.map((item: any) => item.label);
expect(labels).toContain('Description');
expect(labels).toContain('Architectures');
expect(labels).toEqual([
'Description',
'TracingConfig',
'VpcConfig',
'RuntimeManagementConfig',
'ReservedConcurrentExecutions',
'SnapStart',
'FileSystemConfigs',
'KmsKeyArn',
'PackageType',
'CodeSigningConfigArn',
'Layers',
'Tags',
'ImageConfig',
'MemorySize',
'DeadLetterConfig',
'Timeout',
'LoggingConfig',
'RecursiveLoop',
'Environment',
'EphemeralStorage',
'Architectures',
]);

await client.closeDocument({ textDocument: { uri } });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ Resources: {}`;
expect(result?.exists).toBe(false);
});

it.todo('should handle malformed YAML gracefully', () => {
const malformedYaml = 'Parameters:\n - invalid: structure';

const result = utils.findParametersSection(malformedYaml, DocumentType.YAML);

expect(result).toBeDefined();
expect(result?.exists).toBe(false);
it('should handle malformed YAML gracefully', () => {
expect(utils.findParametersSection('Parameters:\n - invalid: structure', DocumentType.YAML)?.exists).toBe(
true,
);

expect(utils.findParametersSection('Parameters:- invalid: structure', DocumentType.YAML)?.exists).toBe(
false,
);
});
});

Expand Down
Loading