Skip to content

Commit 4821f40

Browse files
authored
fix: remove operations counter (#2540)
1 parent a392546 commit 4821f40

File tree

6 files changed

+74
-125
lines changed

6 files changed

+74
-125
lines changed

src/containers/Operations/Operations.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ export function Operations({database, scrollContainerRef}: OperationsProps) {
2323
const {kind, searchValue, pageSize, handleKindChange, handleSearchChange} =
2424
useOperationsQueryParams();
2525

26-
const {operations, isLoading, isLoadingMore, error, refreshTable, totalCount} =
27-
useOperationsInfiniteQuery({
28-
database,
29-
kind,
30-
pageSize,
31-
searchValue,
32-
scrollContainerRef,
33-
});
26+
const {operations, isLoading, isLoadingMore, error, refreshTable} = useOperationsInfiniteQuery({
27+
database,
28+
kind,
29+
pageSize,
30+
searchValue,
31+
scrollContainerRef,
32+
});
3433

3534
const settings = React.useMemo(() => {
3635
return {
@@ -49,9 +48,6 @@ export function Operations({database, scrollContainerRef}: OperationsProps) {
4948
<OperationsControls
5049
kind={kind}
5150
searchValue={searchValue}
52-
entitiesCountCurrent={operations.length}
53-
entitiesCountTotal={totalCount}
54-
entitiesLoading={isLoading}
5551
handleKindChange={handleKindChange}
5652
handleSearchChange={handleSearchChange}
5753
/>

src/containers/Operations/OperationsControls.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22

33
import {Select} from '@gravity-ui/uikit';
44

5-
import {EntitiesCount} from '../../components/EntitiesCount';
65
import {Search} from '../../components/Search';
76
import type {OperationKind} from '../../types/api/operations';
87

@@ -15,19 +14,13 @@ import './Operations.scss';
1514
interface OperationsControlsProps {
1615
kind: OperationKind;
1716
searchValue: string;
18-
entitiesCountCurrent: number;
19-
entitiesCountTotal?: number;
20-
entitiesLoading: boolean;
2117
handleKindChange: (kind: OperationKind) => void;
2218
handleSearchChange: (value: string) => void;
2319
}
2420

2521
export function OperationsControls({
2622
kind,
2723
searchValue,
28-
entitiesCountCurrent,
29-
entitiesCountTotal,
30-
entitiesLoading,
3124
handleKindChange,
3225
handleSearchChange,
3326
}: OperationsControlsProps) {
@@ -45,12 +38,6 @@ export function OperationsControls({
4538
options={OPERATION_KINDS}
4639
onUpdate={(value) => handleKindChange(value[0] as OperationKind)}
4740
/>
48-
<EntitiesCount
49-
label={i18n('label_operations')}
50-
loading={entitiesLoading}
51-
total={entitiesCountTotal}
52-
current={entitiesCountCurrent}
53-
/>
5441
</React.Fragment>
5542
);
5643
}

src/containers/Operations/i18n/en.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"label_operations": "Operations",
32
"title_empty": "No operations data",
43
"pleaceholder_search": "Search operations",
54
"placeholder_kind": "Select operation kind",
@@ -8,7 +7,6 @@
87
"kind_export_yt": "Export/YT",
98
"kind_import_s3": "Import/S3",
109
"kind_buildIndex": "Build Index",
11-
1210
"column_operationId": "Operation ID",
1311
"column_status": "Status",
1412
"column_createdBy": "Created By",
@@ -18,7 +16,6 @@
1816
"column_state": "State",
1917
"column_progress": "Progress",
2018
"label_duration-ongoing": "{{value}} (ongoing)",
21-
2219
"header_cancel": "Cancel operation",
2320
"header_forget": "Forget operation",
2421
"text_cancel": "The operation will be cancelled. Do you want to proceed?",

src/containers/Operations/useOperationsInfiniteQuery.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,5 @@ export function useOperationsInfiniteQuery({
116116
isLoadingMore: isFetchingNextPage,
117117
error,
118118
refreshTable: refetch,
119-
totalCount: allOperations.length,
120119
};
121120
}

tests/suites/tenant/diagnostics/tabs/OperationsModel.ts

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -150,56 +150,19 @@ export class OperationsTable extends BaseModel {
150150
return await this.accessDeniedTitle.innerText();
151151
}
152152

153-
async getOperationsCount(): Promise<number> {
154-
// The EntitiesCount component renders a Label with the count
155-
const countLabel = await this.page
156-
.locator('.ydb-entities-count .g-label__content')
157-
.textContent();
158-
if (!countLabel) {
159-
return 0;
160-
}
161-
const match = countLabel.match(/(\d+)/);
162-
return match ? parseInt(match[1], 10) : 0;
163-
}
164-
165-
async waitForOperationsCount(expectedCount: number, timeout = 5000): Promise<void> {
166-
await this.page.waitForFunction(
167-
(expected) => {
168-
const countElement = document.querySelector(
169-
'.ydb-entities-count .g-label__content',
170-
);
171-
if (!countElement) {
172-
return false;
173-
}
174-
const text = countElement.textContent || '';
175-
const match = text.match(/(\d+)/);
176-
const currentCount = match ? parseInt(match[1], 10) : 0;
177-
return currentCount === expected;
178-
},
179-
expectedCount,
180-
{timeout},
181-
);
182-
}
183-
184-
async waitForOperationsCountToChange(previousCount: number, timeout = 5000): Promise<number> {
153+
async waitForRowCountToChange(previousCount: number, timeout = 5000): Promise<number> {
185154
await this.page.waitForFunction(
186155
(prev) => {
187-
const countElement = document.querySelector(
188-
'.ydb-entities-count .g-label__content',
156+
const rows = document.querySelectorAll(
157+
'.data-table__row:not(.data-table__row_header)',
189158
);
190-
if (!countElement) {
191-
return false;
192-
}
193-
const text = countElement.textContent || '';
194-
const match = text.match(/(\d+)/);
195-
const currentCount = match ? parseInt(match[1], 10) : 0;
196-
return currentCount !== prev;
159+
return rows.length !== prev;
197160
},
198161
previousCount,
199162
{timeout},
200163
);
201-
// Now get the actual new count
202-
return await this.getOperationsCount();
164+
// Return the new row count
165+
return await this.getRowCount();
203166
}
204167

205168
async isPageErrorVisible(): Promise<boolean> {

tests/suites/tenant/diagnostics/tabs/operations.test.ts

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ test.describe('Operations Tab - Infinite Query', () => {
3434
await diagnostics.operations.waitForTableVisible();
3535
await diagnostics.operations.waitForDataLoad();
3636

37-
// Wait a bit for the counter to stabilize after initial load
37+
// Wait a bit for the table to stabilize after initial load
3838
await page.waitForTimeout(1000);
3939

40-
// Verify initial page loaded (should show count in badge)
41-
const operationsCount = await diagnostics.operations.getOperationsCount();
42-
expect(operationsCount).toBeGreaterThan(0);
43-
expect(operationsCount).toBeLessThanOrEqual(20); // Should have up to DEFAULT_PAGE_SIZE operations loaded initially
40+
// Verify initial page loaded (should have up to DEFAULT_PAGE_SIZE operations)
41+
const rowCount = await diagnostics.operations.getRowCount();
42+
expect(rowCount).toBeGreaterThan(0);
43+
expect(rowCount).toBeLessThanOrEqual(20); // Should have up to DEFAULT_PAGE_SIZE operations loaded initially
4444

4545
// Verify first row data structure
4646
const firstRowData = await diagnostics.operations.getRowData(0);
@@ -78,32 +78,32 @@ test.describe('Operations Tab - Infinite Query', () => {
7878
await diagnostics.operations.waitForTableVisible();
7979
await diagnostics.operations.waitForDataLoad();
8080

81-
// Get initial operations count
82-
const initialOperationsCount = await diagnostics.operations.getOperationsCount();
83-
expect(initialOperationsCount).toBeGreaterThan(0);
81+
// Get initial row count
82+
const initialRowCount = await diagnostics.operations.getRowCount();
83+
expect(initialRowCount).toBeGreaterThan(0);
8484

8585
// Scroll to bottom
8686
await diagnostics.operations.scrollToBottom();
8787

88-
// Wait for operations count to potentially change
89-
let finalOperationsCount: number;
88+
// Wait for row count to potentially change
89+
let finalRowCount: number;
9090
try {
91-
finalOperationsCount = await diagnostics.operations.waitForOperationsCountToChange(
92-
initialOperationsCount,
91+
finalRowCount = await diagnostics.operations.waitForRowCountToChange(
92+
initialRowCount,
9393
3000,
9494
);
9595
} catch (_e) {
9696
// If timeout, the count didn't change
97-
finalOperationsCount = await diagnostics.operations.getOperationsCount();
97+
finalRowCount = await diagnostics.operations.getRowCount();
9898
}
9999

100100
// Check if more operations were loaded
101-
if (finalOperationsCount > initialOperationsCount) {
101+
if (finalRowCount > initialRowCount) {
102102
// Infinite scroll worked - more operations were loaded
103-
expect(finalOperationsCount).toBeGreaterThan(initialOperationsCount);
103+
expect(finalRowCount).toBeGreaterThan(initialRowCount);
104104
} else {
105-
// No more data to load - operations count should stay the same
106-
expect(finalOperationsCount).toBe(initialOperationsCount);
105+
// No more data to load - row count should stay the same
106+
expect(finalRowCount).toBe(initialRowCount);
107107
}
108108
});
109109

@@ -222,16 +222,12 @@ test.describe('Operations Tab - Infinite Query', () => {
222222
const rowCount = await diagnostics.operations.getRowCount();
223223
expect(rowCount).toBeLessThanOrEqual(1);
224224

225-
// Verify operations count is 0
226-
const operationsCount = await diagnostics.operations.getOperationsCount();
227-
expect(operationsCount).toBe(0);
228-
229225
// Wait to ensure no infinite refetching occurs
230226
await page.waitForTimeout(3000);
231227

232-
// Verify the count is still 0 (no infinite refetching)
233-
const finalOperationsCount = await diagnostics.operations.getOperationsCount();
234-
expect(finalOperationsCount).toBe(0);
228+
// Verify the count is still the same (no infinite refetching)
229+
const finalRowCount = await diagnostics.operations.getRowCount();
230+
expect(finalRowCount).toBe(rowCount);
235231
});
236232

237233
test('stops pagination when receiving malformed response after valid data', async ({page}) => {
@@ -254,9 +250,10 @@ test.describe('Operations Tab - Infinite Query', () => {
254250
await diagnostics.operations.waitForTableVisible();
255251
await diagnostics.operations.waitForDataLoad();
256252

257-
// Verify initial page loaded (should have 20 operations)
258-
const initialOperationsCount = await diagnostics.operations.getOperationsCount();
259-
expect(initialOperationsCount).toBe(20);
253+
// Verify initial page loaded (virtualized table may not show all 20 rows)
254+
const initialRowCount = await diagnostics.operations.getRowCount();
255+
expect(initialRowCount).toBeGreaterThan(0);
256+
expect(initialRowCount).toBeLessThanOrEqual(20);
260257

261258
// Verify first row data
262259
const firstRowData = await diagnostics.operations.getRowData(0);
@@ -274,16 +271,18 @@ test.describe('Operations Tab - Infinite Query', () => {
274271
await diagnostics.operations.waitForLoadingMoreToDisappear();
275272
}
276273

277-
// Verify the count remains at 20 (malformed response didn't add more)
278-
const finalOperationsCount = await diagnostics.operations.getOperationsCount();
279-
expect(finalOperationsCount).toBe(20);
274+
// Verify the count didn't significantly increase (malformed response didn't add more)
275+
const finalRowCount = await diagnostics.operations.getRowCount();
276+
// With virtualization, row count might vary slightly but shouldn't exceed initial data
277+
expect(finalRowCount).toBeLessThanOrEqual(20);
280278

281279
// Wait to ensure no infinite refetching occurs
282280
await page.waitForTimeout(3000);
283281

284-
// Verify the count is still 20
285-
const stillFinalCount = await diagnostics.operations.getOperationsCount();
286-
expect(stillFinalCount).toBe(20);
282+
// Verify the count remains stable (no infinite refetching)
283+
const stillFinalRowCount = await diagnostics.operations.getRowCount();
284+
// Allow for minor virtualization differences
285+
expect(Math.abs(stillFinalRowCount - finalRowCount)).toBeLessThanOrEqual(5);
287286
});
288287

289288
test('loads all operations when scrolling to the bottom multiple times', async ({page}) => {
@@ -306,21 +305,24 @@ test.describe('Operations Tab - Infinite Query', () => {
306305
await diagnostics.operations.waitForTableVisible();
307306
await diagnostics.operations.waitForDataLoad();
308307

309-
// Wait a bit for the counter to stabilize after initial load
308+
// Wait a bit for the table to stabilize after initial load
310309
await page.waitForTimeout(2000);
311310

312-
// Get initial operations count (should be around 20)
313-
const initialOperationsCount = await diagnostics.operations.getOperationsCount();
314-
expect(initialOperationsCount).toBeGreaterThan(0);
315-
expect(initialOperationsCount).toBeLessThanOrEqual(20);
311+
// Get initial row count (should be around 20)
312+
const initialRowCount = await diagnostics.operations.getRowCount();
313+
expect(initialRowCount).toBeGreaterThan(0);
314+
expect(initialRowCount).toBeLessThanOrEqual(20);
316315

317316
// Keep scrolling until all operations are loaded
318-
let previousOperationsCount = initialOperationsCount;
319-
let currentOperationsCount = initialOperationsCount;
317+
let previousRowCount = initialRowCount;
318+
let currentRowCount = initialRowCount;
320319
const maxScrollAttempts = 10; // Safety limit to prevent infinite loop
321320
let scrollAttempts = 0;
322321

323-
while (currentOperationsCount < 80 && scrollAttempts < maxScrollAttempts) {
322+
// Keep track of whether we're still loading more data
323+
let hasMoreData = true;
324+
325+
while (hasMoreData && scrollAttempts < maxScrollAttempts) {
324326
// Scroll to bottom
325327
await diagnostics.operations.scrollToBottom();
326328

@@ -333,28 +335,33 @@ test.describe('Operations Tab - Infinite Query', () => {
333335
await diagnostics.operations.waitForLoadingMoreToDisappear();
334336
}
335337

336-
// Wait for operations count to change or timeout
338+
// Wait for row count to change or timeout
337339
try {
338-
currentOperationsCount =
339-
await diagnostics.operations.waitForOperationsCountToChange(
340-
previousOperationsCount,
341-
3000,
342-
);
340+
currentRowCount = await diagnostics.operations.waitForRowCountToChange(
341+
previousRowCount,
342+
3000,
343+
);
344+
// If row count changed, we still have more data
345+
hasMoreData = true;
343346
} catch (_e) {
344347
// If timeout, the count didn't change - we might have reached the end
345-
currentOperationsCount = await diagnostics.operations.getOperationsCount();
348+
currentRowCount = await diagnostics.operations.getRowCount();
349+
hasMoreData = false;
346350
}
347351

348-
previousOperationsCount = currentOperationsCount;
352+
previousRowCount = currentRowCount;
349353
scrollAttempts++;
350354
}
351355

352-
// Verify all 80 operations were loaded
353-
expect(currentOperationsCount).toBe(80);
356+
// With virtualization, we can't verify exact count via DOM
357+
// But we should have more rows than initially
358+
expect(currentRowCount).toBeGreaterThan(initialRowCount);
354359

355360
const rowCount = await diagnostics.operations.getRowCount();
356-
// Verify the last operation has the expected ID pattern
357-
const lastRowData = await diagnostics.operations.getRowData(rowCount - 1);
358-
expect(lastRowData['Operation ID']).toContain('ydb://');
361+
// Verify we can read data from the last visible row
362+
if (rowCount > 0) {
363+
const lastRowData = await diagnostics.operations.getRowData(rowCount - 1);
364+
expect(lastRowData['Operation ID']).toContain('ydb://');
365+
}
359366
});
360367
});

0 commit comments

Comments
 (0)