Skip to content

Commit 42a3c1d

Browse files
Merge pull request #90 from RedisInsight/fix/testcafe-workbench-plugins
Fix/ TestCafe WB plugins
2 parents b4458ec + 7ca9de7 commit 42a3c1d

File tree

14 files changed

+1080
-25
lines changed

14 files changed

+1080
-25
lines changed

redisinsight/ui/src/components/query-card/QueryCardCliPlugin/QueryCardCliPlugin.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,32 @@ const QueryCardCliPlugin = (props: Props) => {
4747

4848
const dispatch = useDispatch()
4949

50+
const sendMessageToPlugin = (data = {}) => {
51+
const event: any = document.createEvent('Event')
52+
event.initEvent('message', false, false)
53+
event.data = data
54+
event.origin = '*'
55+
pluginIframeRef?.current?.contentWindow?.dispatchEvent(event)
56+
}
57+
5058
const executeCommand = () => {
51-
pluginIframeRef?.current?.contentWindow?.postMessage({
59+
sendMessageToPlugin({
5260
event: 'executeCommand',
5361
method: currentView.activationMethod,
5462
data: { command: query, data: result, status }
55-
}, '*')
63+
})
5664
}
5765

5866
const sendRedisCommand = (command: string, requestId: string) => {
5967
dispatch(
6068
sendPluginCommandAction({
6169
command,
6270
onSuccessAction: (response) => {
63-
pluginIframeRef?.current?.contentWindow?.postMessage({
71+
sendMessageToPlugin({
6472
event: 'executeRedisCommand',
6573
requestId,
6674
data: response
67-
}, '*')
75+
})
6876
}
6977
})
7078
)
@@ -108,7 +116,7 @@ const QueryCardCliPlugin = (props: Props) => {
108116
modules
109117
})
110118
// @ts-ignore
111-
pluginIframeRef.current.src = `data:text/html;charset=utf-8,${encodeURI(html)}`
119+
pluginIframeRef.current.srcdoc = html
112120
}
113121

114122
const getGlobalStylesSrc = (): string =>

redisinsight/ui/src/packages/redis-app-plugin-api/helpers.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@
44
* @param data
55
*/
66
export const sendMessageToMain = (data = {}) => {
7-
window.top.postMessage(data, '*')
7+
const event = document.createEvent('Event')
8+
event.initEvent('message', true, true)
9+
event.data = data
10+
event.origin = '*'
11+
// eslint-disable-next-line no-restricted-globals
12+
parent.dispatchEvent(event)
813
}
14+
// export const sendMessageToMain = (data = {}) => {
15+
// window.top.postMessage(data, '*')
16+
// }

redisinsight/ui/src/packages/redisearch/src/components/TableInfoResult/TableInfoResult.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ const TableInfoResult = React.memo((props: Props) => {
112112
<div className="content">
113113
{Header()}
114114
<EuiInMemoryTable
115-
pagination
116115
items={items ?? []}
117116
loading={!result}
118117
message={loadingMessage}

redisinsight/ui/src/packages/redisearch/src/icons/arrow_down.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ var EuiIconArrowDown = function EuiIconArrowDown(_ref) {
1111
titleId = _ref.titleId,
1212
props = _objectWithoutProperties(_ref, ["title", "titleId"]);
1313

14+
// For e2e tests. TestCafe is failing for default icons
15+
if(process.env.E2E) {
16+
return <span>&#8595;</span>
17+
}
1418
return /*#__PURE__*/React.createElement("svg", _extends({
1519
width: 16,
1620
height: 16,

redisinsight/ui/src/packages/redisearch/src/icons/arrow_left.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ var EuiIconArrowLeft = function EuiIconArrowLeft(_ref) {
1111
titleId = _ref.titleId,
1212
props = _objectWithoutProperties(_ref, ["title", "titleId"]);
1313

14+
// For e2e tests. TestCafe is failing for default icons
15+
if(process.env.E2E) {
16+
return <span>&#8592;</span>
17+
}
1418
return /*#__PURE__*/React.createElement("svg", _extends({
1519
width: 16,
1620
height: 16,

redisinsight/ui/src/packages/redisearch/src/icons/arrow_right.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const EuiIconArrowRight = function EuiIconArrowRight(_ref) {
1717
const { titleId } = _ref
1818
const props = _objectWithoutProperties(_ref, ['title', 'titleId'])
1919

20+
// For e2e tests. TestCafe is failing for default icons
21+
if(process.env.E2E) {
22+
return <span>&#8594;</span>
23+
}
2024
return /* #__PURE__ */React.createElement('svg', { width: 16,
2125
height: 16,
2226
viewBox: '0 0 16 16',

redisinsight/ui/src/packages/redisearch/src/icons/check.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ var EuiIconCheck = function EuiIconCheck(_ref) {
1111
titleId = _ref.titleId,
1212
props = _objectWithoutProperties(_ref, ["title", "titleId"]);
1313

14+
// For e2e tests. TestCafe is failing for default icons
15+
if(process.env.E2E) {
16+
return <span>&#10004;</span>
17+
}
1418
return /*#__PURE__*/React.createElement("svg", _extends({
1519
width: 16,
1620
height: 16,

redisinsight/ui/src/packages/redisearch/src/icons/copy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ var EuiIconCopy = function EuiIconCopy(_ref) {
1111
titleId = _ref.titleId,
1212
props = _objectWithoutProperties(_ref, ["title", "titleId"]);
1313

14+
// For e2e tests. TestCafe is failing for default icons
15+
if(process.env.E2E) {
16+
return <span>&#9751;</span>
17+
}
1418
return /*#__PURE__*/React.createElement("svg", _extends({
1519
width: 16,
1620
height: 16,

redisinsight/ui/src/packages/redisearch/src/icons/cross.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ var EuiIconCross = function EuiIconCross(_ref) {
1111
titleId = _ref.titleId,
1212
props = _objectWithoutProperties(_ref, ["title", "titleId"]);
1313

14+
// For e2e tests. TestCafe is failing for default icons
15+
if(process.env.E2E) {
16+
return <span>&#10539;</span>
17+
}
1418
return /*#__PURE__*/React.createElement("svg", _extends({
1519
width: 16,
1620
height: 16,

redisinsight/ui/src/packages/redisearch/src/icons/empty.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ var EuiIconEmpty = function EuiIconEmpty(_ref) {
1111
titleId = _ref.titleId,
1212
props = _objectWithoutProperties(_ref, ["title", "titleId"]);
1313

14+
// For e2e tests. TestCafe is failing for default icons
15+
if(process.env.E2E) {
16+
return <span>''</span>
17+
}
1418
return /*#__PURE__*/React.createElement("svg", _extends({
1519
width: 16,
1620
height: 16,

0 commit comments

Comments
 (0)