Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fe-fpm-writer): apply context path to a building block based on min ui5 version #2312

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -211,24 +211,21 @@ exports[`Prompts - no project getCodeSnippet Type "chart", get code snippet 1`]
exports[`Prompts - no project getCodeSnippet Type "filter-bar", get code snippet 1`] = `
"<macros:FilterBar
id=\\"id\\"
metaPath=\\"/REPLACE_WITH_A_QUALIFIER\\"
contextPath=\\"REPLACE_WITH_ENTITY\\"
metaPath=\\"/REPLACE_WITH_ENTITY/REPLACE_WITH_A_QUALIFIER\\"
/>"
`;

exports[`Prompts - no project getCodeSnippet Type "table", get code snippet 1`] = `
"<macros:Table
id=\\"id\\"
metaPath=\\"/REPLACE_WITH_A_QUALIFIER\\"
contextPath=\\"REPLACE_WITH_ENTITY\\"
metaPath=\\"/REPLACE_WITH_ENTITY/REPLACE_WITH_A_QUALIFIER\\"
/>"
`;

exports[`Prompts - no project getCodeSnippet get code snippet with placeholders 1`] = `
"<macros:Table
id=\\"REPLACE_WITH_BUILDING_BLOCK_ID\\"
metaPath=\\"/REPLACE_WITH_A_QUALIFIER\\"
contextPath=\\"REPLACE_WITH_ENTITY\\"
metaPath=\\"/REPLACE_WITH_ENTITY/REPLACE_WITH_A_QUALIFIER\\"
type=\\"GridTable\\"
/>"
`;
Expand Down Expand Up @@ -1160,7 +1157,29 @@ exports[`Prompts getCodeSnippet Type "chart", get code snippet 1`] = `
/>"
`;

exports[`Prompts getCodeSnippet Type "chart", get code snippet, min ui5Version = 1.95.0 1`] = `
exports[`Prompts getCodeSnippet Type "chart", get code snippet, min ui5Version = 1.95.35 1`] = `
"<macros:Chart
id=\\"id\\"
metaPath=\\"qualifier\\"
contextPath=\\"/entity\\"
filterBar=\\"filterBar\\"
selectionMode=\\"testSelectionMode\\"
selectionChange=\\"function1\\"
/>"
`;

exports[`Prompts getCodeSnippet Type "chart", get code snippet, min ui5Version = 1.96.0 1`] = `
"<macros:Chart
id=\\"id\\"
metaPath=\\"qualifier\\"
contextPath=\\"/entity\\"
filterBar=\\"filterBar\\"
selectionMode=\\"testSelectionMode\\"
selectionChange=\\"function1\\"
/>"
`;

exports[`Prompts getCodeSnippet Type "chart", get code snippet, min ui5Version = 1.96.25 1`] = `
"<macros:Chart
id=\\"id\\"
metaPath=\\"qualifier\\"
Expand Down Expand Up @@ -1191,7 +1210,7 @@ exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet 1`] = `
/>"
`;

exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet, min ui5Version = 1.95.0 1`] = `
exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet, min ui5Version = 1.95.35 1`] = `
"<macros:FilterBar
id=\\"id\\"
metaPath=\\"qualifier\\"
Expand All @@ -1201,7 +1220,7 @@ exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet, min ui5Vers
/>"
`;

exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet, min ui5Version is undefined 1`] = `
exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet, min ui5Version = 1.96.0 1`] = `
"<macros:FilterBar
id=\\"id\\"
metaPath=\\"qualifier\\"
Expand All @@ -1211,6 +1230,24 @@ exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet, min ui5Vers
/>"
`;

exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet, min ui5Version = 1.96.25 1`] = `
"<macros:FilterBar
id=\\"id\\"
metaPath=\\"/entity/qualifier\\"
AlinaGovoruhina marked this conversation as resolved.
Show resolved Hide resolved
search=\\"function2\\"
filterChanged=\\"function1\\"
/>"
`;

exports[`Prompts getCodeSnippet Type "filter-bar", get code snippet, min ui5Version is undefined 1`] = `
"<macros:FilterBar
id=\\"id\\"
metaPath=\\"/entity/qualifier\\"
search=\\"function2\\"
filterChanged=\\"function1\\"
/>"
`;

