Skip to content

Commit

Permalink
Add a table page object function to get an icon's severity (#2457)
Browse files Browse the repository at this point in the history
# Pull Request

## 🀨 Rationale

I'd like to be able to verify that icon severities are being set
correctly in the Assets table.

## πŸ‘©β€πŸ’» Implementation

Added a new page object function that gets the icon severity for a
particular cell. It is very similar to the existing function for getting
a cell's icon/spinner tag name.

## πŸ§ͺ Testing

N/A

## βœ… Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.

---------

Co-authored-by: Milan Raj <rajsite@users.noreply.github.com>
  • Loading branch information
m-akinc and rajsite authored Oct 29, 2024
1 parent b51ffc6 commit 42ed262
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Add a table page object function to get an icon's severity",
"packageName": "@ni/nimble-components",
"email": "7282195+m-akinc@users.noreply.github.com",
"dependentChangeType": "patch"
}
14 changes: 14 additions & 0 deletions packages/nimble-components/src/table/testing/table.pageobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Anchor, anchorTag } from '../../anchor';
import { tableGroupRowTag, type TableGroupRow } from '../components/group-row';
import type { Button } from '../../button';
import { Icon } from '../../icon-base';
import type { IconSeverity } from '../../icon-base/types';
import { Spinner, spinnerTag } from '../../spinner';
import { borderHoverColor } from '../../theme-provider/design-tokens';

Expand Down Expand Up @@ -207,6 +208,19 @@ export class TablePageObject<T extends TableRecord> {
return iconOrSpinner.tagName.toLocaleLowerCase();
}

public getRenderedMappingColumnCellIconSeverity(
rowIndex: number,
columnIndex: number
): IconSeverity {
const iconOrSpinner = this.getRenderedMappingColumnIconOrSpinner(
this.getRenderedCellView(rowIndex, columnIndex)
);
if (iconOrSpinner instanceof Icon) {
return iconOrSpinner.severity;
}
throw new Error('Cell does not contain an icon');
}

public getRenderedGroupHeaderTextContent(groupRowIndex: number): string {
return (
this.getGroupRowHeaderView(
Expand Down

0 comments on commit 42ed262

Please sign in to comment.