Skip to content

Commit d964b20

Browse files
committed
Merge branch 'main' into e2e/refactoring-api-tests
# Conflicts: # tests/e2e/tests/regression/browser/stream-key.e2e.ts # tests/e2e/tests/regression/workbench/context.e2e.ts
2 parents c9dc93a + 0665f2b commit d964b20

File tree

59 files changed

+694
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+694
-181
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
coverage
77
dll
8-
node_modules
8+
**/node_modules
99
release
1010

1111
redisinsight/dist

redisinsight/api/src/modules/bulk-actions/models/runners/simple/abstract.bulk-action.simple.runner.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ export abstract class AbstractBulkActionSimpleRunner extends AbstractBulkActionR
4242
*/
4343
async runIteration() {
4444
const keys = await this.getKeysToProcess();
45+
this.progress.addScanned(this.bulkAction.getFilter().getCount());
46+
4547
if (keys.length) {
4648
const commands = this.prepareCommands(keys) as string[][];
4749
const res = await this.node.pipeline(commands).exec();
4850
this.processIterationResults(keys, res);
4951
}
52+
53+
this.bulkAction.changeState();
5054
}
5155

5256
/**
@@ -74,7 +78,6 @@ export abstract class AbstractBulkActionSimpleRunner extends AbstractBulkActionR
7478
* @param res
7579
*/
7680
processIterationResults(keys, res: (string | number | null)[][]) {
77-
this.progress.addScanned(this.bulkAction.getFilter().getCount());
7881
this.summary.addProcessed(res.length);
7982

8083
const errors = [];
@@ -88,6 +91,5 @@ export abstract class AbstractBulkActionSimpleRunner extends AbstractBulkActionR
8891
});
8992

9093
this.summary.addErrors(errors);
91-
this.bulkAction.changeState();
9294
}
9395
}

redisinsight/api/src/modules/profiler/models/redis.observer.spec.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@ describe('RedisObserver', () => {
5353
expect(redisObserver['status']).toEqual(RedisObserverStatus.Connected);
5454
expect(redisObserver['redis']).toEqual(nodeClient);
5555
});
56-
it('init error due to redis connection', async () => {
57-
try {
58-
getRedisClientFn.mockRejectedValueOnce(new Error('error'));
59-
await redisObserver.init(getRedisClientFn);
60-
fail();
61-
} catch (e) {
56+
it('init error due to redis connection', (done) => {
57+
getRedisClientFn.mockRejectedValueOnce(new Error('error'));
58+
redisObserver.init(getRedisClientFn);
59+
redisObserver.on('connect_error', () => {
6260
expect(redisObserver['status']).toEqual(RedisObserverStatus.Error);
6361
expect(redisObserver['redis']).toEqual(undefined);
64-
}
62+
done();
63+
});
6564
});
6665
});
6766

@@ -197,28 +196,26 @@ describe('RedisObserver', () => {
197196
expect(redisObserver['status']).toEqual(RedisObserverStatus.Ready);
198197
});
199198

