Skip to content

Commit fa3605e

Browse files
committedMar 20, 2025··
test: review-comment: Improve test
only allow one channel to get the full user-settings information from the backend Signed-off-by: Dominikus Hellgartner <dominikus.hellgartner@tngtech.com>
1 parent 7b9d4d4 commit fa3605e

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed
 

‎src/Frontend/Components/AttributionCountPerSourcePerLicenseTable/__tests__/AttributionCountPerSourcePerLicenseTable.test.tsx

+6-18
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function expectHeaderTextsToEqual(
5050
expectedHeaderTexts: Array<string>,
5151
) {
5252
const headerTexts = screen
53-
.getAllByTestId('classification-table-row-header')
53+
.getAllByTestId('table-cell-with-sorting')
5454
.map((node) => node.textContent);
5555

5656
expect(headerTexts).toEqual(expectedHeaderTexts);
@@ -60,11 +60,7 @@ describe('Attribution count per source per license table', () => {
6060
it('shows by default criticality and classification columns', () => {
6161
renderComponent(<AttributionCountPerSourcePerLicenseTable {...props} />);
6262

63-
const headerTexts = screen
64-
.getAllByTestId('classification-table-row-header')
65-
.map((node) => node.textContent);
66-
67-
expect(headerTexts).toEqual([
63+
expectHeaderTextsToEqual(screen, [
6864
'Namesorted ascending', //correct, the sorted, ascending is for a11y
6965
'Criticality',
7066
'Classification',
@@ -79,11 +75,7 @@ describe('Attribution count per source per license table', () => {
7975
actions: [setUserSetting({ showCriticality: false })],
8076
});
8177

82-
const headerTexts = screen
83-
.getAllByTestId('classification-table-row-header')
84-
.map((node) => node.textContent);
85-
86-
expect(headerTexts).toEqual([
78+
expectHeaderTextsToEqual(screen, [
8779
'Namesorted ascending', //correct, the sorted, ascending is for a11y
8880
'Classification',
8981
'SourceA',
@@ -97,11 +89,7 @@ describe('Attribution count per source per license table', () => {
9789
actions: [setUserSetting({ showClassifications: false })],
9890
});
9991

100-
const headerTexts = screen
101-
.getAllByTestId('classification-table-row-header')
102-
.map((node) => node.textContent);
103-
104-
expect(headerTexts).toEqual([
92+
expectHeaderTextsToEqual(screen, [
10593
'Namesorted ascending', //correct, the sorted, ascending is for a11y
10694
'Criticality',
10795
'SourceA',
@@ -126,8 +114,8 @@ describe('Attribution count per source per license table', () => {
126114
fireEvent.click(screen.getByText('Criticality'));
127115

128116
expectHeaderTextsToEqual(screen, [
129-
'Name', //correct, the sorted, ascending is for a11y
130-
'Criticalitysorted descending',
117+
'Name',
118+
'Criticalitysorted descending', //correct, the sorted, descending is for a11y
131119
'Classification',
132120
'SourceA',
133121
'SourceB',

‎src/Frontend/Components/TableCellWithSorting/TableCellWithSorting.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const TableCellWithSorting: React.FC<TableCellWithSortingProps> = (
3232
...props.sx,
3333
}}
3434
sortDirection={props.isSortedColumn ? props.order : false}
35-
data-testid="classification-table-row-header"
35+
data-testid="table-cell-with-sorting"
3636
>
3737
<TableSortLabel
3838
sx={{

0 commit comments

Comments
 (0)
Please sign in to comment.