Skip to content

Commit c8a9601

Browse files
neotobneotrow
andauthored
move declarations into type file (#133)
Co-authored-by: Timothy Trowbridge <92933708+neotrow@users.noreply.github.com>
1 parent 8113cc0 commit c8a9601

14 files changed

Lines changed: 56 additions & 56 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- move cypress declarations into type file
13+
1014
## [3.9.0] - 2025-07-31
1115

1216
### Added

cypress/cypress/component/ClassName/ClassName.cy.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Form, Input, DatePickerInput, AsyncTypeaheadInput, StaticTypeaheadInput, FormattedInput } from "react-hook-form-components";
22
import { faker } from "@faker-js/faker";
33
import { fetchMock, generateOptions } from "../../helpers/typeahead";
4+
import { mount } from "cypress/react18";
45

56
it("input has correct classname", () => {
67
const name = faker.random.alpha(10);
78
const value = faker.random.alpha(10);
89

9-
cy.mount(
10+
mount(
1011
<Form
1112
onSubmit={() => {
1213
// Do nothing
@@ -21,7 +22,7 @@ it("input has correct classname", () => {
2122
it("datepicker input has correct classname", () => {
2223
const name = faker.random.word();
2324

24-
cy.mount(
25+
mount(
2526
<Form
2627
onSubmit={() => {
2728
// Do nothing
@@ -38,7 +39,7 @@ it("async typeahead input has correct classname", () => {
3839
const name = faker.random.word();
3940
const options = generateOptions(100);
4041

41-
cy.mount(
42+
mount(
4243
<Form
4344
onSubmit={() => {
4445
// Do nothing
@@ -60,7 +61,7 @@ it("static typeahead input has correct classname", () => {
6061
const name = faker.random.word();
6162
const { simpleOptions } = generateOptions(100);
6263

63-
cy.mount(
64+
mount(
6465
<Form
6566
onSubmit={() => {
6667
// Do nothing
@@ -76,7 +77,7 @@ it("static typeahead input has correct classname", () => {
7677
it("formatted input has correct classname", () => {
7778
const name = faker.random.alpha(10);
7879

79-
cy.mount(
80+
mount(
8081
<Form
8182
onSubmit={() => {
8283
// Do nothing

cypress/cypress/component/ColorPicker/ColorPicker.cy.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Form, ColorPickerInput } from "react-hook-form-components";
22
import { faker } from "@faker-js/faker";
3+
import { mount } from "cypress/react18";
34

45
it("select correct color by specific format", () => {
56
const hexName = faker.random.alpha(10);
67
const rgbName = faker.random.alpha(10);
78
const whiteHex = "#ffffff";
89
const whiteRgb = "rgb(255, 255, 255)";
9-
cy.mount(
10+
mount(
1011
<div className="p-4">
1112
<Form onSubmit={cy.spy().as("onSubmitSpy")}>
1213
<ColorPickerInput name={hexName} useBootstrapStyle label="hex" format="hex" convertColorToFormatOrUndefinedOnBlur={false} />
@@ -32,7 +33,7 @@ it("converts color specified in another format to provided format", () => {
3233
const rgbName = faker.random.alpha(10);
3334
const blackHex = "#000000";
3435
const blackRgb = "rgb(0, 0, 0)";
35-
cy.mount(
36+
mount(
3637
<div className="p-4">
3738
<Form onSubmit={cy.spy().as("onSubmitSpy")}>
3839
<ColorPickerInput name={hexName} useBootstrapStyle label="hex" format="hex" />
@@ -58,7 +59,7 @@ it("recognize color coming from default values (even if specified in different f
5859
const rgbName = faker.random.alpha(10);
5960
const blackHex = "#000000";
6061
const blackRgb = "rgb(0, 0, 0)";
61-
cy.mount(
62+
mount(
6263
<div className="p-4">
6364
<Form
6465
onSubmit={cy.spy().as("onSubmitSpy")}

cypress/cypress/component/Disabled/Disabled.cy.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
useFormContext,
1010
} from "react-hook-form-components";
1111
import { Input as ReactstrapInput, Label } from "reactstrap";
12+
import { mount } from "cypress/react18";
1213

1314
it("disable all fields when readonly attribute is set", () => {
1415
const inputName = faker.random.alpha(10);
@@ -17,7 +18,7 @@ it("disable all fields when readonly attribute is set", () => {
1718
const asyncTypeAheadInputName = faker.random.alpha(10);
1819
const staticTypeAheadInputName = faker.random.alpha(10);
1920

20-
cy.mount(
21+
mount(
2122
<Form
2223
onSubmit={() => {
2324
// Nothing to do
@@ -42,7 +43,7 @@ it("disable all fields when readonly attribute is set", () => {
4243
it("exposing readonly through children function works", () => {
4344
const name = faker.random.alpha(10);
4445

45-
cy.mount(
46+
mount(
4647
<Form
4748
onSubmit={() => {
4849
// Nothing to do
@@ -73,7 +74,7 @@ it("exposing readonly through context works", () => {
7374
</>
7475
);
7576
};
76-
cy.mount(
77+
mount(
7778
<Form
7879
onSubmit={() => {
7980
// Nothing to do

cypress/cypress/component/FormGroupLayout/FormGroupLayout.cy.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { faker } from "@faker-js/faker";
22
import { yupResolver } from "@hookform/resolvers/yup";
33
import { Form, Input, StaticTypeaheadInput, AsyncTypeaheadInput, DatePickerInput, FormattedInput } from "react-hook-form-components";
44
import * as yup from "yup";
5+
import { mount } from "cypress/react18";
56

67
it("adding * character if string label works", () => {
78
const name = faker.random.alpha(10);
89
const schema = yup.object().shape({
910
[name]: yup.number(),
1011
});
1112

12-
cy.mount(
13+
mount(
1314
<Form
1415
onSubmit={() => {
1516
// Nothing to do
@@ -31,7 +32,7 @@ it("ignore * character if label is not of string type works", () => {
3132
[name]: yup.number(),
3233
});
3334

34-
cy.mount(
35+
mount(
3536
<Form
3637
onSubmit={() => {
3738
// Nothing to do
@@ -61,7 +62,7 @@ it("testing existing * on nested object", () => {
6162
[fakePerson.city.address.street]: yup.string(),
6263
});
6364

64-
cy.mount(
65+
mount(
6566
<Form
6667
onSubmit={() => {
6768
// Nothing to do
@@ -105,7 +106,7 @@ const ValidationForm = (props: { hideValidationMessage?: boolean; hideValidation
105106
};
106107

107108
it("show validation messages", () => {
108-
cy.mount(<ValidationForm />);
109+
mount(<ValidationForm />);
109110
cy.get(`button[type=submit]`).click();
110111
cy.get(`label[for=name`).parent().find(".invalid-feedback").should("exist");
111112
cy.get(`label[for=surname`).parent().find("#surname-helper-text").should("exist");
@@ -115,7 +116,7 @@ it("show validation messages", () => {
115116
});
116117

117118
it("hide validation messages when hideValidationMessages is provided through the form", () => {
118-
cy.mount(<ValidationForm hideValidationMessages />);
119+
mount(<ValidationForm hideValidationMessages />);
119120

120121
cy.get(`button[type=submit]`).click();
121122
cy.get(`label[for=name`).parent().find(".invalid-feedback").should("not.exist");
@@ -126,7 +127,7 @@ it("hide validation messages when hideValidationMessages is provided through the
126127
});
127128

128129
it("hide validation message when hideValidationMessage is provided on the single input", () => {
129-
cy.mount(<ValidationForm hideValidationMessage />);
130+
mount(<ValidationForm hideValidationMessage />);
130131

131132
cy.get(`button[type=submit]`).click();
132133
cy.get(`label[for=name`).parent().find(".invalid-feedback").should("not.exist");

cypress/cypress/component/Input/Checkbox.cy.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { yupResolver } from "@hookform/resolvers/yup";
33
import { Form, Input } from "react-hook-form-components";
44
import * as yup from "yup";
55
import { generateOptions } from "../../helpers/typeahead";
6+
import { mount } from "cypress/react18";
67

78
it("checkbox works", () => {
89
const name = faker.random.alpha(10);
910
const schema = yup.object().shape({
1011
[name]: yup.boolean(),
1112
});
1213

13-
cy.mount(
14+
mount(
1415
<Form onSubmit={cy.spy().as("onSubmitSpy")} resolver={yupResolver(schema)}>
1516
<Input type="checkbox" name={name} label={name} />
1617

@@ -35,7 +36,7 @@ it("multiple checkboxes pass their value", () => {
3536

3637
const { objectOptions, randomSubset } = generateOptions();
3738

38-
cy.mount(
39+
mount(
3940
<Form onSubmit={cy.spy().as("onSubmitSpy")} resolver={yupResolver(schema)}>
4041
{objectOptions.map((option, i) => (
4142
<Input type="checkbox" key={option.value} name={name} label={option.label} value={option.value} id={`${name}-${i}`} />
@@ -59,7 +60,7 @@ it("switch works", () => {
5960
[name]: yup.boolean(),
6061
});
6162

62-
cy.mount(
63+
mount(
6364
<Form onSubmit={cy.spy().as("onSubmitSpy")} resolver={yupResolver(schema)}>
6465
<Input type="switch" name={name} label={name} />
6566

@@ -81,7 +82,7 @@ it("has disabled checkbox variants", () => {
8182
const switchName = faker.random.word();
8283
const checkboxName = faker.random.word();
8384

84-
cy.mount(
85+
mount(
8586
<Form
8687
onSubmit={() => {
8788
// Do nothing

cypress/cypress/component/Input/InputPlainText.cy.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Form, Input } from "react-hook-form-components";
22
import { faker } from "@faker-js/faker";
3+
import { mount } from "cypress/react18";
34

45
it("it has form-control-plaintext class", () => {
56
const name = faker.random.alpha(10);
67
const value = faker.random.alpha(10);
78

8-
cy.mount(
9+
mount(
910
<Form
1011
onSubmit={() => {
1112
// Do nothing
@@ -21,7 +22,7 @@ it("it has the correct style", () => {
2122
const name = faker.random.alpha(10);
2223
const value = faker.random.alpha(10);
2324

24-
cy.mount(
25+
mount(
2526
<Form
2627
onSubmit={() => {
2728
// Do nothing

cypress/cypress/component/Style/Style.cy.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Form, Input, AsyncTypeaheadInput, StaticTypeaheadInput } from "react-hook-form-components";
22
import { faker } from "@faker-js/faker";
33
import { fetchMock, generateOptions } from "../../helpers/typeahead";
4+
import { mount } from "cypress/react18";
45

56
it("input has correct style", () => {
67
const name = faker.random.alpha(10);
78
const value = faker.random.alpha(10);
89

9-
cy.mount(
10+
mount(
1011
<Form
1112
onSubmit={() => {
1213
// Do nothing
@@ -24,7 +25,7 @@ it("async typeahead input has correct style", () => {
2425
const options = generateOptions(100);
2526
const customStyle = "background-color: black; margin-top: 10px;";
2627

27-
cy.mount(
28+
mount(
2829
<Form
2930
onSubmit={() => {
3031
// Do nothing
@@ -47,7 +48,7 @@ it("static typeahead input has correct style", () => {
4748
const { simpleOptions } = generateOptions(100);
4849
const customStyle = "background-color: black; margin-top: 10px;";
4950

50-
cy.mount(
51+
mount(
5152
<Form
5253
onSubmit={() => {
5354
// Do nothing

cypress/cypress/component/Typeahead/AsyncTypeaheadInput.cy.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,9 @@ it("placeholder", () => {
670670
);
671671

672672
cy.get(`#${name}`).should("have.attr", "placeholder", placeholder);
673-
simpleOptions.slice(0, 2).forEach((option) => selectOption(name, option));
673+
for (const option of simpleOptions.slice(0, 2)) {
674+
selectOption(name, option);
675+
}
674676
cy.get(`#${name}`).should("not.have.attr", "placeholder");
675677
});
676678

@@ -810,7 +812,9 @@ it("cannot select already selected option when multiple", () => {
810812
</div>,
811813
);
812814

813-
cy.get(`#${name}`).clear().click().type(defaultSelectedOption.label);
815+
cy.get(`#${name}`).clear();
816+
cy.get(`#${name}`).click();
817+
cy.focused().type(defaultSelectedOption.label);
814818
waitLoadingOptions();
815819
cy.get('div[role="presentation"]').should("have.class", "MuiAutocomplete-noOptions");
816820
});

cypress/cypress/component/Typeahead/StaticTypeaheadInput.cy.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,9 @@ it("placeholder", () => {
415415
);
416416

417417
cy.get(`#${name}`).should("have.attr", "placeholder", placeholder);
418-
simpleOptions.slice(0, 2).forEach((option) => selectOption(name, option));
418+
for (const option of simpleOptions.slice(0, 2)) {
419+
selectOption(name, option);
420+
}
419421
cy.get(`#${name}`).should("not.have.attr", "placeholder");
420422
});
421423

0 commit comments

Comments
 (0)