From 4ab7a1ca4afcdc960a8448d978bb0d5b28cd757d Mon Sep 17 00:00:00 2001 From: Mert Akinc <7282195+m-akinc@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:49:32 -0500 Subject: [PATCH 1/3] Add a table page object function to get an icon's severity --- .../src/table/testing/table.pageobject.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/nimble-components/src/table/testing/table.pageobject.ts b/packages/nimble-components/src/table/testing/table.pageobject.ts index 8cc66039e1..c35b21d1c5 100644 --- a/packages/nimble-components/src/table/testing/table.pageobject.ts +++ b/packages/nimble-components/src/table/testing/table.pageobject.ts @@ -20,6 +20,7 @@ import type { Button } from '../../button'; import { Icon } from '../../icon-base'; import { Spinner, spinnerTag } from '../../spinner'; import { borderHoverColor } from '../../theme-provider/design-tokens'; +import { IconSeverity } from '../../icon-base/types'; /** * Summary information about a column that is sorted in the table for use in the `TablePageObject`. @@ -207,6 +208,18 @@ export class TablePageObject { return iconOrSpinner.tagName.toLocaleLowerCase(); } + public getRenderedMappingColumnCellIconSeverity( + rowIndex: number, + columnIndex: number + ): IconSeverity { + const iconOrSpinner = this.getRenderedMappingColumnIconOrSpinner( + this.getRenderedCellView(rowIndex, columnIndex) + ); + return iconOrSpinner instanceof Icon + ? iconOrSpinner.severity + : undefined; + } + public getRenderedGroupHeaderTextContent(groupRowIndex: number): string { return ( this.getGroupRowHeaderView( From 9168d679d23f3dca6cb1dec73f9e1e0faf7a61d8 Mon Sep 17 00:00:00 2001 From: Mert Akinc <7282195+m-akinc@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:50:14 -0500 Subject: [PATCH 2/3] Change files --- ...le-components-9d9491f3-1f39-4a0b-8196-7d5a25ae3b8f.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@ni-nimble-components-9d9491f3-1f39-4a0b-8196-7d5a25ae3b8f.json diff --git a/change/@ni-nimble-components-9d9491f3-1f39-4a0b-8196-7d5a25ae3b8f.json b/change/@ni-nimble-components-9d9491f3-1f39-4a0b-8196-7d5a25ae3b8f.json new file mode 100644 index 0000000000..5096a385fb --- /dev/null +++ b/change/@ni-nimble-components-9d9491f3-1f39-4a0b-8196-7d5a25ae3b8f.json @@ -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" +} From 8d3b3a707e476825e6d3ba74e89ac3286d716417 Mon Sep 17 00:00:00 2001 From: Mert Akinc <7282195+m-akinc@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:11:26 -0500 Subject: [PATCH 3/3] Throw if cell contains a spinner --- .../src/table/testing/table.pageobject.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/nimble-components/src/table/testing/table.pageobject.ts b/packages/nimble-components/src/table/testing/table.pageobject.ts index c35b21d1c5..5ef0628d33 100644 --- a/packages/nimble-components/src/table/testing/table.pageobject.ts +++ b/packages/nimble-components/src/table/testing/table.pageobject.ts @@ -18,9 +18,9 @@ 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'; -import { IconSeverity } from '../../icon-base/types'; /** * Summary information about a column that is sorted in the table for use in the `TablePageObject`. @@ -215,9 +215,10 @@ export class TablePageObject { const iconOrSpinner = this.getRenderedMappingColumnIconOrSpinner( this.getRenderedCellView(rowIndex, columnIndex) ); - return iconOrSpinner instanceof Icon - ? iconOrSpinner.severity - : undefined; + if (iconOrSpinner instanceof Icon) { + return iconOrSpinner.severity; + } + throw new Error('Cell does not contain an icon'); } public getRenderedGroupHeaderTextContent(groupRowIndex: number): string {