Skip to content

Commit

Permalink
Update main package versions (#166)
Browse files Browse the repository at this point in the history
* Update itwijs/core package versions

* Fix ci pipeline

* Update itwinui version

* Remove tableProps

* Adress comments

* Update pnpm lock

* Fix typecheck issues

* Update dependencies

* Update app/frontend/src/app/AppHeader.tsx

Co-authored-by: Saulius Skliutas <[email protected]>

* Add more meaningful keys to dropdown menu

* Fix dependencies

* Update react version

* Update tests to use getByRole

* Update appui version

* Fix import

* Fix all issues

* Fix tables

---------

Co-authored-by: Saulius Skliutas <[email protected]>
  • Loading branch information
JonasDov and saskliutas authored Nov 15, 2024
1 parent a00d44f commit 69c8751
Show file tree
Hide file tree
Showing 41 changed files with 7,503 additions and 5,319 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8.0.0
version: 9

- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: "pnpm"

- name: Install dependencies
Expand All @@ -37,6 +37,9 @@ jobs:
- name: Typecheck
run: npm run typecheck

- name: Prettier
run: npm run prettier

- name: Build presentation-rules-editor-react package
run: npm run build --prefix ./presentation-rules-editor-react

Expand Down
8 changes: 6 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
"sidenav",
"signin",
"signout",
"tablist",
"testid",
"threagile",
"twinjs",
"typecheck",
"unicodes",
"unmangled",
"unregisters",
Expand All @@ -52,7 +55,7 @@
"wdth",
"wght"
],
"cSpell.ignorePaths": ["package.json", ".vscode", "*.yaml"],
"cSpell.ignorePaths": ["package.json", ".vscode", "*.yaml", "*.yml"],
"cSpell.ignoreRegExpList": ["from\\s\".*\";"],

"editor.insertSpaces": true,
Expand All @@ -61,7 +64,8 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},

