-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
apps/test-app/src/frontend/appui/frontstages/TestWidgetFrontstage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from "react"; | ||
import { | ||
Frontstage, | ||
StagePanelState, | ||
Widget, | ||
WidgetState, | ||
} from "@itwin/appui-react"; | ||
import { createTestFrontstage } from "./createTestFrontstage"; | ||
|
||
/** Used in e2e tests to test different widget configurations. */ | ||
export const createTestWidgetFrontstage = () => { | ||
{ | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const frontstageParams = getFrontstageParams(urlParams); | ||
|
||
const defaultState = getDefaultState(urlParams); | ||
const useSavedState = urlParams.has("useSavedState"); | ||
|
||
const frontstage = createTestFrontstage({ | ||
id: "test-widget", | ||
version: frontstageParams.version, | ||
}); | ||
|
||
return { | ||
...frontstage, | ||
rightPanel: { | ||
defaultState: StagePanelState.Open, | ||
sections: { | ||
start: [ | ||
{ | ||
id: "widget-1", | ||
label: "Widget 1", | ||
content: <>Widget 1 content</>, | ||
defaultState, | ||
useSavedState, | ||
}, | ||
], | ||
}, | ||
}, | ||
} satisfies Frontstage; | ||
} | ||
}; | ||
|
||
function getFrontstageParams(params: URLSearchParams) { | ||
const versionParam = params.get("frontstageVersion"); | ||
const version = versionParam ? Number(versionParam) : undefined; | ||
return { version } satisfies Partial<Frontstage>; | ||
} | ||
|
||
function getDefaultState(params: URLSearchParams): Widget["defaultState"] { | ||
const param = params.get("defaultState"); | ||
if (param === "hidden") return WidgetState.Hidden; | ||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters