generated from SAP/repository-template
-
Couldn't load subscription status.
- Fork 50
[FEATURE] Support Lean-App card generation for CAP based Fiori applications #3719
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
Open
Singham-24
wants to merge
15
commits into
main
Choose a base branch
from
feat/1304/card-gen-for-cap-apps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
694bdd0
feat: update flp.ts
Singham-24 36c5259
feat: update test cases
Singham-24 1413812
Merge branch 'main' into feat/1304/card-gen-for-cap-apps
Singham-24 0a5d787
feat: changeset added
Singham-24 74762b7
Merge branch 'feat/1304/card-gen-for-cap-apps' of https://github.com/…
Singham-24 f161ba1
feat: update test cases
Singham-24 11303a3
Linting auto fix commit
github-actions[bot] bf00d32
Merge branch 'main' into feat/1304/card-gen-for-cap-apps
Singham-24 bc9c903
feat: updated test cases
Singham-24 e3b6832
Merge branch 'main' into feat/1304/card-gen-for-cap-apps
Singham-24 cf5bae9
Merge branch 'feat/1304/card-gen-for-cap-apps' of https://github.com/…
Singham-24 f65f1ad
feat: typo fix
Singham-24 e23162e
Linting auto fix commit
github-actions[bot] 4aa6750
feat: readme updated
Singham-24 10b5997
Merge branch 'feat/1304/card-gen-for-cap-apps' of https://github.com/…
Singham-24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@sap-ux/preview-middleware': major | ||
| --- | ||
|
|
||
| i18n for CAP based apps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -820,18 +820,18 @@ describe('FlpSandbox', () => { | |
| afterEach(() => { | ||
| fetchMock.mockRestore(); | ||
| }); | ||
|
|
||
| let flp: FlpSandbox; | ||
| const setupMiddleware = async (mockConfig: Partial<MiddlewareConfig>) => { | ||
| const flp = new FlpSandbox(mockConfig, mockProject, mockUtils, logger); | ||
| flp = new FlpSandbox(mockConfig, mockProject, mockUtils, logger); | ||
| const manifest = JSON.parse(readFileSync(join(fixtures, 'simple-app/webapp/manifest.json'), 'utf-8')); | ||
| await flp.init(manifest); | ||
|
|
||
| const app = express(); | ||
| app.use(flp.router); | ||
|
|
||
| server = supertest(app); | ||
| return { flp, app }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The return parameters seem to be not use anywhere. Can this be deleted? |
||
| }; | ||
|
|
||
| beforeAll(async () => { | ||
| await setupMiddleware(mockConfig as MiddlewareConfig); | ||
| }); | ||
|
|
@@ -926,62 +926,68 @@ describe('FlpSandbox', () => { | |
| expect(createPropertiesI18nEntriesMock).toHaveBeenCalledTimes(1); | ||
| expect(createPropertiesI18nEntriesMock).toHaveBeenCalledWith(filePath, newI18nEntry); | ||
| }); | ||
| }); | ||
| test('should handle string i18n path', async () => { | ||
| const newI18nEntry = [{ key: 'HELLO', value: 'Hello World' }]; | ||
| const manifest = JSON.parse(readFileSync(join(fixtures, 'simple-app/webapp/manifest.json'), 'utf-8')); | ||
| manifest['sap.app'].i18n = 'i18n/custom.properties'; | ||
| await flp.init(manifest); | ||
| const response = await server.post(`${CARD_GENERATOR_DEFAULT.i18nStore}?locale=de`).send(newI18nEntry); | ||
| const webappPath = await getWebappPath(path.resolve()); | ||
| const expectedPath = join(webappPath, 'i18n', 'custom_de.properties'); | ||
|
|
||
| describe('router with enableCardGenerator in CAP project', () => { | ||
| let server!: SuperTest<Test>; | ||
| const mockConfig = { | ||
| editors: { | ||
| cardGenerator: { | ||
| path: 'test/flpCardGeneratorSandbox.html' | ||
| } | ||
| } | ||
| }; | ||
| expect(response.status).toBe(201); | ||
| expect(response.text).toBe('i18n file updated.'); | ||
| expect(createPropertiesI18nEntriesMock).toHaveBeenCalledWith(expectedPath, newI18nEntry); | ||
| }); | ||
|
|
||
| let mockFsPromisesWriteFile: jest.Mock; | ||
| test('should handle bundleUrl with supported and fallback locales', async () => { | ||
| const newI18nEntry = [{ key: 'GREETING', value: 'Hallo Welt' }]; | ||
| const manifest = JSON.parse(readFileSync(join(fixtures, 'simple-app/webapp/manifest.json'), 'utf-8')); | ||
| manifest['sap.app'].i18n = { | ||
| bundleUrl: 'i18n/i18n.properties', | ||
| supportedLocales: ['de', 'es'], | ||
| fallbackLocale: 'de' | ||
| }; | ||
| await flp.init(manifest); | ||
|
|
||
| beforeEach(() => { | ||
| mockFsPromisesWriteFile = jest.fn(); | ||
| promises.writeFile = mockFsPromisesWriteFile; | ||
| }); | ||
| const response = await server.post(`${CARD_GENERATOR_DEFAULT.i18nStore}?locale=de`).send(newI18nEntry); | ||
| const webappPath = await getWebappPath(path.resolve()); | ||
| const expectedPath = join(webappPath, 'i18n', 'i18n_de.properties'); | ||
|
|
||
| afterEach(() => { | ||
| fetchMock.mockRestore(); | ||
| expect(response.status).toBe(201); | ||
| expect(response.text).toBe('i18n file updated.'); | ||
| expect(createPropertiesI18nEntriesMock).toHaveBeenCalledWith(expectedPath, newI18nEntry); | ||
| }); | ||
|
|
||
| const setupMiddleware = async (mockConfig: Partial<MiddlewareConfig>) => { | ||
| const flp = new FlpSandbox(mockConfig, mockProject, mockUtils, logger); | ||
| test('should reject unsupported locale', async () => { | ||
| const newI18nEntry = [{ key: 'GREETING', value: 'Bonjour' }]; | ||
|
|
||
| const manifest = JSON.parse(readFileSync(join(fixtures, 'simple-app/webapp/manifest.json'), 'utf-8')); | ||
| jest.spyOn(projectAccess, 'getProjectType').mockImplementationOnce(() => Promise.resolve('CAPNodejs')); | ||
| manifest['sap.app'].i18n = { | ||
| bundleUrl: 'i18n/i18n.properties', | ||
| supportedLocales: ['de', 'es'] | ||
| }; | ||
| await flp.init(manifest); | ||
|
|
||
| const app = express(); | ||
| app.use(flp.router); | ||
|
|
||
| server = supertest(app); | ||
| }; | ||
| const response = await server.post(`${CARD_GENERATOR_DEFAULT.i18nStore}?locale=fr`).send(newI18nEntry); | ||
|
|
||
| beforeAll(async () => { | ||
| await setupMiddleware(mockConfig as MiddlewareConfig); | ||
| expect(response.status).toBe(400); | ||
| expect(response.text).toContain('Locale "fr" is not supported'); | ||
| }); | ||
| test('should fallback to default i18n/i18n.properties if no i18n defined', async () => { | ||
| const newI18nEntry = [{ key: 'HELLO', value: 'Hello World' }]; | ||
|
|
||
| test('GET /test/flpCardGeneratorSandbox.html', async () => { | ||
| const response = await server.get( | ||
| `${CARD_GENERATOR_DEFAULT.previewGeneratorSandbox}?sap-ui-xx-viewCache=false` | ||
| ); | ||
| expect(response.status).toBe(200); | ||
| expect(response.type).toBe('text/html'); | ||
| expect(logger.warn).toHaveBeenCalledWith('The Card Generator is not available for CAP projects.'); | ||
| }); | ||
| const manifest = JSON.parse(readFileSync(join(fixtures, 'simple-app/webapp/manifest.json'), 'utf-8')); | ||
| delete manifest['sap.app'].i18n; | ||
| await flp.init(manifest); | ||
| const response = await server.post(`${CARD_GENERATOR_DEFAULT.i18nStore}`).send(newI18nEntry); | ||
|
|
||
| test('POST /cards/store with payload', async () => { | ||
| const response = await server.post(CARD_GENERATOR_DEFAULT.cardsStore).send('hello'); | ||
| expect(response.status).toBe(404); | ||
| }); | ||
| const webappPath = await getWebappPath(path.resolve()); | ||
| const expectedPath = join(webappPath, 'i18n', 'i18n.properties'); | ||
|
|
||
| test('POST /editor/i18n with payload', async () => { | ||
| const response = await server.post(CARD_GENERATOR_DEFAULT.i18nStore).send('hello'); | ||
| expect(response.status).toBe(404); | ||
| expect(response.status).toBe(201); | ||
| expect(response.text).toBe('i18n file updated.'); | ||
| expect(createPropertiesI18nEntriesMock).toHaveBeenCalledWith(expectedPath, newI18nEntry); | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General question: What does the i18n adjustments have to do with card generation for CAP based apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier, the implementation only handled the default i18n.properties file and did not account for scenarios where the manifest defined i18n configurations using a bundleUrl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that. My question was rather what the i18n adjustment has to do with general cards support for CAP apps. According to this PR because of the missing object support for the i18n property, CAP apps have not been supported. But that's not true. Card generation fro CAP apps has been disabled in #3349 because you cannot deploy the generated cards / the generated cards will be ignored by the FLP. That only works for ABAP based FLPs. So basically my questions are:
string | objectall the time. That's nothing CAP specific. So that part rather looks like a bugfix to me.