@@ -14,6 +14,7 @@ import type {
1414import type { AppFeatures , FPMFeatures } from '../types' ;
1515import { getObjectPageFeatures , getObjectPages } from './objectPageUtils' ;
1616import { getFilterFieldNames , getListReportFeatures } from './listReportUtils' ;
17+ import { extractTableColumnsFromNode } from './tableUtils' ;
1718
1819export interface AggregationItem extends TreeAggregation {
1920 description : string ;
@@ -128,44 +129,6 @@ export async function getAppFeatures(
128129 return featureData ;
129130}
130131
131- /**
132- * Gets identifier of a column for OPA5 tests.
133- * If the column is custom, the identifier is taken from the 'Key' entry in the schema keys.
134- * If the column is not custom, the identifier is taken from the 'Value' entry in the schema keys.
135- * If no such entry is found, undefined is returned.
136- *
137- * @param column - column module from ux specification
138- * @param column.custom boolean indicating whether the column is custom
139- * @param column.schema schema of the column
140- * @param column.schema.keys keys of the column; expected to have an entry with the name 'Key' or 'Value'
141- * @returns identifier of the column for OPA5 tests; can be the name or index
142- */
143- function getColumnIdentifier ( column : {
144- custom : boolean ;
145- schema : { keys : { name : string ; value : string } [ ] } ;
146- } ) : string | undefined {
147- const key = column . custom ? 'Key' : 'Value' ;
148- const keyEntry = column . schema . keys . find ( ( entry : { name : string ; value : string } ) => entry . name === key ) ;
149- return keyEntry ?. value ;
150- }
151-
152- /**
153- * Transforms column aggregations from the ux specification model into a map of columns for OPA5 tests.
154- *
155- * @param columnAggregations column aggregations from the ux specification model
156- * @returns a map of columns for OPA5 tests
157- */
158- function transformTableColumns ( columnAggregations : Record < string , any > ) : Record < string , any > {
159- const columns : Record < string , any > = { } ;
160- Object . values ( columnAggregations ) . forEach ( ( columnAggregation , index ) => {
161- columns [ getColumnIdentifier ( columnAggregation ) ?? index ] = {
162- header : columnAggregation . description
163- // TODO possibly more reliable properties could be used?
164- } ;
165- } ) ;
166- return columns ;
167- }
168-
169132/**
170133 * Retrieves table column data from the page model using ux-specification.
171134 *
@@ -180,8 +143,7 @@ export function getTableColumnData(
180143 let tableColumns : Record < string , Record < string , string | number | boolean > > = { } ;
181144
182145 try {
183- const columnAggregations = getTableColumns ( pageModel ) ;
184- tableColumns = transformTableColumns ( columnAggregations ) ;
146+ tableColumns = extractTableColumnsFromNode ( pageModel . root ) ;
185147 } catch ( error ) {
186148 log ?. debug ( error ) ;
187149 }
@@ -292,17 +254,3 @@ export function getFilterFields(pageModel: TreeModel): TreeAggregations {
292254 const selectionFieldsAggregations = getAggregations ( selectionFields ) ;
293255 return selectionFieldsAggregations ;
294256}
295-
296- /**
297- * Retrieves the table columns aggregation from the given tree model.
298- *
299- * @param pageModel - The tree model containing table column definitions.
300- * @returns The table columns aggregation object.
301- */
302- export function getTableColumns ( pageModel : TreeModel ) : TreeAggregations {
303- const table = getAggregations ( pageModel . root ) [ 'table' ] ;
304- const tableAggregations = getAggregations ( table ) ;
305- const columns = tableAggregations [ 'columns' ] ;
306- const columnAggregations = getAggregations ( columns ) ;
307- return columnAggregations ;
308- }
0 commit comments