Skip to content

Commit ab7ae67

Browse files
committed
[Upgrade Assistant] Tighten ES deprecations unit coverage parity
Add missing unit assertions and scenarios to fully cover behaviors previously exercised by the removed client integration suite. Made-with: Cursor
1 parent 4eab494 commit ab7ae67

5 files changed

Lines changed: 166 additions & 26 deletions

File tree

x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/data_streams/flyout/steps/checklist/checklist_reindex_step.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ describe('ChecklistFlyoutStep (data streams)', () => {
112112
cancelAction,
113113
});
114114

115+
expect(screen.getByTestId('startDataStreamMigrationButton')).toBeDisabled();
115116
fireEvent.click(screen.getByTestId('cancelDataStreamMigrationButton'));
116117
expect(cancelAction).toHaveBeenCalledTimes(1);
117118
});

x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/data_streams/flyout/steps/checklist/progress.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ describe('MigrationProgress', () => {
4343
renderWithI18n(<MigrationProgress migrationState={migrationState} dataStreamName="logs-foo" />);
4444

4545
expect(screen.getByTestId('reindexChecklistTitle')).toHaveTextContent('logs-foo');
46+
expect(screen.getByTestId('reindexChecklistTitle')).toHaveTextContent(
47+
'Reindexing logs-foo in progress…'
48+
);
4649
expect(screen.getByText('1 Index failed to get reindexed.')).toBeInTheDocument();
4750
expect(screen.getByText('2 Indices successfully reindexed.')).toBeInTheDocument();
4851
expect(screen.getByText('3 Indices currently getting reindexed.')).toBeInTheDocument();
@@ -70,6 +73,9 @@ describe('MigrationProgress', () => {
7073

7174
renderWithI18n(<MigrationProgress migrationState={migrationState} dataStreamName="logs-bar" />);
7275

76+
expect(screen.getByTestId('reindexChecklistTitle')).toHaveTextContent(
77+
'Setting to read-only logs-bar in progress…'
78+
);
7379
expect(screen.getByText('1 Index successfully set to read-only.')).toBeInTheDocument();
7480
expect(screen.getByText('0 Indices currently getting set to read-only.')).toBeInTheDocument();
7581
expect(screen.getByText('1 Index waiting to start.')).toBeInTheDocument();

x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/reindex/progress.test.tsx

Lines changed: 125 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,28 @@ import { renderWithI18n } from '@kbn/test-jest-helpers';
1313
import { ReindexStep } from '@kbn/reindex-service-plugin/common';
1414
import { ReindexStatus } from '@kbn/upgrade-assistant-pkg-common';
1515
import { LoadingState } from '../../../../../../types';
16-
import type { ReindexState } from '../../../use_reindex';
1716
import { ReindexProgress } from './progress';
17+
import { createReindexState } from '../../../../test_utils/helpers';
1818

1919
describe('ReindexProgress', () => {
2020
it('renders', () => {
2121
renderWithI18n(
2222
<ReindexProgress
23-
reindexState={
24-
{
25-
lastCompletedStep: ReindexStep.created,
26-
status: ReindexStatus.inProgress,
27-
reindexTaskPercComplete: null,
28-
errorMessage: null,
23+
reindexState={{
24+
...createReindexState({
2925
loadingState: LoadingState.Success,
3026
meta: {
27+
...createReindexState().meta,
3128
indexName: 'foo',
3229
reindexName: 'reindexed-foo',
3330
aliases: [],
34-
isFrozen: false,
35-
isReadonly: false,
36-
isInDataStream: false,
37-
isClosedIndex: false,
38-
isFollowerIndex: false,
3931
},
40-
} as ReindexState
41-
}
32+
}),
33+
lastCompletedStep: ReindexStep.created,
34+
status: ReindexStatus.inProgress,
35+
reindexTaskPercComplete: null,
36+
errorMessage: null,
37+
}}
4238
cancelReindex={jest.fn()}
4339
/>
4440
);
@@ -61,25 +57,22 @@ describe('ReindexProgress', () => {
6157
it('displays errors in the step that failed', () => {
6258
renderWithI18n(
6359
<ReindexProgress
64-
reindexState={
65-
{
66-
lastCompletedStep: ReindexStep.reindexCompleted,
67-
status: ReindexStatus.failed,
68-
reindexTaskPercComplete: 1,
69-
errorMessage: `This is an error that happened on alias switch`,
60+
reindexState={{
61+
...createReindexState({
7062
loadingState: LoadingState.Success,
7163
meta: {
64+
...createReindexState().meta,
7265
indexName: 'foo',
7366
reindexName: 'reindexed-foo',
7467
aliases: [],
7568
isFrozen: true,
76-
isReadonly: false,
77-
isInDataStream: false,
78-
isClosedIndex: false,
79-
isFollowerIndex: false,
8069
},
81-
} as ReindexState
82-
}
70+
}),
71+
lastCompletedStep: ReindexStep.reindexCompleted,
72+
status: ReindexStatus.failed,
73+
reindexTaskPercComplete: 1,
74+
errorMessage: `This is an error that happened on alias switch`,
75+
}}
8376
cancelReindex={jest.fn()}
8477
/>
8578
);
@@ -97,4 +90,110 @@ describe('ReindexProgress', () => {
9790
expect(stepContent!).toHaveTextContent('There was an error');
9891
expect(stepContent!).toHaveTextContent('This is an error that happened on alias switch');
9992
});
93+
94+
it('has started but not yet reindexing documents', () => {
95+
renderWithI18n(
96+
<ReindexProgress
97+
reindexState={{
98+
...createReindexState({
99+
loadingState: LoadingState.Success,
100+
meta: {
101+
...createReindexState().meta,
102+
indexName: 'foo',
103+
reindexName: 'reindexed-foo',
104+
aliases: [],
105+
},
106+
}),
107+
lastCompletedStep: ReindexStep.readonly,
108+
status: ReindexStatus.inProgress,
109+
reindexTaskPercComplete: null,
110+
}}
111+
cancelReindex={jest.fn()}
112+
/>
113+
);
114+
115+
expect(screen.getByTestId('reindexChecklistTitle')).toHaveTextContent(
116+
'Reindexing in progress… 5%'
117+
);
118+
expect(screen.queryByTestId('cancelReindexingDocumentsButton')).toBeNull();
119+
});
120+
121+
it('has started reindexing documents', () => {
122+
renderWithI18n(
123+
<ReindexProgress
124+
reindexState={{
125+
...createReindexState({
126+
loadingState: LoadingState.Success,
127+
meta: {
128+
...createReindexState().meta,
129+
indexName: 'foo',
130+
reindexName: 'reindexed-foo',
131+
aliases: [],
132+
},
133+
}),
134+
lastCompletedStep: ReindexStep.reindexStarted,
135+
status: ReindexStatus.inProgress,
136+
reindexTaskPercComplete: 0.25,
137+
}}
138+
cancelReindex={jest.fn()}
139+
/>
140+
);
141+
142+
expect(screen.getByTestId('reindexChecklistTitle')).toHaveTextContent(
143+
'Reindexing in progress… 30%'
144+
);
145+
expect(screen.getByTestId('cancelReindexingDocumentsButton')).toBeInTheDocument();
146+
});
147+
148+
it('has completed reindexing documents', () => {
149+
renderWithI18n(
150+
<ReindexProgress
151+
reindexState={{
152+
...createReindexState({
153+
loadingState: LoadingState.Success,
154+
meta: {
155+
...createReindexState().meta,
156+
indexName: 'foo',
157+
reindexName: 'reindexed-foo',
158+
aliases: [],
159+
},
160+
}),
161+
lastCompletedStep: ReindexStep.reindexCompleted,
162+
status: ReindexStatus.inProgress,
163+
reindexTaskPercComplete: 1,
164+
}}
165+
cancelReindex={jest.fn()}
166+
/>
167+
);
168+
169+
expect(screen.getByTestId('reindexChecklistTitle')).toHaveTextContent(
170+
'Reindexing in progress… 90%'
171+
);
172+
expect(screen.queryByTestId('cancelReindexingDocumentsButton')).toBeNull();
173+
});
174+
175+
it('has completed', () => {
176+
renderWithI18n(
177+
<ReindexProgress
178+
reindexState={{
179+
...createReindexState({
180+
loadingState: LoadingState.Success,
181+
meta: {
182+
...createReindexState().meta,
183+
indexName: 'foo',
184+
reindexName: 'reindexed-foo',
185+
aliases: [],
186+
},
187+
}),
188+
lastCompletedStep: ReindexStep.aliasCreated,
189+
status: ReindexStatus.completed,
190+
reindexTaskPercComplete: 1,
191+
}}
192+
cancelReindex={jest.fn()}
193+
/>
194+
);
195+
196+
expect(screen.getByTestId('reindexChecklistTitle')).toHaveTextContent('Reindexing process');
197+
expect(screen.queryByTestId('cancelReindexingDocumentsButton')).toBeNull();
198+
});
100199
});

x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/resolution_table_cell.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ describe('ReindexResolutionCell', () => {
6969
mockUseIndexContext.mockReset();
7070
});
7171

72+
it('recommends reindexing by default', () => {
73+
mockUseIndexContext.mockReturnValue(
74+
createIndexContext({
75+
deprecation: reindexDeprecation,
76+
reindexState: createReindexState(),
77+
updateIndexState: createUpdateIndexState(),
78+
})
79+
);
80+
81+
renderWithI18n(<ReindexResolutionCell deprecation={reindexDeprecation} />);
82+
83+
expect(screen.getByText('Recommended: reindex')).toBeInTheDocument();
84+
});
85+
7286
it('recommends unfreeze for frozen indices', () => {
7387
mockUseIndexContext.mockReturnValue(
7488
createIndexContext({

x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/ml_snapshots/flyout.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,26 @@ describe('FixSnapshotsFlyout', () => {
129129
expect(screen.getByTestId('upgradeSnapshotButton')).toHaveTextContent('Retry upgrade');
130130
});
131131

132+
it('shows error callout and changes action labels on delete failure', () => {
133+
const error: ResponseError = {
134+
statusCode: 500,
135+
message: 'Delete snapshot error',
136+
};
137+
const snapshotState: SnapshotState = {
138+
jobId: MOCK_JOB_ID,
139+
snapshotId: MOCK_SNAPSHOT_ID,
140+
status: 'error',
141+
action: 'delete',
142+
error,
143+
};
144+
145+
renderFlyout({ snapshotState, mlUpgradeModeEnabled: false });
146+
147+
expect(screen.getByTestId('resolveSnapshotError')).toHaveTextContent('Error deleting snapshot');
148+
expect(screen.getByTestId('resolveSnapshotError')).toHaveTextContent('Delete snapshot error');
149+
expect(screen.getByTestId('deleteSnapshotButton')).toHaveTextContent('Retry delete');
150+
});
151+
132152
it('calls upgradeSnapshot and closes flyout', () => {
133153
const snapshotState: SnapshotState = {
134154
jobId: MOCK_JOB_ID,

0 commit comments

Comments
 (0)