|
1 | 1 | import ValueState from '@ui5/webcomponents-base/dist/types/ValueState.js'; |
| 2 | +import NoDataIllustration from '@ui5/webcomponents-fiori/dist/illustrations/NoData.js'; |
| 3 | +import NoFilterResults from '@ui5/webcomponents-fiori/dist/illustrations/NoFilterResults.js'; |
2 | 4 | import paperPlaneIcon from '@ui5/webcomponents-icons/paper-plane.js'; |
| 5 | +import { isIOS, isMac } from '@ui5/webcomponents-react-base/Device'; |
3 | 6 | import { ThemingParameters } from '@ui5/webcomponents-react-base/ThemingParameters'; |
| 7 | +import type { ComponentClass, ComponentProps } from 'react'; |
4 | 8 | import { useCallback, useEffect, useMemo, useRef, useState, version as reactVersion } from 'react'; |
5 | 9 | import type { |
6 | 10 | AnalyticalTableCellInstance, |
@@ -53,6 +57,7 @@ import { |
53 | 57 | FileUploader, |
54 | 58 | IndicationColor, |
55 | 59 | Icon, |
| 60 | + IllustratedMessage, |
56 | 61 | Input, |
57 | 62 | MessageViewButton, |
58 | 63 | MultiComboBox, |
@@ -80,7 +85,6 @@ import { useRowDisableSelection } from './pluginHooks/useRowDisableSelection'; |
80 | 85 | import { cssVarToRgb, cypressPassThroughTestsFactory } from '@/cypress/support/utils'; |
81 | 86 | import type { RowType } from '@/packages/main/src/components/AnalyticalTable/types/index.js'; |
82 | 87 | import { getUi5TagWithSuffix } from '@/packages/main/src/internal/utils.js'; |
83 | | -import { isIOS, isMac } from '@ui5/webcomponents-react-base/Device'; |
84 | 88 |
|
85 | 89 | const canUseVoiceOver = isIOS() || isMac(); |
86 | 90 |
|
@@ -1859,6 +1863,70 @@ describe('AnalyticalTable', () => { |
1859 | 1863 | cy.findByText('No data found. Try adjusting the filter settings.').should('be.visible'); |
1860 | 1864 | }); |
1861 | 1865 |
|
| 1866 | + it('NoDataComponent', () => { |
| 1867 | + const NoDataComponent = ( |
| 1868 | + props: ComponentProps<Exclude<AnalyticalTablePropTypes['NoDataComponent'], ComponentClass<any>>>, |
| 1869 | + ) => { |
| 1870 | + return props.noDataReason === 'Filtered' ? ( |
| 1871 | + <IllustratedMessage role={props.accessibleRole} name={NoFilterResults} /> |
| 1872 | + ) : ( |
| 1873 | + <IllustratedMessage role={props.accessibleRole} name={NoDataIllustration} /> |
| 1874 | + ); |
| 1875 | + }; |
| 1876 | + |
| 1877 | + cy.mount(<AnalyticalTable data={data} columns={columns} NoDataComponent={NoDataComponent} />); |
| 1878 | + cy.get('[data-component-name="AnalyticalTableBody"]').should('have.attr', 'style').and('include', 'height: 220px'); |
| 1879 | + cy.mount(<AnalyticalTable data={[]} columns={columns} NoDataComponent={NoDataComponent} />); |
| 1880 | + cy.get('[data-component-name="AnalyticalTableNoDataContainer"]') |
| 1881 | + .should('have.attr', 'style') |
| 1882 | + .and('include', 'height: 220px'); |
| 1883 | + |
| 1884 | + cy.mount( |
| 1885 | + <div style={{ height: '400px' }}> |
| 1886 | + <AnalyticalTable |
| 1887 | + data={[...data, ...data]} |
| 1888 | + columns={columns} |
| 1889 | + NoDataComponent={NoDataComponent} |
| 1890 | + visibleRowCountMode="Auto" |
| 1891 | + /> |
| 1892 | + </div>, |
| 1893 | + ); |
| 1894 | + cy.get('[data-component-name="AnalyticalTableBody"]').should('have.attr', 'style').and('include', 'height: 352px'); |
| 1895 | + cy.mount( |
| 1896 | + <div style={{ height: '400px' }}> |
| 1897 | + <AnalyticalTable data={[]} columns={columns} NoDataComponent={NoDataComponent} visibleRowCountMode="Auto" /> |
| 1898 | + </div>, |
| 1899 | + ); |
| 1900 | + cy.get('[data-component-name="AnalyticalTableNoDataContainer"]') |
| 1901 | + .should('have.attr', 'style') |
| 1902 | + .and('include', 'height: 352px'); |
| 1903 | + |
| 1904 | + cy.mount( |
| 1905 | + <div style={{ height: '400px' }}> |
| 1906 | + <AnalyticalTable |
| 1907 | + data={data} |
| 1908 | + columns={columns} |
| 1909 | + NoDataComponent={NoDataComponent} |
| 1910 | + visibleRowCountMode="AutoWithEmptyRows" |
| 1911 | + /> |
| 1912 | + </div>, |
| 1913 | + ); |
| 1914 | + cy.get('[data-component-name="AnalyticalTableBody"]').should('have.attr', 'style').and('include', 'height: 352px'); |
| 1915 | + cy.mount( |
| 1916 | + <div style={{ height: '400px' }}> |
| 1917 | + <AnalyticalTable |
| 1918 | + data={[]} |
| 1919 | + columns={columns} |
| 1920 | + NoDataComponent={NoDataComponent} |
| 1921 | + visibleRowCountMode="AutoWithEmptyRows" |
| 1922 | + /> |
| 1923 | + </div>, |
| 1924 | + ); |
| 1925 | + cy.get('[data-component-name="AnalyticalTableNoDataContainer"]') |
| 1926 | + .should('have.attr', 'style') |
| 1927 | + .and('include', 'height: 352px'); |
| 1928 | + }); |
| 1929 | + |
1862 | 1930 | it('Alternate Row Color', () => { |
1863 | 1931 | const standardRowColor = cssVarToRgb(ThemingParameters.sapList_Background); |
1864 | 1932 | const alternatingRowColor = cssVarToRgb(ThemingParameters.sapList_AlternatingBackground); |
|
0 commit comments