Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e test for reparentPopoutWidgets preview feature #1133

Merged
merged 6 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@itwin/imodels-access-frontend": "^5.2.3",
"@itwin/imodels-client-authoring": "^5.9.0",
"@itwin/imodels-client-management": "^5.9.0",
"@itwin/itwinui-react": "^3.15.0",
"@itwin/itwinui-react": "^3.16.6",
"@itwin/itwinui-react-v2": "npm:@itwin/itwinui-react@^2.12.26",
"@itwin/itwinui-icons-react": "^2.8.0",
"@itwin/itwinui-layouts-react": "~0.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "./TestPopoutFrontstage.scss";
import * as React from "react";
import { Frontstage } from "@itwin/appui-react";
import { createTestFrontstage } from "./createTestFrontstage";
import { ProgressRadial } from "@itwin/itwinui-react";
import { Button, Input, ProgressRadial } from "@itwin/itwinui-react";
import { Logger } from "@itwin/core-bentley";
import { loggerCategory } from "../../logger";
import { WidgetContentThrowError } from "@itwin/appui-test-providers";
Expand Down Expand Up @@ -53,6 +53,14 @@ export const createTestPopoutFrontstage = () => {
),
},
],
end: [
{
id: "state-widget",
label: "State widget",
canPopout: true,
content: <StateWidget />,
},
],
},
},
} satisfies Frontstage;
Expand Down Expand Up @@ -122,3 +130,15 @@ function LinkTest() {
}, []);
return <div ref={ref} id="link-test" style={{ background: "red" }} />;
}

function StateWidget() {
const [value, setValue] = React.useState(0);
return (
<>
<Input defaultValue="Default value" />
<Button onClick={() => setValue((prev) => prev + 1)}>
Increment: {value}
</Button>
</>
);
}
2 changes: 1 addition & 1 deletion apps/test-providers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@itwin/core-react": "workspace:*",
"@itwin/appui-react": "workspace:*",
"@itwin/imodel-components-react": "workspace:*",
"@itwin/itwinui-react": "^3.15.0",
"@itwin/itwinui-react": "^3.16.6",
"@itwin/itwinui-icons-react": "^2.8.0",
"@itwin/webgl-compatibility": "^4.0.0",
"classnames": "2.5.1",
Expand Down
7 changes: 1 addition & 6 deletions apps/test-providers/src/ui/widgets/LayoutWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,7 @@ export function WidgetContentThrowError() {
if (shouldThrow) {
throw new Error("Simulated error was thrown.");
}
return (
<>
<h2>Throw error button</h2>
<Button onClick={() => setShouldThrow(true)}>Throw Error</Button>
</>
);
return <Button onClick={() => setShouldThrow(true)}>Throw Error</Button>;
}

const widgetContentStyle: React.CSSProperties = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/appui-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/appui-react"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/components-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/components-react"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/core-react"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/imodel-components-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/imodel-components-react"
}
38 changes: 19 additions & 19 deletions common/config/rush/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion docs/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@itwin/imodels-access-frontend": "^5.2.3",
"@itwin/imodels-client-authoring": "^5.9.0",
"@itwin/itwinui-icons-react": "^2.8.0",
"@itwin/itwinui-react": "^3.15.0",
"@itwin/itwinui-react": "^3.16.6",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-redux": "^9.1.2"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions e2e-tests/tests/popout-widget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,31 @@ for (const useDefaultPopoutUrl of [1, 0]) {
await expectTabInPanelSection(tab, "left", 0);
});
}

test("should persist widget state with `reparentPopoutWidgets` enabled", async ({
page,
}) => {
await page.goto("./blank?frontstageId=test-popout&reparentPopoutWidgets=1");

const increment = page.getByRole("button", { name: "Increment: " });
await increment.click();
await increment.click();
await increment.click();
await expect(increment).toHaveText("Increment: 3");

const input = page.getByRole("textbox");
await input.fill("test");
await expect(input).toHaveValue("test");

const tab = tabLocator(page, "State widget");
const widget = widgetLocator({ tab });
const popoutPage = await popoutWidget(widget);

const popoutIncrement = popoutPage.getByRole("button", {
name: "Increment: 3",
});
await expect(popoutIncrement).toBeVisible();

const popoutInput = popoutPage.getByRole("textbox");
await expect(popoutInput).toHaveValue("test");
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ui/appui-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"@itwin/ecschema-metadata": "^4.0.0",
"@itwin/eslint-plugin": "5.0.0-dev.2",
"@itwin/imodel-components-react": "workspace:*",
"@itwin/itwinui-react": "^3.15.0",
"@itwin/itwinui-react": "^3.16.6",
"@itwin/webgl-compatibility": "^4.0.0",
"@testing-library/dom": "^10.1.0",
"@testing-library/react": "^15.0.7",
Expand Down
2 changes: 1 addition & 1 deletion ui/components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@itwin/core-i18n": "^4.0.0",
"@itwin/core-react": "workspace:*",
"@itwin/eslint-plugin": "5.0.0-dev.2",
"@itwin/itwinui-react": "^3.15.0",
"@itwin/itwinui-react": "^3.16.6",
"@testing-library/dom": "^10.1.0",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
Expand Down
2 changes: 1 addition & 1 deletion ui/core-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@itwin/core-geometry": "^4.0.0",
"@itwin/core-i18n": "^4.0.0",
"@itwin/eslint-plugin": "5.0.0-dev.2",
"@itwin/itwinui-react": "^3.15.0",
"@itwin/itwinui-react": "^3.16.6",
"@testing-library/dom": "^10.1.0",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
Expand Down
2 changes: 1 addition & 1 deletion ui/imodel-components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@itwin/core-quantity": "^4.0.0",
"@itwin/core-react": "workspace:*",
"@itwin/eslint-plugin": "5.0.0-dev.2",
"@itwin/itwinui-react": "^3.15.0",
"@itwin/itwinui-react": "^3.16.6",
"@itwin/webgl-compatibility": "^4.0.0",
"@testing-library/dom": "^10.1.0",
"@testing-library/react": "^15.0.7",
Expand Down