exports[`Prompts getCodeSnippet Type "table", get code snippet 1`] = `
"<macros:Table
id=\\"id\\"
Expand All @@ -1222,7 +1259,7 @@ exports[`Prompts getCodeSnippet Type "table", get code snippet 1`] = `
/>"
`;

exports[`Prompts getCodeSnippet Type "table", get code snippet, min ui5Version = 1.95.0 1`] = `
exports[`Prompts getCodeSnippet Type "table", get code snippet, min ui5Version = 1.95.35 1`] = `
"<macros:Table
id=\\"id\\"
metaPath=\\"qualifier\\"
Expand All @@ -1234,7 +1271,7 @@ exports[`Prompts getCodeSnippet Type "table", get code snippet, min ui5Version =
/>"
`;

exports[`Prompts getCodeSnippet Type "table", get code snippet, min ui5Version is undefined 1`] = `
exports[`Prompts getCodeSnippet Type "table", get code snippet, min ui5Version = 1.96.0 1`] = `
"<macros:Table
id=\\"id\\"
metaPath=\\"qualifier\\"
Expand All @@ -1246,6 +1283,28 @@ exports[`Prompts getCodeSnippet Type "table", get code snippet, min ui5Version i
/>"
`;

exports[`Prompts getCodeSnippet Type "table", get code snippet, min ui5Version = 1.96.25 1`] = `
"<macros:Table
id=\\"id\\"
metaPath=\\"/entity/qualifier\\"
filterBar=\\"filterBar\\"
header=\\"header\\"
headerVisible=\\"true\\"
type=\\"ResponsiveTable\\"
/>"
`;

exports[`Prompts getCodeSnippet Type "table", get code snippet, min ui5Version is undefined 1`] = `
"<macros:Table
id=\\"id\\"
metaPath=\\"/entity/qualifier\\"
filterBar=\\"filterBar\\"
header=\\"header\\"
headerVisible=\\"true\\"
type=\\"ResponsiveTable\\"
/>"
`;

exports[`Prompts getCodeSnippet get code snippet with placeholders 1`] = `
"<macros:Table
id=\\"REPLACE_WITH_BUILDING_BLOCK_ID\\"
Expand Down
18 changes: 16 additions & 2 deletions packages/fe-fpm-writer/test/unit/prompts/prompts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,22 @@ describe('Prompts', () => {
expect(result.viewOrFragmentPath.filePathProps?.fileName).toBe('Main.view.xml');
});

test.each(types)('Type "%s", get code snippet, min ui5Version = 1.95.0', async (type: PromptsType) => {
jest.spyOn(projectAccess, 'getMinimumUI5Version').mockReturnValueOnce('1.95.0');
test.each(types)('Type "%s", get code snippet, min ui5Version = 1.95.35', async (type: PromptsType) => {
jest.spyOn(projectAccess, 'getMinimumUI5Version').mockReturnValueOnce('1.95.35');
const result = promptsAPI.getCodeSnippets(type, answers[type] as SupportedGeneratorAnswers);
expect(result.viewOrFragmentPath.content).toMatchSnapshot();
expect(result.viewOrFragmentPath.filePathProps?.fileName).toBe('Main.view.xml');
});

test.each(types)('Type "%s", get code snippet, min ui5Version = 1.96.0', async (type: PromptsType) => {
jest.spyOn(projectAccess, 'getMinimumUI5Version').mockReturnValueOnce('1.96.0');
const result = promptsAPI.getCodeSnippets(type, answers[type] as SupportedGeneratorAnswers);
expect(result.viewOrFragmentPath.content).toMatchSnapshot();
expect(result.viewOrFragmentPath.filePathProps?.fileName).toBe('Main.view.xml');
});

test.each(types)('Type "%s", get code snippet, min ui5Version = 1.96.25', async (type: PromptsType) => {
jest.spyOn(projectAccess, 'getMinimumUI5Version').mockReturnValueOnce('1.96.25');
const result = promptsAPI.getCodeSnippets(type, answers[type] as SupportedGeneratorAnswers);
expect(result.viewOrFragmentPath.content).toMatchSnapshot();
expect(result.viewOrFragmentPath.filePathProps?.fileName).toBe('Main.view.xml');
Expand Down