Skip to content

Commit e69a22e

Browse files
committed
Updated the UI & the API unit-test cases as per the new app.
1 parent f84709a commit e69a22e

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from "react";
2+
import { render, screen, cleanup, fireEvent } from "@testing-library/react";
3+
import ConfigPage from "./index";
4+
5+
const inputLabel = "Data format In Entry";
6+
7+
const UIElementsIDs = [
8+
"cs-form",
9+
"cs-field",
10+
"cs-field-label",
11+
"cs-tooltip",
12+
"cs-radio-one",
13+
"cs-radio-two",
14+
"cs-instruction-text",
15+
];
16+
17+
beforeEach(async () => {
18+
render(<ConfigPage />);
19+
});
20+
jest.spyOn(React, "useEffect").mockImplementation();
21+
22+
afterEach(cleanup);
23+
24+
describe(`UI Elements of Custom Field Screen`, () => {
25+
UIElementsIDs.forEach((id: string) => {
26+
test(`Rendered ${id} element`, async () => {
27+
expect(screen.getByTestId(`${id}`)).toBeInTheDocument();
28+
});
29+
});
30+
31+
test(`Text Label`, async () => {
32+
expect(screen.getByText(inputLabel)).toBeInTheDocument();
33+
});
34+
35+
test(`FireEvent Functionality`, async () => {
36+
const input = screen
37+
.getByTestId(`cs-radio-one`)
38+
.querySelector("input") as HTMLInputElement;
39+
fireEvent.change(input, { target: { value: "false" } });
40+
expect(input.value).toBe("false");
41+
});
42+
});

ui/src/containers/ConfigScreen/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@ const ConfigScreen: React.FC = function () {
108108
return (
109109
<div className="layout-container">
110110
<div className="page-wrapper">
111-
<form data-test-id="cs-form" className="config-wrapper">
111+
<form data-testid="cs-form" className="config-wrapper">
112112
<div className="Form__item">
113113
<div
114114
className="Field Field--full json-field"
115-
data-test-id="cs-field"
115+
data-testid="cs-field"
116116
>
117117
<label
118118
className="FieldLabel"
119119
htmlFor="isStringified"
120-
data-test-id="cs-field-label"
120+
data-testid="cs-field-label"
121121
>
122122
{localeTexts.configFields.entrySaveRadioButton.label}
123123
<span className="FieldLabel__required-text">
@@ -127,12 +127,12 @@ const ConfigScreen: React.FC = function () {
127127
<div
128128
className="tippy-wrapper"
129129
id="help-text"
130-
data-test-id="cs-tooltip"
130+
data-testid="cs-tooltip"
131131
>
132132
<VenusHelp />
133133
</div>
134134
<div className="Radio-wrapper">
135-
<label data-test-id="cs-radio" className="Radio label-text">
135+
<label data-testid="cs-radio-one" className="Radio label-text">
136136
<input
137137
id="jsonObject"
138138
type="radio"
@@ -147,7 +147,7 @@ const ConfigScreen: React.FC = function () {
147147
{localeTexts.configFields.entrySaveRadioButton.jsonObject}
148148
</span>
149149
</label>
150-
<label data-test-id="cs-radio" className="Radio label-text">
150+
<label data-testid="cs-radio-two" className="Radio label-text">
151151
<input
152152
id="stringified"
153153
type="radio"
@@ -166,7 +166,7 @@ const ConfigScreen: React.FC = function () {
166166
</span>
167167
</label>
168168
</div>
169-
<p className="InstructionText" data-test-id="cs-instruction-text">
169+
<p className="InstructionText" data-testid="cs-instruction-text">
170170
{localeTexts.configFields.entrySaveRadioButton.instruction}
171171
</p>
172172
</div>

0 commit comments

Comments
 (0)