Skip to content

Commit

Permalink
Show required sign only if label is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
amitbadala committed Nov 15, 2023
1 parent b43bf9b commit 5bb924b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/build/emailpassword-shared7.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/ts/recipe/emailpassword/components/library/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function Label({ value, showIsRequired }: LabelProps): JSX.Elemen
return (
<div data-supertokens="label">
{t(value)}
{showIsRequired && " *"}
{showIsRequired && value !== "" && " *"}
</div>
);
}
6 changes: 6 additions & 0 deletions test/end-to-end/signup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ describe("SuperTokens SignUp", function () {
// check if checbox is loaded
const checkboxExists = await waitForSTElement(page, 'input[type="checkbox"]');
assert.ok(checkboxExists, "Checkbox exists");

// check if labels are loaded correctly
// non-optional field with empty labels should'nt show * sign
const expectedLabels = ["Email *", "Password *", "Select Dropdown", ""];
const labelNames = await getLabelsText(page);
assert.deepStrictEqual(labelNames, expectedLabels);
});

it("Should show error messages, based on optional flag", async function () {
Expand Down
7 changes: 7 additions & 0 deletions test/end-to-end/thirdpartyemailpassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
backendBeforeEach,
setSelectDropdownValue,
getInputField,
getLabelsText,
} from "../helpers";
import {
TEST_CLIENT_BASE_URL,
Expand Down Expand Up @@ -531,6 +532,12 @@ describe("SuperTokens Third Party Email Password", function () {
// check if checbox is loaded
const checkboxExists = await waitForSTElement(page, 'input[type="checkbox"]');
assert.ok(checkboxExists, "Checkbox exists");

// check if labels are loaded correctly
// non-optional field with empty labels should'nt show * sign
const expectedLabels = ["Email *", "Password *", "Select Dropdown", ""];
const labelNames = await getLabelsText(page);
assert.deepStrictEqual(labelNames, expectedLabels);
});

it("Should show error messages, based on optional flag", async function () {
Expand Down

0 comments on commit 5bb924b

Please sign in to comment.