From 934868b7679f8516bb2b6b714b5e1bcf8a670c97 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Tue, 28 Oct 2025 15:28:04 +0530 Subject: [PATCH 1/6] Add table row click command based on text and optional column --- .../commands/miq_data_table_commands.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cypress/support/commands/miq_data_table_commands.js b/cypress/support/commands/miq_data_table_commands.js index 3cbe466c1a8..3923bfec50f 100644 --- a/cypress/support/commands/miq_data_table_commands.js +++ b/cypress/support/commands/miq_data_table_commands.js @@ -53,3 +53,23 @@ Cypress.Commands.add('selectTableRowsByText', ({ textArray = [] }) => { }); }); }); + +/** + * Command to click on a table row that contains the specified text. + * If columnIndex is provided, it will only look for the text in that specific column. + * + * @param {Object} params - Parameters for the command + * @param {string} params.text - Text to find in the table row + * @param {number} [params.columnIndex] - Optional index of the column to search in (0-based) + */ +Cypress.Commands.add('clickTableRowByText', ({ text, columnIndex }) => { + if (!text) { + cy.logAndThrowError('text parameter is required'); + } + + if (columnIndex || columnIndex === 0) { + cy.contains(`.miq-data-table table tbody tr td:nth-child(${columnIndex + 1})`, text).click(); + } else { + cy.contains('.miq-data-table table tbody tr td', text).click(); + } +}); From 044e1a588cdbd65244789f2999914975b92c1278 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Tue, 28 Oct 2025 15:30:13 +0530 Subject: [PATCH 2/6] Updated cypress README with clickTableRowByText info --- cypress/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/README.md b/cypress/README.md index 8bfc738bd85..3e6e4f52d66 100644 --- a/cypress/README.md +++ b/cypress/README.md @@ -55,6 +55,7 @@ ManageIQ implements the following cypress extensions: ##### miq_data_table_commands * `cy.selectTableRowsByText({ textArray })` - selects table rows that contain any of the specified text values. Iterates through each text in the array and finds the corresponding row. If any text is not found in the table, it throws an error immediately. `textArray` is an array of text values to match against table rows. e.g. `cy.selectTableRowsByText({ textArray: ['Option 1', 'Option 2'] });` +* `cy.clickTableRowByText({ text, columnIndex })` - clicks on a table row that contains the specified text. If columnIndex is provided, it will only look for the text in that specific column. `text` is the text to find in the table row. `columnIndex` is an optional 0-based index of the column to search in. e.g. `cy.clickTableRowByText({ text: 'My Service' });`, `cy.clickTableRowByText({ text: 'Active', columnIndex: 2 });` ##### tabs From 127f4394bd8a760765c8f517c7112cbb9c5be328 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Tue, 28 Oct 2025 15:31:37 +0530 Subject: [PATCH 3/6] Dropped gtl_no_record from commands --- cypress/support/commands/gtl.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cypress/support/commands/gtl.js b/cypress/support/commands/gtl.js index fdacf92e295..65de35850ea 100644 --- a/cypress/support/commands/gtl.js +++ b/cypress/support/commands/gtl.js @@ -4,10 +4,6 @@ Cypress.Commands.add('gtl_error', () => { return cy.get('#miq-gtl-view > #flash_msg_div').should('be.visible'); }); -Cypress.Commands.add('gtl_no_record', () => { - return cy.get('#miq-gtl-view > div.no-record').should('be.visible'); -}); - Cypress.Commands.add('gtlGetTable', () => { return cy.get('#miq-gtl-view > .miq-data-table > .miq-data-table > .bx--data-table-content > table'); }); From 50eb00207adf77f019dbd9bbb1e12c725d9fe2ae Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Tue, 28 Oct 2025 15:32:36 +0530 Subject: [PATCH 4/6] Removed gtl_no_record from cypress README --- cypress/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/README.md b/cypress/README.md index 3e6e4f52d66..f1261920988 100644 --- a/cypress/README.md +++ b/cypress/README.md @@ -38,7 +38,6 @@ ManageIQ implements the following cypress extensions: ##### gtl * `cy.gtl_error()` - check that error message is present. -* `cy.gtl_no_record()` - check that `No Record` message is present. * `cy.gtlGetTable()` - returns GTL table. * `cy.gtlGetRows(columns)` - return GTL table row data in an array. `columns`: Array of 0-based indexes of the columns to read (e.g. [1, 2, 3] will return all row data from columns 1, 2, and 3). * `cy.gtlClickRow(columns)` - click on a row in a GTL table. `columns`: Array of `{ title: String, number: Integer }`. `title` is the string you want to find in the table to click on, `number` is the column that string is found in. (e.g. `[{title: 'Default', number: 1}, {title: 'Compute', number: 2}]` will click on a row in the GTL table with `Default` in column 1 and `Compute` in column 2. Using just `[{title: 'Default', number: 1}]` will click on the first row found in the GTL table with `Default` in column 1). From ffcab812b31597f49332e5cfd82a6afb38a629b4 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Fri, 31 Oct 2025 15:41:17 +0530 Subject: [PATCH 5/6] Added expect_gtl_no_records_with_text assertion to replace gtl_no_record --- .../assertions/miq_data_table_assertions.js | 23 +++++++++++++++++++ cypress/support/e2e.js | 1 + 2 files changed, 24 insertions(+) create mode 100644 cypress/support/assertions/miq_data_table_assertions.js diff --git a/cypress/support/assertions/miq_data_table_assertions.js b/cypress/support/assertions/miq_data_table_assertions.js new file mode 100644 index 00000000000..5161c5a48eb --- /dev/null +++ b/cypress/support/assertions/miq_data_table_assertions.js @@ -0,0 +1,23 @@ +/* eslint-disable no-undef */ + +/** + * Command to verify that the GTL (Grid/Tile/List) view displays a "no records" message. + * This assertion checks that the specified text is visible within the GTL view container. + * + * @param {Object} params - Parameters for the command + * @param {string} [params.containsText='No records'] - The text to verify in the no records message + * @returns {Cypress.Chainable} A Cypress chainable that asserts the text is visible + * @example + * // Check for default "No records" message + * cy.expect_gtl_no_records_with_text(); + * + * @example + * // Check for custom message + * cy.expect_gtl_no_records_with_text({ containsText: 'No items found' }); + */ +Cypress.Commands.add( + 'expect_gtl_no_records_with_text', + ({ containsText = 'No records' } = {}) => { + return cy.contains('#miq-gtl-view', containsText).should('be.visible'); + } +); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index 4a1915269d6..c5051a30084 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -63,6 +63,7 @@ import './assertions/expect_rates_table.js'; import './assertions/expect_search_box.js'; import './assertions/expect_text.js'; import './assertions/expect_title.js'; +import './assertions/miq_data_table_assertions.js' // cypress on rails setup: // *********************************************************** From 5a31ec46a174ed9153afc327364b12e7896e36bb Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Fri, 31 Oct 2025 15:46:16 +0530 Subject: [PATCH 6/6] Updated cypress README with expect_gtl_no_records_with_text command info --- cypress/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/README.md b/cypress/README.md index f1261920988..6fcaf29ef16 100644 --- a/cypress/README.md +++ b/cypress/README.md @@ -98,6 +98,7 @@ ManageIQ implements the following cypress extensions: #### Assertions * `cy.expect_explorer_title(title)` - check that the title on an explorer screen matches the provided title. `title`: String for the title. +* `cy.expect_gtl_no_records_with_text({ containsText })` - verifies that the GTL view displays a "no records" message. Checks that the specified text is visible within the GTL view container. `containsText` is the optional text to verify in the no records message (defaults to 'No records'). e.g. `cy.expect_gtl_no_records_with_text();`, `cy.expect_gtl_no_records_with_text({ containsText: 'No items found' });` * `cy.expect_no_search_box()` - check if no searchbox is present on the screen. * `cy.expect_rates_table(headers, rows)` - check the values in a chargeback rate table. `headers`: Array of strings representing the headers of the table. `rows`: Array of type `[String, [...String], [...String], [...String], [...String], String]` where each index of the array represents a column in the table. The arrays within the `rows` array can be any length and represent the values in each given column, e.g. an array of `[0.0, 100.0]` in the index for the `Range Start` column would verify that the column contains two range starts with values `0.0` and `100.0`. * `cy.expect_show_list_title(title)` - check the title on a show\_list screen matches the provided title. `title`: String for the title.