Skip to content

Commit 2a5506a

Browse files
committed
Refactor
1 parent c0dabc9 commit 2a5506a

2 files changed

Lines changed: 37 additions & 75 deletions

File tree

e2e/VGrid.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ test("check if scrollToIndex works", async ({ page }) => {
134134
(await getFirstItem(component)).text.startsWith("0 / 0")
135135
).toBeTruthy();
136136

137-
const button = (await page
138-
.getByRole("button", { name: "scroll to index" })
139-
.elementHandle())!;
137+
const button = page.getByRole("button", { name: "scroll to index" });
140138
const [colInput, rowInput] = await page.$$("input");
141139

142140
await button.click();

e2e/VList.spec.ts

Lines changed: 36 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,12 @@ test.describe("smoke", () => {
156156
const mountedItem = await getFirstItem(component);
157157
expect(mountedItem.text).not.toEqual(initialItem.text);
158158

159-
const button = (await page
160-
.getByRole("button", { name: "hide" })
161-
.elementHandle())!;
162-
163159
// check if items are unmounted
164-
await button.click();
160+
await page.getByRole("button", { name: "hide" }).click();
165161
expect((await getFirstItem(component)).text).not.toEqual(mountedItem.text);
166162

167163
// check if scroll position is restored
168-
await button.click();
164+
await page.getByRole("button", { name: "show" }).click();
169165
await page.waitForTimeout(250);
170166
const remountedComponent = await getScrollable(page);
171167
const remountedItem = await getFirstItem(remountedComponent);
@@ -510,9 +506,7 @@ test.describe("check if scroll jump compensation works", () => {
510506

511507
await clearTimer(page);
512508

513-
const button = (await page
514-
.getByRole("button", { name: "submit" })
515-
.elementHandle())!;
509+
const button = page.getByRole("button", { name: "submit" });
516510
const textarea = (await page.getByRole("textbox"))!;
517511

518512
// append small item
@@ -612,12 +606,9 @@ test.describe("check if scrollToIndex works", () => {
612606
// check if start is displayed
613607
await expect((await getFirstItem(component)).text).toEqual("0");
614608

615-
const button = (await page
616-
.getByRole("button", { name: "scroll to index" })
617-
.elementHandle())!;
618-
const input = await page.evaluateHandle(
619-
(el) => el!.previousSibling as HTMLInputElement,
620-
button
609+
const button = page.getByRole("button", { name: "scroll to index" });
610+
const input = await button.evaluateHandle(
611+
(el) => el.previousSibling as HTMLInputElement
621612
);
622613

623614
await clearInput(input);
@@ -643,12 +634,9 @@ test.describe("check if scrollToIndex works", () => {
643634
// check if start is displayed
644635
await expect((await getFirstItem(component)).text).toEqual("0");
645636

646-
const button = (await page
647-
.getByRole("button", { name: "scroll to index" })
648-
.elementHandle())!;
649-
const input = await page.evaluateHandle(
650-
(el) => el!.previousSibling as HTMLInputElement,
651-
button
637+
const button = page.getByRole("button", { name: "scroll to index" });
638+
const input = await button.evaluateHandle(
639+
(el) => el.previousSibling as HTMLInputElement
652640
);
653641

654642
await clearInput(input);
@@ -681,12 +669,9 @@ test.describe("check if scrollToIndex works", () => {
681669
// check if start is displayed
682670
await expect((await getFirstItem(component)).text).toEqual("0");
683671

684-
const button = (await page
685-
.getByRole("button", { name: "scroll to index" })
686-
.elementHandle())!;
687-
const input = await page.evaluateHandle(
688-
(el) => el!.previousSibling as HTMLInputElement,
689-
button
672+
const button = page.getByRole("button", { name: "scroll to index" });
673+
const input = await button.evaluateHandle(
674+
(el) => el.previousSibling as HTMLInputElement
690675
);
691676

692677
await clearInput(input);
@@ -713,12 +698,9 @@ test.describe("check if scrollToIndex works", () => {
713698

714699
await page.getByRole("checkbox", { name: "smooth" }).click();
715700

716-
const button = (await page
717-
.getByRole("button", { name: "scroll to index" })
718-
.elementHandle())!;
719-
const input = await page.evaluateHandle(
720-
(el) => el!.previousSibling as HTMLInputElement,
721-
button
701+
const button = page.getByRole("button", { name: "scroll to index" });
702+
const input = await button.evaluateHandle(
703+
(el) => el.previousSibling as HTMLInputElement
722704
);
723705

724706
const scrollListener = listenScrollCount(component);
@@ -760,12 +742,9 @@ test.describe("check if scrollToIndex works", () => {
760742
// check if start is displayed
761743
await expect((await getFirstItem(component)).text).toEqual("0");
762744

763-
const button = (await page
764-
.getByRole("button", { name: "scroll to index" })
765-
.elementHandle())!;
766-
const input = await page.evaluateHandle(
767-
(el) => el!.previousSibling as HTMLInputElement,
768-
button
745+
const button = page.getByRole("button", { name: "scroll to index" });
746+
const input = await button.evaluateHandle(
747+
(el) => el.previousSibling as HTMLInputElement
769748
);
770749

771750
await clearInput(input);
@@ -791,12 +770,9 @@ test.describe("check if scrollToIndex works", () => {
791770
// check if start is displayed
792771
await expect((await getFirstItem(component)).text).toEqual("0");
793772

794-
const button = (await page
795-
.getByRole("button", { name: "scroll to index" })
796-
.elementHandle())!;
797-
const input = await page.evaluateHandle(
798-
(el) => el!.previousSibling as HTMLInputElement,
799-
button
773+
const button = page.getByRole("button", { name: "scroll to index" });
774+
const input = await button.evaluateHandle(
775+
(el) => el.previousSibling as HTMLInputElement
800776
);
801777

802778
await clearInput(input);
@@ -829,12 +805,9 @@ test.describe("check if scrollToIndex works", () => {
829805
// check if start is displayed
830806
await expect((await getFirstItem(component)).text).toEqual("0");
831807

832-
const button = (await page
833-
.getByRole("button", { name: "scroll to index" })
834-
.elementHandle())!;
835-
const input = await page.evaluateHandle(
836-
(el) => el!.previousSibling as HTMLInputElement,
837-
button
808+
const button = page.getByRole("button", { name: "scroll to index" });
809+
const input = await button.evaluateHandle(
810+
(el) => el.previousSibling as HTMLInputElement
838811
);
839812

840813
await clearInput(input);
@@ -861,12 +834,9 @@ test.describe("check if scrollToIndex works", () => {
861834

862835
await page.getByRole("checkbox", { name: "smooth" }).click();
863836

864-
const button = (await page
865-
.getByRole("button", { name: "scroll to index" })
866-
.elementHandle())!;
867-
const input = await page.evaluateHandle(
868-
(el) => el!.previousSibling as HTMLInputElement,
869-
button
837+
const button = page.getByRole("button", { name: "scroll to index" });
838+
const input = await button.evaluateHandle(
839+
(el) => el.previousSibling as HTMLInputElement
870840
);
871841

872842
const scrollListener = listenScrollCount(component);
@@ -909,12 +879,9 @@ test.describe("check if scrollTo works", () => {
909879
// check if start is displayed
910880
await expect((await getFirstItem(component)).text).toEqual("0");
911881

912-
const button = (await page
913-
.getByRole("button", { name: "scroll to offset" })
914-
.elementHandle())!;
915-
const input = await page.evaluateHandle(
916-
(el) => el!.previousSibling as HTMLInputElement,
917-
button
882+
const button = page.getByRole("button", { name: "scroll to offset" });
883+
const input = await button.evaluateHandle(
884+
(el) => el.previousSibling as HTMLInputElement
918885
);
919886

920887
// scroll down
@@ -955,12 +922,11 @@ test.describe("check if scrollBy works", () => {
955922
// check if start is displayed
956923
await expect((await getFirstItem(component)).text).toEqual("0");
957924

958-
const button = (await page
959-
.getByRole("button", { name: "scroll by offset" })
960-
.elementHandle())!;
961-
const input = await page.evaluateHandle(
962-
(el) => el!.previousSibling!.previousSibling as HTMLInputElement,
963-
button
925+
const button = page.getByRole("button", {
926+
name: "scroll by offset",
927+
});
928+
const input = await button.evaluateHandle(
929+
(el) => el.previousSibling!.previousSibling as HTMLInputElement
964930
);
965931

966932
// scroll down
@@ -1278,9 +1244,7 @@ test.describe("check if item shift compensation works", () => {
12781244

12791245
const scrollListener = listenScrollCount(component);
12801246

1281-
const button = (await page
1282-
.getByRole("button", { name: "jump to top" })
1283-
.elementHandle())!;
1247+
const button = page.getByRole("button", { name: "jump to top" });
12841248

12851249
// scroll to top
12861250
await button.click();

0 commit comments

Comments
 (0)