Skip to content

Commit

Permalink
Added test to expand selected node
Browse files Browse the repository at this point in the history
  • Loading branch information
syedsalehinipg committed Mar 11, 2024
1 parent 0629fcd commit 8085655
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/TreeViewList/TreeViewList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,33 @@ test("should not expand the child nodes when expand for search is not enabled",
throw new Error("Frame element is null");
}
});

test("should expand selected node", async ({ page }) => {
// Navigate to the story
await page.goto(
"http://localhost:6006/?path=/story/lists-treeviewlist--default"
);

// Wait for the iframe to be attached in the DOM.
await page.waitForSelector('iframe[title="storybook-preview-iframe"]');

// Expect the test node to be hidden initially
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByText("Mass", { exact: true })
).toBeHidden();

// Fill the selected field with an example node id and then lose focus to trigger the update
await page
.getByPlaceholder("Edit JSON string...")
.fill('"SUS.Damper.Front.Mass"');
await page.keyboard.press("Tab");

// Expect the selected test node to be visible after the update
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByText("Mass", { exact: true })
).toBeVisible();
});

0 comments on commit 8085655

Please sign in to comment.