"eslint.useFlatConfig": true,
Expand Down
24 changes: 12 additions & 12 deletions app/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
},
"dependencies": {
"@app/common": "workspace:*",
"@itwin/core-backend": "^4.7.2",
"@itwin/core-bentley": "^4.7.2",
"@itwin/core-common": "^4.7.2",
"@itwin/core-geometry": "^4.7.2",
"@itwin/core-quantity": "^4.7.2",
"@itwin/ecschema-metadata": "^4.7.2",
"@itwin/ecschema-rpcinterface-common": "^4.7.2",
"@itwin/ecschema-rpcinterface-impl": "^4.7.2",
"@itwin/core-backend": "^4.10.0",
"@itwin/core-bentley": "^4.10.0",
"@itwin/core-common": "^4.10.0",
"@itwin/core-geometry": "^4.10.0",
"@itwin/core-quantity": "^4.10.0",
"@itwin/ecschema-metadata": "^4.10.0",
"@itwin/ecschema-rpcinterface-common": "^4.10.0",
"@itwin/ecschema-rpcinterface-impl": "^4.10.0",
"@itwin/eslint-plugin": "^4.1.1",
"@itwin/express-server": "^4.7.2",
"@itwin/express-server": "^4.10.0",
"@itwin/imodels-access-backend": "^4.1.5",
"@itwin/presentation-backend": "^4.7.2",
"@itwin/presentation-common": "^4.7.2",
"@types/node": "^18.19.24",
"@itwin/presentation-backend": "^4.10.0",
"@itwin/presentation-common": "^4.10.0",
"@types/node": "^20.17.6",
"dotenv": "^10.0.0",
"eslint": "^8.57.1",
"pretty-bytes": "^5.6.0",
Expand Down
8 changes: 2 additions & 6 deletions app/backend/src/SnapshotFileNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

import { IModelHost } from "@itwin/core-backend";
import * as path from "path";
import { FileNameResolver, IModelHost } from "@itwin/core-backend";

export class SnapshotFileNameResolver extends FileNameResolver {
public override tryResolveFileName(inFileName: string): string | undefined {
return path.resolve(SnapshotFileNameResolver.getIModelsDirectory(), inFileName);
}

export class SnapshotFileNameResolver {
public static getIModelsDirectory(): string {
const assetsDir = IModelHost.appAssetsDir ? IModelHost.appAssetsDir : "assets";
return path.resolve(path.join(assetsDir, "imodels"));
Expand Down
4 changes: 1 addition & 3 deletions app/backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

import * as dotenv from "dotenv";
import { rpcInterfaces } from "@app/common";
import { IModelHost, IModelHostConfiguration } from "@itwin/core-backend";
import { Logger, LogLevel } from "@itwin/core-bentley";
import { RpcConfiguration } from "@itwin/core-common";
import { ECSchemaRpcImpl } from "@itwin/ecschema-rpcinterface-impl";
import { BackendIModelsAccess } from "@itwin/imodels-access-backend";
import { Presentation, PresentationBackendLoggerCategory, PresentationBackendNativeLoggerCategory } from "@itwin/presentation-backend";
import * as dotenv from "dotenv";
import { PresentationRulesEditorRpcImpl } from "./PresentationRulesEditorRpcImpl";
import { SnapshotFileNameResolver } from "./SnapshotFileNameResolver";
import { initialize } from "./web/BackendServer";

dotenv.config({ path: "../../.env" });
Expand All @@ -28,7 +27,6 @@ void (async () => {
// eslint-disable-next-line @itwin/no-internal
config.hubAccess = new BackendIModelsAccess();
await IModelHost.startup(config);
IModelHost.snapshotFileNameResolver = new SnapshotFileNameResolver();

Presentation.initialize({
workerThreadsCount: 1,
Expand Down
14 changes: 7 additions & 7 deletions app/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"lint": "eslint **/*.{ts,tsx}"
},
"dependencies": {
"@itwin/core-bentley": "^4.7.2",
"@itwin/core-common": "^4.7.2",
"@itwin/core-geometry": "^4.7.2",
"@itwin/core-quantity": "^4.7.2",
"@itwin/ecschema-metadata": "^4.7.2",
"@itwin/ecschema-rpcinterface-common": "^4.7.2",
"@itwin/core-bentley": "^4.10.0",
"@itwin/core-common": "^4.10.0",
"@itwin/core-geometry": "^4.10.0",
"@itwin/core-quantity": "^4.10.0",
"@itwin/ecschema-metadata": "^4.10.0",
"@itwin/ecschema-rpcinterface-common": "^4.10.0",
"@itwin/eslint-plugin": "^4.1.1",
"@itwin/presentation-common": "^4.7.2",
"@itwin/presentation-common": "^4.10.0",
"eslint": "^8.57.1",
"typescript": "^4.9.5"
}
Expand Down
4 changes: 2 additions & 2 deletions app/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"@itwin/eslint-plugin": "^4.1.1",
"@types/chai": "^4.3.12",
"@types/mocha": "^10.0.6",
"@types/node": "^16.18.89",
"@types/node": "^20.17.6",
"chai": "^4.4.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"jest-dev-server": "^10.0.0",
"mocha": "^10.3.0",
"mocha-junit-reporter": "^2.2.1",
"playwright": "^1.42.1",
"playwright": "^1.48.2",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
}
Expand Down
31 changes: 17 additions & 14 deletions app/e2e-tests/src/header.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ describe("header #local", () => {
});

it("populates header with opened snapshot information", async () => {
const header = await page.waitForSelector(".iui-page-header nav");
expect(await header.waitForSelector('text="Local snapshots"'));
expect(await header.waitForSelector("text=Baytown.bim"));
const header = page.getByRole("navigation", { name: "breadcrumbs" });
expect(await header.getByText("Local snapshots").isVisible()).to.be.true;
expect(await header.getByText("Baytown.bim").isVisible()).to.be.true;
});

it("allows navigating to snapshot iModels browser", async () => {
await page.click('text="Local snapshots"');
expect(await page.waitForSelector("button.iui-tab.iui-active >> text='Local snapshots'"));
await page.getByText("Local snapshots").click();
await page.getByRole("tab", { name: "Local snapshots", selected: true }).waitFor();
});

it("clears breadcrumbs after navigating to home", async () => {
await page.click('text="Local snapshots"');
const header = await page.waitForSelector(".iui-page-header nav", { state: "attached" });
await page.getByText("Local snapshots").click();
const header = page.getByRole("navigation", { name: "breadcrumbs" });
await header.waitFor({ state: "attached" });
expect(await header.textContent()).to.be.empty;
});
});
Expand All @@ -36,19 +37,21 @@ describe("header #web", () => {
});

it("populates header with opened demo iModel information", async () => {
const header = await page.waitForSelector(".iui-page-header nav");
expect(header.$('text="Demo iModel"'));
expect(header.$('text="Bay Town Process Plant"'));
const header = page.getByRole("navigation", { name: "breadcrumbs" });
await header.waitFor();
expect(await header.getByText("Demo iModel").isVisible()).to.be.true;
expect(await header.getByText("Bay Town Process Plant").isVisible()).to.be.true;
});

it("allows navigating to demo iModels browser", async () => {
await page.click('text="Demo iModels"');
expect(await page.waitForSelector("button.iui-tab.iui-active >> text='Demo iModels'"));
await page.getByText("Demo iModels").click();
await page.getByRole("tab", { name: "Demo iModels", selected: true }).waitFor();
});

it("clears breadcrumbs after navigating to home", async () => {
await page.click('text="Presentation Rules Editor"');
const header = await page.waitForSelector(".iui-page-header nav", { state: "attached" });
await page.getByText("Presentation Rules Editor").click();
const header = page.getByRole("navigation", { name: "breadcrumbs" });
await header.waitFor({ state: "attached" });
expect(await header.textContent()).to.be.empty;
});
});
27 changes: 16 additions & 11 deletions app/e2e-tests/src/imodel-browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ describe("iModel browser #local", () => {
});

it("gives options for browsing snapshots, iTwins and demo iModels", async () => {
await page.waitForSelector(".iui-tabs >> text=Local snapshots");
await page.waitForSelector(".iui-tabs >> text=My iTwins");
await page.waitForSelector(".iui-tabs >> text=Demo iModels");
const tabList = page.getByRole("tablist");
await tabList.waitFor();
await Promise.all([
page.getByRole("tab", { name: "Local snapshots" }).waitFor(),
page.getByRole("tab", { name: "My iTwins" }).waitFor(),
page.getByRole("tab", { name: "Demo iModels" }).waitFor(),
]);
});

it("allows opening a snapshot iModel", async () => {
await page.click("text=Local snapshots");
await page.click("text=Baytown.bim");
await page.waitForSelector("text=Submit ruleset");
await page.getByRole("tab", { name: "Local snapshots" }).click();
await page.getByText("Baytown.bim").click();
await page.getByText("Submit ruleset").waitFor();
});
});