200-
it('connect fail due to NOPERM', async () => {
201-
try {
202-
nodeClient.send_command.mockRejectedValueOnce(NO_PERM_ERROR);
203-
await redisObserver.init(getRedisClientFn);
204-
fail();
205-
} catch (e) {
206-
expect(e).toBeInstanceOf(ForbiddenException);
199+
it('connect fail due to NOPERM', (done) => {
200+
nodeClient.send_command.mockRejectedValueOnce(NO_PERM_ERROR);
201+
redisObserver.init(getRedisClientFn);
202+
redisObserver.on('connect_error', (e) => {
207203
expect(redisObserver['shardsObservers']).toEqual([]);
208204
expect(redisObserver['status']).toEqual(RedisObserverStatus.Error);
209-
}
205+
expect(e).toBeInstanceOf(ForbiddenException);
206+
done();
207+
});
210208
});
211209

212-
it('connect fail due an error', async () => {
213-
try {
214-
nodeClient.send_command.mockRejectedValueOnce(new Error('some error'));
215-
await redisObserver.init(getRedisClientFn);
216-
fail();
217-
} catch (e) {
210+
it('connect fail due an error', (done) => {
211+
nodeClient.send_command.mockRejectedValueOnce(new Error('some error'));
212+
redisObserver.init(getRedisClientFn);
213+
redisObserver.on('connect_error', (e) => {
218214
expect(e).toBeInstanceOf(ServiceUnavailableException);
219215
expect(redisObserver['shardsObservers']).toEqual([]);
220216
expect(redisObserver['status']).toEqual(RedisObserverStatus.Error);
221-
}
217+
done();
218+
});
222219
});
223220

224221
it('connect to cluster', async () => {

redisinsight/api/src/modules/profiler/models/redis.observer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export class RedisObserver extends EventEmitter2 {
4141
.catch((err) => {
4242
this.status = RedisObserverStatus.Error;
4343
this.emit('connect_error', err);
44-
return Promise.reject(err);
44+
// todo: rethink error handling for profiler
45+
// prevent unhandled rejection
46+
// return Promise.reject(err);
4547
});
4648
}
4749

redisinsight/ui/index.html.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<!-- Dependencies -->
1313
<% if (webpackConfig.mode=='production' ) { %>
1414
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js"
15-
integrity="sha256-yUhvEmYVhZ/GGshIQKArLvySDSh6cdmdcIx0spR3UP4=" crossorigin="anonymous"></script>
15+
integrity="sha512-8Q6Y9XnTbOE+JNvjBQwJ2H8S+UV4uA6hiRykhdtIyDYZ2TprdNmWOUaKdGzOhyr4dCyk287OejbPvwl7lrfqrQ==" crossorigin="anonymous"></script>
1616
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"
17-
integrity="sha256-vFt3l+illeNlwThbDUdoPTqF81M8WNSZZZt3HEjsbSU=" crossorigin="anonymous"></script>
17+
integrity="sha512-MOCpqoRoisCTwJ8vQQiciZv0qcpROCidek3GTFS6KTk2+y7munJIlKCVkFCYY+p3ErYFXCjmFjnfTTRSC1OHWQ==" crossorigin="anonymous"></script>
1818
<% } else { %>
1919
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.development.js"
2020
integrity="sha512-m7nhpWHotpucPI37I4lPovL28Bm2BhAMV8poF3F8Z9oOEZ3jlxGzkgvG0EMt1mVL1xydr1erlBbmN90js/ssUw==" crossorigin="anonymous"></script>

redisinsight/ui/src/components/consents-settings/ConsentOption/ConsentOption.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ interface Props {
1717
onChangeAgreement: (checked: boolean, name: string) => void
1818
checked: boolean
1919
isSettingsPage?: boolean
20+
withoutSpacer?: boolean
2021
}
2122

2223
const ConsentOption = (props: Props) => {
23-
const { consent, onChangeAgreement, checked, isSettingsPage = false } = props
24+
const {
25+
consent,
26+
onChangeAgreement,
27+
checked,
28+
isSettingsPage = false,
29+
withoutSpacer = false
30+
} = props
2431
return (
2532
<EuiFlexItem key={consent.agreementName}>
2633
{isSettingsPage && consent.description && (
@@ -52,7 +59,7 @@ const ConsentOption = (props: Props) => {
5259
)}
5360
</EuiFlexItem>
5461
</EuiFlexGroup>
55-
<EuiSpacer size="l" />
62+
{!withoutSpacer && (<EuiSpacer size="l" />)}
5663
</EuiFlexItem>
5764
)
5865
}

redisinsight/ui/src/components/consents-settings/ConsentsNotifications/ConsentsNotifications.spec.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
mockedStore,
88
cleanup,
99
clearStoreActions,
10-
waitFor,
10+
act,
1111
} from 'uiSrc/utils/test-utils'
1212
import { updateUserConfigSettings } from 'uiSrc/slices/user/user-settings'
1313
import ConsentsNotifications from './ConsentsNotifications'
@@ -83,8 +83,9 @@ describe('ConsentsNotifications', () => {
8383

8484
describe('update settings', () => {
8585
it('option change should call "updateUserConfigSettingsAction"', async () => {
86-
await waitFor(() => {
87-
render(<ConsentsNotifications />)
86+
render(<ConsentsNotifications />)
87+
88+
await act(() => {
8889
screen.getAllByTestId(/switch-option/).forEach(async (el) => {
8990
fireEvent.click(el)
9091
})

redisinsight/ui/src/components/consents-settings/ConsentsPrivacy/ConsentsPrivacy.spec.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
mockedStore,
88
cleanup,
99
clearStoreActions,
10-
waitFor,
10+
act,
1111
} from 'uiSrc/utils/test-utils'
1212
import { updateUserConfigSettings } from 'uiSrc/slices/user/user-settings'
1313
import ConsentsPrivacy from './ConsentsPrivacy'
@@ -83,8 +83,9 @@ describe('ConsentsPrivacy', () => {
8383

8484
describe('update settings', () => {
8585
it('option change should call "updateUserConfigSettingsAction"', async () => {
86-
await waitFor(() => {
87-
render(<ConsentsPrivacy />)
86+
render(<ConsentsPrivacy />)
87+
88+
await act(() => {
8889
screen.getAllByTestId(/switch-option/).forEach(async (el) => {
8990
fireEvent.click(el)
9091
})

redisinsight/ui/src/components/consents-settings/ConsentsSettings.spec.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
fireEvent,
77
mockedStore,
88
cleanup,
9-
clearStoreActions,
10-
act,
119
} from 'uiSrc/utils/test-utils'
1210
import ConsentsSettings from './ConsentsSettings'
1311

@@ -94,27 +92,4 @@ describe('ConsentsSettings', () => {
9492
})
9593
expect(screen.getByTestId(BTN_SUBMIT)).not.toBeDisabled()
9694
})
97-
describe('liveEditMode', () => {
98-
it('btn submit should not render', () => {
99-
const { queryByTestId } = render(<ConsentsSettings liveEditMode />)
100-
expect(queryByTestId(BTN_SUBMIT)).not.toBeInTheDocument()
101-
})
102-
103-
it('option change should call "updateUserConfigSettingsAction"', async () => {
104-
const { queryByTestId } = render(<ConsentsSettings liveEditMode />)
105-
106-
await act(() => {
107-
screen.getAllByTestId(/switch-option/).forEach(async (el) => {
108-
fireEvent.click(el)
109-
})
110-
})
111-
112-
const expectedActions = [{}].fill(updateUserConfigSettings(), 0)
113-
expect(clearStoreActions(store.getActions().slice(0, expectedActions.length))).toEqual(
114-
clearStoreActions(expectedActions)
115-
)
116-
117-
expect(queryByTestId(BTN_SUBMIT)).not.toBeInTheDocument()
118-
})
119-
})
12095
})

redisinsight/ui/src/components/consents-settings/ConsentsSettings.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import cx from 'classnames'
2121

2222
import { compareConsents } from 'uiSrc/utils'
2323
import { updateUserConfigSettingsAction, userSettingsSelector } from 'uiSrc/slices/user/user-settings'
24+
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
2425
import ConsentOption from './ConsentOption'
2526

2627
import styles from './styles.module.scss'
@@ -152,14 +153,14 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
152153
const checkIsRecommended = () => {
153154
let recommended = true
154155
forEach(privacyConsents, (consent) => {
155-
if (!formik.values[consent.agreementName]) {
156+
if (!formik.values[consent?.agreementName]) {
156157
recommended = false
157158
return false
158159
}
159160
})
160161

161162
forEach(notificationConsents, (consent) => {
162-
if (!formik.values[consent.agreementName]) {
163+
if (!formik.values[consent?.agreementName]) {
163164
recommended = false
164165
return false
165166
}
@@ -176,6 +177,14 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
176177
if (submitIsDisabled()) {
177178
return
178179
}
180+
// have only one switcher in notificationConsents
181+
if (notificationConsents.length) {
182+
sendEventTelemetry({
183+
event: values[notificationConsents[0]?.agreementName]
184+
? TelemetryEvent.SETTINGS_NOTIFICATION_MESSAGES_ENABLED
185+
: TelemetryEvent.SETTINGS_NOTIFICATION_MESSAGES_DISABLED,
186+
})
187+
}
179188
dispatch(updateUserConfigSettingsAction({ agreements: values }, onSubmitted))
180189
}
181190

@@ -222,7 +231,7 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
222231
<h1 className={styles.title}>Privacy Settings</h1>
223232
</EuiTitle>
224233
<EuiSpacer size="m" />
225-
<EuiText size="s" color="subdued">
234+
<EuiText className={styles.smallText} size="s" color="subdued">
226235
To optimize your experience, RedisInsight uses third-party tools.
227236
All data collected is anonymized and will not be used for any purpose without your consent.
228237
</EuiText>
@@ -261,7 +270,7 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
261270
))
262271
}
263272
</div>
264-
{!!requiredConsents.length && (
273+
{requiredConsents.length ? (
265274
<>
266275
<EuiHorizontalRule margin="l" className={styles.requiredHR} />
267276
<EuiSpacer size="m" />
@@ -277,18 +286,22 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
277286
</EuiText>
278287
<EuiSpacer size="m" />
279288
</>
289+
) : (
290+
<EuiSpacer size="l" />
280291
)}
281292

282-
{requiredConsents.map((consent: IConsent) => (
283-
<ConsentOption
284-
consent={consent}
285-
checked={formik.values[consent.agreementName] ?? false}
286-
onChangeAgreement={onChangeAgreement}
287-
key={consent.agreementName}
288-
/>
289-
))}
290-
{!requiredConsents.length && (<EuiSpacer size="l" />)}
291-
<EuiFlexGroup justifyContent="flexEnd" responsive={false}>
293+
<EuiFlexGroup alignItems="center" justifyContent="spaceBetween" responsive={false}>
294+
<EuiFlexItem grow={false}>
295+
{requiredConsents.map((consent: IConsent) => (
296+
<ConsentOption
297+
consent={consent}
298+
checked={formik.values[consent.agreementName] ?? false}
299+
onChangeAgreement={onChangeAgreement}
300+
withoutSpacer
301+
key={consent.agreementName}
302+
/>
303+
))}
304+
</EuiFlexItem>
292305
<EuiFlexItem grow={false}>
293306
<EuiToolTip
294307
position="top"

0 commit comments

Comments
 (0)