Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed Nov 3, 2024
1 parent c0dabc9 commit e54f3b8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 74 deletions.
4 changes: 1 addition & 3 deletions e2e/VGrid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ test("check if scrollToIndex works", async ({ page }) => {
(await getFirstItem(component)).text.startsWith("0 / 0")
).toBeTruthy();

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const button = page.getByRole("button", { name: "scroll to index" });
const [colInput, rowInput] = await page.$$("input");

await button.click();
Expand Down
107 changes: 36 additions & 71 deletions e2e/VList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,13 @@ test.describe("smoke", () => {
const mountedItem = await getFirstItem(component);
expect(mountedItem.text).not.toEqual(initialItem.text);

const button = (await page
.getByRole("button", { name: "hide" })
.elementHandle())!;

// check if items are unmounted
await button.click();
await page.getByRole("button", { name: "hide" }).click();
expect((await getFirstItem(component)).text).not.toEqual(mountedItem.text);

// check if scroll position is restored
await button.click();
await page.getByRole("button", { name: "show" }).click();
await page.waitForTimeout(250);
const remountedComponent = await getScrollable(page);
const remountedItem = await getFirstItem(remountedComponent);
Expand Down Expand Up @@ -510,9 +507,7 @@ test.describe("check if scroll jump compensation works", () => {

await clearTimer(page);

const button = (await page
.getByRole("button", { name: "submit" })
.elementHandle())!;
const button = page.getByRole("button", { name: "submit" });
const textarea = (await page.getByRole("textbox"))!;

// append small item
Expand Down Expand Up @@ -612,12 +607,9 @@ test.describe("check if scrollToIndex works", () => {
// check if start is displayed
await expect((await getFirstItem(component)).text).toEqual("0");

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to index" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

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

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to index" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

await clearInput(input);
Expand Down Expand Up @@ -681,12 +670,9 @@ test.describe("check if scrollToIndex works", () => {
// check if start is displayed
await expect((await getFirstItem(component)).text).toEqual("0");

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to index" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

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

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

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to index" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

const scrollListener = listenScrollCount(component);
Expand Down Expand Up @@ -760,12 +743,9 @@ test.describe("check if scrollToIndex works", () => {
// check if start is displayed
await expect((await getFirstItem(component)).text).toEqual("0");

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to index" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

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

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to index" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

await clearInput(input);
Expand Down Expand Up @@ -829,12 +806,9 @@ test.describe("check if scrollToIndex works", () => {
// check if start is displayed
await expect((await getFirstItem(component)).text).toEqual("0");

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to index" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

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

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

const button = (await page
.getByRole("button", { name: "scroll to index" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to index" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

const scrollListener = listenScrollCount(component);
Expand Down Expand Up @@ -909,12 +880,9 @@ test.describe("check if scrollTo works", () => {
// check if start is displayed
await expect((await getFirstItem(component)).text).toEqual("0");

const button = (await page
.getByRole("button", { name: "scroll to offset" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", { name: "scroll to offset" });
const input = await button.evaluateHandle(
(el) => el.previousSibling as HTMLInputElement
);

// scroll down
Expand Down Expand Up @@ -955,12 +923,11 @@ test.describe("check if scrollBy works", () => {
// check if start is displayed
await expect((await getFirstItem(component)).text).toEqual("0");

const button = (await page
.getByRole("button", { name: "scroll by offset" })
.elementHandle())!;
const input = await page.evaluateHandle(
(el) => el!.previousSibling!.previousSibling as HTMLInputElement,
button
const button = page.getByRole("button", {
name: "scroll by offset",
});
const input = await button.evaluateHandle(
(el) => el.previousSibling!.previousSibling as HTMLInputElement
);

// scroll down
Expand Down Expand Up @@ -1278,9 +1245,7 @@ test.describe("check if item shift compensation works", () => {

const scrollListener = listenScrollCount(component);

const button = (await page
.getByRole("button", { name: "jump to top" })
.elementHandle())!;
const button = page.getByRole("button", { name: "jump to top" });

// scroll to top
await button.click();
Expand Down

0 comments on commit e54f3b8

Please sign in to comment.