This is an automated email from the ASF dual-hosted git repository.
tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new ec84b2d24e7 kie-issues#1161: Add end-to-end tests for Conditional
Expression on the Boxed Expression Component (#2336)
ec84b2d24e7 is described below
commit ec84b2d24e74b2be01ea79363ccb305a37d147ad
Author: Jozef Marko <[email protected]>
AuthorDate: Thu Aug 8 21:26:22 2024 +0200
kie-issues#1161: Add end-to-end tests for Conditional Expression on the
Boxed Expression Component (#2336)
---
.../ConditionalExpression.tsx | 2 +-
.../LiteralExpression/LiteralExpression.tsx | 2 +-
.../stories/boxedExpressions/BoxedExpressions.mdx | 1 +
.../boxedExpressions/Conditional/Conditional.mdx | 25 +++
.../Conditional/Conditional.stories.tsx | 181 +++++++++++++++++++++
.../tests-e2e/__fixtures__/stories.ts | 4 +
.../conditional/boxed-conditional--reset-state.png | Bin 0 -> 2683 bytes
...oxed-conditional-copy-and-paste-recursively.png | Bin 0 -> 11436 bytes
.../conditional/boxed-conditional-monthly-fee.png | Bin 0 -> 18102 bytes
...d-conditional-with-nested-other-expressions.png | Bin 0 -> 40222 bytes
.../nested-boxed-conditional--reset-state.png | Bin 0 -> 14659 bytes
.../conditional/nested-boxed-conditional.png | Bin 0 -> 18576 bytes
.../boxed-conditionald-resized-using-else.png | Bin 0 -> 13138 bytes
.../boxed-conditionald-resized-using-if.png | Bin 0 -> 13009 bytes
.../boxed-conditionald-resized-using-root.png | Bin 0 -> 8362 bytes
.../boxed-conditionald-resized-using-then.png | Bin 0 -> 13135 bytes
.../conditional/boxed-conditional--reset-state.png | Bin 0 -> 2433 bytes
...oxed-conditional-copy-and-paste-recursively.png | Bin 0 -> 10310 bytes
.../conditional/boxed-conditional-monthly-fee.png | Bin 0 -> 16343 bytes
...d-conditional-with-nested-other-expressions.png | Bin 0 -> 36134 bytes
.../nested-boxed-conditional--reset-state.png | Bin 0 -> 13246 bytes
.../conditional/nested-boxed-conditional.png | Bin 0 -> 16676 bytes
.../boxed-conditionald-resized-using-else.png | Bin 0 -> 11775 bytes
.../boxed-conditionald-resized-using-if.png | Bin 0 -> 11668 bytes
.../boxed-conditionald-resized-using-root.png | Bin 0 -> 7508 bytes
.../boxed-conditionald-resized-using-then.png | Bin 0 -> 11786 bytes
.../conditional/boxed-conditional--reset-state.png | Bin 0 -> 2240 bytes
.../conditional/boxed-conditional-monthly-fee.png | Bin 0 -> 15395 bytes
...d-conditional-with-nested-other-expressions.png | Bin 0 -> 31977 bytes
.../nested-boxed-conditional--reset-state.png | Bin 0 -> 11655 bytes
.../conditional/nested-boxed-conditional.png | Bin 0 -> 14757 bytes
.../boxed-conditionald-resized-using-else.png | Bin 0 -> 10050 bytes
.../boxed-conditionald-resized-using-if.png | Bin 0 -> 10089 bytes
.../boxed-conditionald-resized-using-root.png | Bin 0 -> 6747 bytes
.../boxed-conditionald-resized-using-then.png | Bin 0 -> 10066 bytes
.../api/expressions/literalExpressionElement.ts | 6 +-
.../boxedExpressions/conditional/populate.spec.ts | 167 +++++++++++++++++++
.../tests-e2e/features/resizing/resizing.spec.ts | 68 ++++++++
.../tests/__mocks__/monacoMock.js | 66 --------
.../tests/__mocks__/styleMocks.js | 20 ---
.../tests/keysUtils/NavigationKeysUtils.test.ts | 168 -------------------
41 files changed, 453 insertions(+), 257 deletions(-)
diff --git
a/packages/boxed-expression-component/src/expressions/ConditionalExpression/ConditionalExpression.tsx
b/packages/boxed-expression-component/src/expressions/ConditionalExpression/ConditionalExpression.tsx
index b0c678ad55e..948e4d836d1 100644
---
a/packages/boxed-expression-component/src/expressions/ConditionalExpression/ConditionalExpression.tsx
+++
b/packages/boxed-expression-component/src/expressions/ConditionalExpression/ConditionalExpression.tsx
@@ -228,7 +228,7 @@ export function ConditionalExpression({
return (
<NestedExpressionContainerContext.Provider
value={nestedExpressionContainerValue}>
- <div>
+ <div data-testid={"kie-tools--boxed-expression-component---conditional"}>
<BeeTable<ROWTYPE>
resizerStopBehavior={ResizerStopBehavior.SET_WIDTH_WHEN_SMALLER}
tableId={id}
diff --git
a/packages/boxed-expression-component/src/expressions/LiteralExpression/LiteralExpression.tsx
b/packages/boxed-expression-component/src/expressions/LiteralExpression/LiteralExpression.tsx
index e807a58b21d..06114f95e7e 100644
---
a/packages/boxed-expression-component/src/expressions/LiteralExpression/LiteralExpression.tsx
+++
b/packages/boxed-expression-component/src/expressions/LiteralExpression/LiteralExpression.tsx
@@ -212,7 +212,7 @@ export function LiteralExpression({
return (
<div className={`literal-expression`}
data-testid={`kie-tools--bee--literal-expression-${id}`}>
<div className={"literal-expression-body-container"}>
- <div className={"equals-sign"}>{`=`}</div>
+ <div className={"equals-sign"}
data-testid={"kie-tools--equals-sign"}>{`=`}</div>
<BeeTable<ROWTYPE>
resizerStopBehavior={ResizerStopBehavior.SET_WIDTH_WHEN_SMALLER}
forwardRef={beeTableRef}
diff --git
a/packages/boxed-expression-component/stories/boxedExpressions/BoxedExpressions.mdx
b/packages/boxed-expression-component/stories/boxedExpressions/BoxedExpressions.mdx
index 113520fc2b9..cdcc417b620 100644
---
a/packages/boxed-expression-component/stories/boxedExpressions/BoxedExpressions.mdx
+++
b/packages/boxed-expression-component/stories/boxedExpressions/BoxedExpressions.mdx
@@ -38,6 +38,7 @@ Currently, the following boxed expressions are supported:
- [List](/docs/boxed-expressions-list--overview)
- [Literal](/docs/boxed-expressions-literal--overview)
- [Relation](/docs/boxed-expressions-relation--overview)
+- [Conditional](/docs/boxed-expressions-conditional--overview)
- [Filter](/docs/boxed-expressions-filter--overview)
- [Every](/docs/boxed-expressions-every--overview)
- [For](/docs/boxed-expressions-for--overview)
diff --git
a/packages/boxed-expression-component/stories/boxedExpressions/Conditional/Conditional.mdx
b/packages/boxed-expression-component/stories/boxedExpressions/Conditional/Conditional.mdx
new file mode 100644
index 00000000000..4d3a7e41440
--- /dev/null
+++
b/packages/boxed-expression-component/stories/boxedExpressions/Conditional/Conditional.mdx
@@ -0,0 +1,25 @@
+{/* Licensed to the Apache Software Foundation (ASF) under one */}
+{/* or more contributor license agreements. See the NOTICE file */}
+{/* distributed with this work for additional information */}
+{/* regarding copyright ownership. The ASF licenses this file */}
+{/* to you under the Apache License, Version 2.0 (the */}
+{/* "License"); you may not use this file except in compliance */}
+{/* with the License. You may obtain a copy of the License at */}
+{/* */}
+{/* http://www.apache.org/licenses/LICENSE-2.0 */}
+{/* */}
+{/* Unless required by applicable law or agreed to in writing, */}
+{/* software distributed under the License is distributed on an */}
+{/* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY */}
+{/* KIND, either express or implied. See the License for the */}
+{/* specific language governing permissions and limitations */}
+{/* under the License. */}
+
+import { Meta, Story, Canvas, Subtitle } from "@storybook/blocks";
+import * as Conditional from "./Conditional.stories";
+
+<Meta title="MDX/Conditional" of={Conditional} />
+
+# Boxed Conditional Expression
+
+The Boxed Conditional expression was implemented as an alternative way of
defining FEEL expressions `if [condition satisfied] then [something] else
[something else]`
diff --git
a/packages/boxed-expression-component/stories/boxedExpressions/Conditional/Conditional.stories.tsx
b/packages/boxed-expression-component/stories/boxedExpressions/Conditional/Conditional.stories.tsx
new file mode 100644
index 00000000000..c7d4b94294e
--- /dev/null
+++
b/packages/boxed-expression-component/stories/boxedExpressions/Conditional/Conditional.stories.tsx
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Meta, StoryObj } from "@storybook/react";
+import { BoxedExpressionEditor, BoxedExpressionEditorProps } from
"../../../src/BoxedExpressionEditor";
+import { BoxedExpressionEditorStory, BoxedExpressionEditorStoryArgs } from
"../../boxedExpressionStoriesWrapper";
+import { generateUuid } from "../../../src/api";
+import { Base as EmptyExpression } from
"../../misc/Empty/EmptyExpression.stories";
+
+// More on how to set up stories at:
https://storybook.js.org/docs/react/writing-stories/introduction#default-export
+const meta: Meta<BoxedExpressionEditorProps> = {
+ title: "Boxed Expressions/Conditional",
+ component: BoxedExpressionEditor,
+ includeStories: /^[A-Z]/,
+};
+
+export default meta;
+type Story = StoryObj<BoxedExpressionEditorStoryArgs>;
+
+// More on writing stories with args:
https://storybook.js.org/docs/react/writing-stories/args
+export const Base: Story = {
+ render: (args) => BoxedExpressionEditorStory(),
+ parameters: { exclude: ["dataTypes", "beeGwtService", "pmmlDocuments"] },
+ args: {
+ ...EmptyExpression.args,
+ expression: {
+ __$$element: "conditional",
+ "@_id": generateUuid(),
+ "@_label": "Expression Name",
+ if: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ },
+ },
+ then: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ },
+ },
+ else: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ },
+ },
+ },
+ },
+};
+
+export const MonthlyFee: Story = {
+ render: (args) => BoxedExpressionEditorStory(),
+ parameters: { exclude: ["dataTypes", "beeGwtService", "pmmlDocuments"] },
+ args: {
+ ...EmptyExpression.args,
+ expression: {
+ __$$element: "conditional",
+ "@_id": "_D98FB35A-C6A5-4BA7-AD38-176D56A31983",
+ "@_label": "MonthlyFee",
+ "@_typeRef": "number",
+ if: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ text: { __$$text: 'ProductType = "STANDARD LOAN"' },
+ },
+ },
+ then: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ text: { __$$text: "20" },
+ },
+ },
+ else: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "conditional",
+ "@_id": generateUuid(),
+ if: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": "_D98FB35A-C6A5-4BA7-AD38-176D56A31983",
+ text: { __$$text: 'ProductType = "SPECIAL OFFERING"' },
+ },
+ },
+ then: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ text: { __$$text: "25" },
+ },
+ },
+ else: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ text: { __$$text: "null" },
+ },
+ },
+ },
+ },
+ },
+ widthsById: {
+ "_D98FB35A-C6A5-4BA7-AD38-176D56A31983": [300],
+ },
+ },
+};
+
+export const Nested: Story = {
+ render: (args) => BoxedExpressionEditorStory(),
+ parameters: { exclude: ["dataTypes", "beeGwtService", "pmmlDocuments"] },
+ args: {
+ ...EmptyExpression.args,
+ expression: {
+ __$$element: "context",
+ "@_id": generateUuid(),
+ "@_label": "Expression Name",
+ contextEntry: [
+ {
+ "@_id": generateUuid(),
+ variable: {
+ "@_id": generateUuid(),
+ "@_name": "ContextEntry-1",
+ },
+ expression: {
+ __$$element: "conditional",
+ "@_id": generateUuid(),
+ "@_label": "Expression Name",
+ if: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ },
+ },
+ then: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ },
+ },
+ else: {
+ "@_id": generateUuid(),
+ expression: {
+ __$$element: "literalExpression",
+ "@_id": generateUuid(),
+ },
+ },
+ },
+ },
+ ],
+ },
+ },
+};
diff --git
a/packages/boxed-expression-component/tests-e2e/__fixtures__/stories.ts
b/packages/boxed-expression-component/tests-e2e/__fixtures__/stories.ts
index b8219799152..ffc94be0906 100644
--- a/packages/boxed-expression-component/tests-e2e/__fixtures__/stories.ts
+++ b/packages/boxed-expression-component/tests-e2e/__fixtures__/stories.ts
@@ -66,6 +66,10 @@ export class Stories {
await
this.page.goto(`${this.baseURL}/${this.getIframeURL(`boxed-expressions-filter--${type}`)}`
?? "");
}
+ public async openBoxedConditional(type: BoxedExpressionTypes = "base") {
+ await
this.page.goto(`${this.baseURL}/${this.getIframeURL(`boxed-expressions-conditional--${type}`)}`
?? "");
+ }
+
public async openBoxedEvery(type: BoxedExpressionTypes = "base") {
await
this.page.goto(`${this.baseURL}/${this.getIframeURL(`boxed-expressions-every--${type}`)}`
?? "");
}
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional--reset-state.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional--reset-state.png
new file mode 100644
index 00000000000..f44c5cba2c9
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional--reset-state.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-copy-and-paste-recursively.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-copy-and-paste-recursively.png
new file mode 100644
index 00000000000..6bd847a9a48
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-copy-and-paste-recursively.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
new file mode 100644
index 00000000000..386d6ec164d
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
new file mode 100644
index 00000000000..13d3414cdf5
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
new file mode 100644
index 00000000000..45dbeb75840
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/nested-boxed-conditional.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/nested-boxed-conditional.png
new file mode 100644
index 00000000000..9a7177e73fb
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/boxedExpressions/conditional/nested-boxed-conditional.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-else.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-else.png
new file mode 100644
index 00000000000..38cb57b29dd
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-else.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-if.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-if.png
new file mode 100644
index 00000000000..1709529fd6e
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-if.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-root.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-root.png
new file mode 100644
index 00000000000..7370f195731
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-root.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-then.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-then.png
new file mode 100644
index 00000000000..8f29758822e
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/Google-Chrome/features/resizing/boxed-conditionald-resized-using-then.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional--reset-state.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional--reset-state.png
new file mode 100644
index 00000000000..7bde9eb7624
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional--reset-state.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-copy-and-paste-recursively.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-copy-and-paste-recursively.png
new file mode 100644
index 00000000000..13013a99c4c
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-copy-and-paste-recursively.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
new file mode 100644
index 00000000000..c7ddc016eb9
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
new file mode 100644
index 00000000000..7192f369de9
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
new file mode 100644
index 00000000000..30ce064cdce
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/nested-boxed-conditional.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/nested-boxed-conditional.png
new file mode 100644
index 00000000000..b51cdfc3f50
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/boxedExpressions/conditional/nested-boxed-conditional.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-else.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-else.png
new file mode 100644
index 00000000000..80be3408ba7
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-else.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-if.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-if.png
new file mode 100644
index 00000000000..44b3452127b
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-if.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-root.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-root.png
new file mode 100644
index 00000000000..0207f0f7bce
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-root.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-then.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-then.png
new file mode 100644
index 00000000000..0d0f642c594
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/chromium/features/resizing/boxed-conditionald-resized-using-then.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional--reset-state.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional--reset-state.png
new file mode 100644
index 00000000000..60341110829
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional--reset-state.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
new file mode 100644
index 00000000000..181a4cdda76
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional-monthly-fee.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
new file mode 100644
index 00000000000..6598af722c9
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/boxed-conditional-with-nested-other-expressions.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
new file mode 100644
index 00000000000..7253c2a2c5e
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/nested-boxed-conditional--reset-state.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/nested-boxed-conditional.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/nested-boxed-conditional.png
new file mode 100644
index 00000000000..12afac56898
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/boxedExpressions/conditional/nested-boxed-conditional.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-else.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-else.png
new file mode 100644
index 00000000000..4ed1291557f
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-else.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-if.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-if.png
new file mode 100644
index 00000000000..5f126677cbf
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-if.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-root.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-root.png
new file mode 100644
index 00000000000..e8cae2a2c8a
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-root.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-then.png
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-then.png
new file mode 100644
index 00000000000..ced31850116
Binary files /dev/null and
b/packages/boxed-expression-component/tests-e2e/__screenshots__/webkit/features/resizing/boxed-conditionald-resized-using-then.png
differ
diff --git
a/packages/boxed-expression-component/tests-e2e/api/expressions/literalExpressionElement.ts
b/packages/boxed-expression-component/tests-e2e/api/expressions/literalExpressionElement.ts
index 2429c5c6e7e..58be5f3ae21 100644
---
a/packages/boxed-expression-component/tests-e2e/api/expressions/literalExpressionElement.ts
+++
b/packages/boxed-expression-component/tests-e2e/api/expressions/literalExpressionElement.ts
@@ -20,7 +20,7 @@
import { Locator, Page } from "@playwright/test";
import { Monaco } from "../../__fixtures__/monaco";
import { NameAndDataTypeCell } from "../nameAndDataTypeCell";
-import { ExpressionCell } from "../expressionContainer";
+import { ContextMenu, ExpressionCell } from "../expressionContainer";
export class LiteralExpressionElement {
constructor(
@@ -40,6 +40,10 @@ export class LiteralExpressionElement {
return new ExpressionCell(this.locator.getByRole("cell").nth(0),
this.monaco);
}
+ get equalsSignContextMenu() {
+ return new ContextMenu(this.locator.getByTestId("kie-tools--equals-sign"));
+ }
+
get expressionHeaderCell() {
return new NameAndDataTypeCell(this.locator.getByRole("columnheader"));
}
diff --git
a/packages/boxed-expression-component/tests-e2e/boxedExpressions/conditional/populate.spec.ts
b/packages/boxed-expression-component/tests-e2e/boxedExpressions/conditional/populate.spec.ts
new file mode 100644
index 00000000000..0ff8889de66
--- /dev/null
+++
b/packages/boxed-expression-component/tests-e2e/boxedExpressions/conditional/populate.spec.ts
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import _ from "lodash";
+import { test, expect } from "../../__fixtures__/base";
+
+test.describe("Populate Boxed Conditional", () => {
+ test("should rename a Conditional", async ({ bee, stories }) => {
+ await stories.openBoxedConditional();
+
+ await bee.expression.asConditional().expressionHeaderCell.open();
+ await bee.expression
+ .asConditional()
+ .expressionHeaderCell.setName({ name: "Conditional Expression Name",
close: true });
+
+ expect(await
bee.expression.asConditional().expressionHeaderCell.content.textContent()).toEqual(
+ "Conditional Expression Name(<Undefined>)"
+ );
+ });
+
+ test("should change a Conditional data type", async ({ bee, stories }) => {
+ await stories.openBoxedConditional();
+
+ await bee.expression.asConditional().expressionHeaderCell.open();
+ await bee.expression.asConditional().expressionHeaderCell.setDataType({
dataType: "boolean", close: true });
+
+ expect(await
bee.expression.asConditional().expressionHeaderCell.content.textContent()).toEqual(
+ "Expression Name(boolean)"
+ );
+ });
+
+ test("should create the Monthly Fee Conditional", async ({ bee, stories })
=> {
+ await stories.openBoxedConditional();
+
+ // HEADER
+ await bee.expression.asConditional().expressionHeaderCell.open();
+ await bee.expression.asConditional().expressionHeaderCell.setName({ name:
"MonthlyFee", close: false });
+ await bee.expression.asConditional().expressionHeaderCell.setDataType({
dataType: "number", close: true });
+
+ // IF
+ await
bee.expression.asConditional().if.expression.asLiteral().fill('ProdctType =
"STANDARD LOAN"');
+
+ // THEN
+ await
bee.expression.asConditional().then.expression.asLiteral().fill("20");
+
+ // ELSE
+ await
bee.expression.asConditional().else.expression.asLiteral().equalsSignContextMenu.open();
+ await bee.expression
+ .asConditional()
+ .else.expression.asLiteral()
+ .equalsSignContextMenu.option("Reset")
+ .nth(0)
+ .click();
+ await
bee.expression.asConditional().else.selectExpressionMenu.selectConditional();
+ await
bee.expression.asConditional().else.expression.asConditional().if.selectExpressionMenu.selectLiteral();
+ await bee.expression
+ .asConditional()
+ .else.expression.asConditional()
+ .if.expression.asLiteral()
+ .fill('ProdctType = "SPECIAL OFFERING"');
+ await
bee.expression.asConditional().else.expression.asConditional().then.selectExpressionMenu.selectLiteral();
+ await
bee.expression.asConditional().else.expression.asConditional().then.expression.asLiteral().fill("25");
+ await
bee.expression.asConditional().else.expression.asConditional().else.selectExpressionMenu.selectLiteral();
+ await
bee.expression.asConditional().else.expression.asConditional().else.expression.asLiteral().fill("null");
+
+ await
expect(bee.getContainer()).toHaveScreenshot("boxed-conditional-monthly-fee.png");
+ });
+
+ test("should create a nested Conditional", async ({ bee, stories }) => {
+ await stories.openBoxedConditional();
+
+ await bee.expression.header.reset();
+ await bee.selectExpressionMenu.selectContext();
+ await
bee.expression.asContext().entry(0).selectExpressionMenu.selectConditional();
+
+ await
bee.expression.asContext().entry(0).expression.asConditional().if.selectExpressionMenu.selectLiteral();
+ await
bee.expression.asContext().entry(0).expression.asConditional().if.expression.asLiteral().fill("1
> 0");
+
+ await
bee.expression.asContext().entry(0).expression.asConditional().then.selectExpressionMenu.selectLiteral();
+ await
bee.expression.asContext().entry(0).expression.asConditional().then.expression.asLiteral().fill("always");
+
+ await
bee.expression.asContext().entry(0).expression.asConditional().else.selectExpressionMenu.selectLiteral();
+ await
bee.expression.asContext().entry(0).expression.asConditional().else.expression.asLiteral().fill("never");
+
+ await
expect(bee.getContainer()).toHaveScreenshot("nested-boxed-conditional.png");
+ });
+
+ test("should combine other expressions with the Conditional", async ({ bee,
stories }) => {
+ await stories.openBoxedConditional();
+
+ await
bee.expression.asConditional().if.expression.asLiteral().equalsSignContextMenu.open();
+ await
bee.expression.asConditional().if.expression.asLiteral().equalsSignContextMenu.option("Reset").nth(0).click();
+ await
bee.expression.asConditional().if.selectExpressionMenu.selectContext();
+
+ await
bee.expression.asConditional().then.expression.asLiteral().equalsSignContextMenu.open();
+ await bee.expression
+ .asConditional()
+ .then.expression.asLiteral()
+ .equalsSignContextMenu.option("Reset")
+ .nth(0)
+ .click();
+ await
bee.expression.asConditional().then.selectExpressionMenu.selectDecisionTable();
+
+ await
bee.expression.asConditional().else.expression.asLiteral().equalsSignContextMenu.open();
+ await bee.expression
+ .asConditional()
+ .else.expression.asLiteral()
+ .equalsSignContextMenu.option("Reset")
+ .nth(0)
+ .click();
+ await
bee.expression.asConditional().else.selectExpressionMenu.selectSome();
+
+ await
expect(bee.getContainer()).toHaveScreenshot("boxed-conditional-with-nested-other-expressions.png");
+ });
+
+ test("should reset a Conditional", async ({ bee, stories }) => {
+ await stories.openBoxedConditional();
+
+ await bee.expression.header.reset();
+
+ await
expect(bee.getContainer()).toHaveScreenshot("boxed-conditional--reset-state.png");
+ });
+
+ test("should reset a nested Conditional", async ({ bee, stories }) => {
+ await stories.openBoxedConditional("nested");
+
+ await bee.expression.asContext().entry(0).expression.header.reset();
+
+ await
expect(bee.getContainer()).toHaveScreenshot("nested-boxed-conditional--reset-state.png");
+ });
+
+ test("should copy and paste Conditional", async ({ bee, browserName,
context, stories }) => {
+ test.skip(
+ browserName === "webkit",
+ "Playwright Webkit doesn't support clipboard permissions:
https://github.com/microsoft/playwright/issues/13037"
+ );
+
+ await context.grantPermissions(["clipboard-read", "clipboard-write"]);
+
+ await stories.openBoxedConditional();
+
+ // Copy the root of the expression
+ await bee.expression.header.copy();
+
+ // Paste it recursively as 'if' expression
+ await
bee.expression.asConditional().if.expression.asLiteral().equalsSignContextMenu.open();
+ await
bee.expression.asConditional().if.expression.asLiteral().equalsSignContextMenu.option("Paste").nth(0).click();
+
+ await
expect(bee.getContainer()).toHaveScreenshot("boxed-conditional-copy-and-paste-recursively.png");
+ });
+});
diff --git
a/packages/boxed-expression-component/tests-e2e/features/resizing/resizing.spec.ts
b/packages/boxed-expression-component/tests-e2e/features/resizing/resizing.spec.ts
index c46a5ef64ea..78fa3a32f94 100644
---
a/packages/boxed-expression-component/tests-e2e/features/resizing/resizing.spec.ts
+++
b/packages/boxed-expression-component/tests-e2e/features/resizing/resizing.spec.ts
@@ -1009,4 +1009,72 @@ test.describe("Resizing", () => {
await
expect(bee.getContainer()).toHaveScreenshot("boxed-filter-nested-resized-using-match.png");
});
});
+
+ test.describe("Conditional expression", async () => {
+ test("should resize a Conditional", async ({ bee, resizing, stories }) => {
+ await stories.openBoxedConditional();
+
+ await resizing.resizeCell(
+ bee.expression.asConditional().expressionHeaderCell.content,
+ { x: 0, y: 0 },
+ { x: 250, y: 0 }
+ );
+
+ await
expect(bee.getContainer()).toHaveScreenshot("boxed-conditionald-resized-using-root.png");
+ });
+
+ test("should resize a Conditional - if", async ({ bee, monaco, page,
resizing, stories }) => {
+ await stories.openBoxedConditional();
+
+ await monaco.fill({
+ monacoParentLocator: page,
+ nth: 0,
+ content: "some pretty long text that will not fit the 'if' box",
+ });
+
+ await resizing.resizeCell(
+ bee.expression.asConditional().if.expression.asLiteral().content,
+ { x: 0, y: 0 },
+ { x: 250, y: 0 }
+ );
+
+ await
expect(bee.getContainer()).toHaveScreenshot("boxed-conditionald-resized-using-if.png");
+ });
+
+ test("should resize a Conditional - then", async ({ bee, monaco, page,
resizing, stories }) => {
+ await stories.openBoxedConditional();
+
+ await monaco.fill({
+ monacoParentLocator: page,
+ nth: 1,
+ content: "some pretty long text that will not fit the 'then' box",
+ });
+
+ await resizing.resizeCell(
+ bee.expression.asConditional().then.expression.asLiteral().content,
+ { x: 0, y: 0 },
+ { x: 250, y: 0 }
+ );
+
+ await
expect(bee.getContainer()).toHaveScreenshot("boxed-conditionald-resized-using-then.png");
+ });
+
+ test("should resize a Conditional - else", async ({ bee, monaco, page,
resizing, stories }) => {
+ await stories.openBoxedConditional();
+
+ await monaco.fill({
+ monacoParentLocator: page,
+ nth: 2,
+ content: "some pretty long text that will not fit the 'else' box",
+ });
+
+ await resizing.resizeCell(
+ bee.expression.asConditional().else.expression.asLiteral().content,
+ { x: 0, y: 0 },
+ { x: 250, y: 0 }
+ );
+
+ await
expect(bee.getContainer()).toHaveScreenshot("boxed-conditionald-resized-using-else.png");
+ });
+ });
});
diff --git a/packages/boxed-expression-component/tests/__mocks__/monacoMock.js
b/packages/boxed-expression-component/tests/__mocks__/monacoMock.js
deleted file mode 100644
index a1fa4fbe465..00000000000
--- a/packages/boxed-expression-component/tests/__mocks__/monacoMock.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-const languages = [];
-let value = "new value";
-let onDidBlurEditorText;
-
-module.exports = {
- languages: {
- registeredLanguages: [],
- register: (language) => {
- languages.push(language);
- },
- getLanguages: () => {
- return languages;
- },
- setMonarchTokensProvider: (_name, _tokens) => {},
- registerCompletionItemProvider: (_name, _provider) => {},
- CompletionItemKind: {
- Keyword: "Keyword",
- Function: "Function",
- },
- CompletionItemInsertTextRule: {
- InsertAsSnippet: "InsertAsSnippet",
- },
- },
- editor: {
- defineTheme: (_name, _theme) => {},
- colorize: () => ({
- then: (fn) => fn(),
- }),
- create: (element, _config) => {
- element.innerHTML = "<monaco-editor-mock />";
- return {
- dispose: () => {},
- getValue: () => value,
- setValue: (newValue) => {
- if (newValue.includes("</>")) {
- onDidBlurEditorText(newValue);
- }
- },
- setPosition: (_v) => {},
- focus: () => {},
- onDidChangeModelContent: () => {},
- onDidBlurEditorText: (fn) => (onDidBlurEditorText = fn),
- onKeyDown: () => {},
- };
- },
- },
-};
diff --git a/packages/boxed-expression-component/tests/__mocks__/styleMocks.js
b/packages/boxed-expression-component/tests/__mocks__/styleMocks.js
deleted file mode 100644
index 4bd939113b0..00000000000
--- a/packages/boxed-expression-component/tests/__mocks__/styleMocks.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-module.exports = {};
diff --git
a/packages/boxed-expression-component/tests/keysUtils/NavigationKeysUtils.test.ts
b/packages/boxed-expression-component/tests/keysUtils/NavigationKeysUtils.test.ts
deleted file mode 100644
index 5026ecb1f8c..00000000000
---
a/packages/boxed-expression-component/tests/keysUtils/NavigationKeysUtils.test.ts
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { NavigationKeysUtils } from
"@kie-tools/boxed-expression-component/dist/keysUtils/keyUtils";
-
-const notAKey = "NotAKey";
-const testDescription = "With input key: '%s', should return '%s'";
-
-describe("NavigationKeysUtils", () => {
- describe("isEscape", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["escapex", false],
- ["escape", true],
- ["Escape", true],
- ["ESCAPE", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isEsc(key!)).toBe(expected);
- });
- });
-
- describe("isAltGraph", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["altgraphx", false],
- ["altgraph", true],
- ["AltGraph", true],
- ["ALTGRAPH", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isAltGraph(key!)).toBe(expected);
- });
- });
-
- describe("isArrowDown", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["arrowdownx", false],
- ["arrowdown", true],
- ["ArrowDown", true],
- ["ARROWDOWN", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isArrowDown(key!)).toBe(expected);
- });
- });
-
- describe("isArrowLeft", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["arrowleftx", false],
- ["arrowleft", true],
- ["ArrowLeft", true],
- ["ARROWLEFT", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isArrowLeft(key!)).toBe(expected);
- });
- });
-
- describe("isArrowRight", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["arrowrightx", false],
- ["arrowright", true],
- ["ArrowRight", true],
- ["ARROWRIGHT", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isArrowRight(key!)).toBe(expected);
- });
- });
-
- describe("isArrowUp", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["arrowupx", false],
- ["arrowup", true],
- ["ArrowUp", true],
- ["ARROWUP", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isArrowUp(key!)).toBe(expected);
- });
- });
-
- describe("isAnyArrow", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["enter", false],
- ["arrowupx", false],
- ["arrowup", true],
- ["arrowleft", true],
- ["ArrowUp", true],
- ["ARROWRIGHT", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isAnyArrow(key!)).toBe(expected);
- });
- });
-
- describe("isEnter", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["enterx", false],
- ["enter", true],
- ["Enter", true],
- ["ENTER", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isEnter(key!)).toBe(expected);
- });
- });
-
- describe("isTab", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["tabx", false],
- ["tab", true],
- ["Tab", true],
- ["TAB", true],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isTab(key!)).toBe(expected);
- });
- });
-
- describe("isFX", () => {
- test.each([
- [undefined, false],
- ["", false],
- [notAKey, false],
- ["F1x", false],
- ["f1", true],
- ["F1", true],
- ["F12", true],
- ["F120", false],
- ])(testDescription, (key, expected) => {
- expect(NavigationKeysUtils.isFunctionKey(key!)).toBe(expected);
- });
- });
-});
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]