-
Notifications
You must be signed in to change notification settings - Fork 59
feat(ui5-test-writer): Generate tests for Form and Table content of Object Page Sections #4593
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
sap-sebelao
wants to merge
5
commits into
main
Choose a base branch
from
feat/ui5-test-writer/gen-op-section-content
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 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
356a368
(feat) ui5-test-writer: Generate tests for form and Table content of …
sap-sebelao 385d8bb
Fix fallback and check when missing navigationProperty
sap-sebelao 92e3fde
Adjust based on AI review, update test
sap-sebelao aa5e5ac
Clean up types
sap-sebelao e9b81e3
Fix TS type issues caused by type adjustments
sap-sebelao 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/ui5-test-writer': patch | ||
| --- | ||
|
|
||
| Generate tests for Form and Table content in Object Page Sections |
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
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,62 @@ | ||
| import type { TreeAggregation } from '@sap/ux-specification/dist/types/src/parser'; | ||
| import { getAggregations } from './modelUtils'; | ||
|
|
||
| type ColumnSpec = { | ||
| custom?: boolean; | ||
| description?: string; | ||
| schema: { keys: { name: string; value: string }[] }; | ||
| }; | ||
|
|
||
| /** | ||
| * Gets the identifier of a column for OPA5 tests. | ||
| * Custom columns use the 'Key' entry; standard columns use the 'Value' entry from the schema keys. | ||
| * | ||
| * @param column - column item from ux specification | ||
| * @returns identifier of the column for OPA5 tests; undefined if no matching key entry is found | ||
| */ | ||
| export function getColumnIdentifier(column: ColumnSpec): string | undefined { | ||
| const key = column.custom ? 'Key' : 'Value'; | ||
| return column.schema.keys.find((k) => k.name === key)?.value; | ||
| } | ||
|
|
||
| /** | ||
| * Transforms column aggregations from the ux specification model into a map of columns for OPA5 tests. | ||
| * Each column entry includes the column header label for display verification. | ||
| * | ||
| * @param columnAggregations - column aggregations from the ux specification model | ||
| * @returns a map of column identifiers to column state objects for use with iCheckColumns() | ||
| */ | ||
| export function transformTableColumns( | ||
| columnAggregations: Record<string, ColumnSpec> | ||
| ): Record<string, Record<string, string | number | boolean>> { | ||
|
Check warning on line 31 in packages/ui5-test-writer/src/utils/tableUtils.ts
|
||
| const columns: Record<string, Record<string, string | number | boolean>> = {}; | ||
| Object.values(columnAggregations).forEach((col, index) => { | ||
| const id = getColumnIdentifier(col) ?? String(index); | ||
| const state: Record<string, string | number | boolean> = {}; | ||
| if (col.description) { | ||
| state['header'] = col.description; | ||
| } | ||
| columns[id] = state; | ||
| }); | ||
| return columns; | ||
| } | ||
|
|
||
| /** | ||
| * Extracts table column data from a spec model node that contains a 'table' aggregation. | ||
| * Covers both page-level nodes (List Report, FPM) via their root and section-level nodes | ||
| * (Object Page body sections) — both are TreeAggregation nodes that expose a 'table' aggregation. | ||
| * | ||
| * @param node - tree aggregation node that exposes a 'table' aggregation | ||
| * @returns a map of column identifiers to column state objects for use with iCheckColumns() | ||
| */ | ||
| export function extractTableColumnsFromNode( | ||
| node: TreeAggregation | ||
| ): Record<string, Record<string, string | number | boolean>> { | ||
| const tableAggregation = getAggregations(node)['table']; | ||
| if (!tableAggregation) { | ||
| return {}; | ||
| } | ||
| const columnsAggregation = getAggregations(tableAggregation)['columns']; | ||
| const columnItems = getAggregations(columnsAggregation); | ||
| return transformTableColumns(columnItems as unknown as Record<string, ColumnSpec>); | ||
|
sap-sebelao marked this conversation as resolved.
Outdated
|
||
| } | ||
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.