Expand All @@ -30,13 +34,14 @@ describe("iModel browser #web", () => {
});

it("gives options for browsing iTwins and demo iModels", async () => {
await page.waitForSelector(".iui-tabs >> text=My iTwins");
await page.waitForSelector(".iui-tabs >> text=Demo iModels");
const tabList = page.getByRole("tablist");
await tabList.waitFor();
await Promise.all([page.getByRole("tab", { name: "My iTwins" }).waitFor(), page.getByRole("tab", { name: "Demo iModels" }).waitFor()]);
});

it("allows opening a demo iModel", async () => {
await page.click("text=Demo iModels");
await page.click("text=Bay Town Process Plant");
await page.waitForSelector("text=Submit ruleset");
await page.getByRole("tab", { name: "Demo iModels" }).click();
await page.getByText("Bay Town Process Plant").click();
await page.getByText("Submit ruleset").waitFor();
});
});
12 changes: 8 additions & 4 deletions app/e2e-tests/src/share.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,19 @@ describe("opening shared link #local #web", () => {
it("offers user to sign in when link points to a private iModel", async () => {
await page.goto(`${getServiceUrl()}/open-imodel?iTwinId=test_itwin&iModelId=test_imodel`);

const appHeader = await page.waitForSelector(".iui-page-header");
const options = await page.waitForSelector(".landing-page-options");
expect(await options?.textContent()).to.contain(process.env.WEB_TEST || (await appHeader.$('text="Offline mode"')) === null ? "Sign In" : "Go to homepage");
const appHeader = page.getByRole("banner");
const options = page.locator(".landing-page-options");
await Promise.all([appHeader.waitFor(), options.waitFor()]);

const offlineMode = appHeader.getByText("Offline mode");
const isOfflineModeVisible = await offlineMode.isVisible();
expect(await options?.textContent()).to.contain(process.env.WEB_TEST || isOfflineModeVisible === false ? "Sign In" : "Go to homepage");
});
});

describe("opening snapshot link in #web", () => {
it("shows user 404 error", async () => {
await page.goto(`${getServiceUrl()}/open-imodel?snapshot=test_snapshot`);
await page.waitForSelector('text="Page Not Found"');
await page.getByText("Page Not Found").waitFor();
});
});
6 changes: 3 additions & 3 deletions app/e2e-tests/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getServiceUrl(): string {

export async function loadHomepage(page: Page): Promise<void> {
await page.goto(getServiceUrl());
await page.waitForSelector("text=Presentation Rules Editor");
await page.getByText("Presentation Rules Editor").waitFor();
}

export async function openIModelBrowser(page: Page): Promise<void> {
Expand All @@ -21,14 +21,14 @@ export async function openIModelBrowser(page: Page): Promise<void> {

export async function openTestIModel(page: Page): Promise<void> {
await page.goto(`${getServiceUrl()}/open-imodel?snapshot=Baytown.bim`);
await page.waitForSelector("id=app-loader", { state: "detached" });
await page.locator("id=app-loader").waitFor({ state: "detached" });
}

export async function openDemoIModel(page: Page): Promise<void> {
const iTwinId = "b27dc251-0e53-4a36-9a38-182fc309be07";
const iModelId = "f30566da-8fdf-4cba-b09a-fd39f5397ae6";
await page.goto(`${getServiceUrl()}/open-imodel?iTwinId=${iTwinId}&iModelId=${iModelId}`);
await page.waitForSelector("id=app-loader", { state: "detached" });
await page.locator("id=app-loader").waitFor({ state: "detached" });
}

export function getWidget(page: Page, widget: string): Locator {
Expand Down
Loading

0 comments on commit 69c8751

Please sign in to comment.