Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/create-imodel-react",
"comment": "Updated create-imodel-react to itwin-react V3",
"type": "major"
Comment thread
veekeys marked this conversation as resolved.
Outdated
}
],
"packageName": "@itwin/create-imodel-react"
}
94 changes: 87 additions & 7 deletions common/config/rush/pnpm-lock.yaml

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

6 changes: 4 additions & 2 deletions packages/modules/create-imodel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
"clean": "rimraf cjs esm"
},
"dependencies": {
"@itwin/itwinui-react": "^2.12.18"
"@itwin/itwinui-react": "^3.18.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "~17.1.0",
"@testing-library/react": "^11.1.0",
"@testing-library/dom": "~10.4.0",
Comment thread
veekeys marked this conversation as resolved.
Outdated
"@testing-library/jest-dom": "~6.6.3",
Comment thread
veekeys marked this conversation as resolved.
Outdated
"@testing-library/react": "^16.2.0",
"@types/jest": "^27.5.1",
"@types/node": "^14.14.35",
"@types/react": "^18.3.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { fireEvent, render } from "@testing-library/react";
import "@testing-library/jest-dom";

import { act, fireEvent, render, waitFor } from "@testing-library/react";
import React from "react";

import { BaseIModelPage } from "./BaseIModel";
Expand All @@ -12,7 +14,7 @@ describe("BaseIModel", () => {
jest.clearAllMocks();
});

it("should show base page", () => {
it("should show base page", async () => {
const actionMock = jest.fn();
const closeMock = jest.fn();

Expand All @@ -37,14 +39,14 @@ describe("BaseIModel", () => {
const confirmButton = container.querySelector(
".iac-button-bar button:first-child"
) as HTMLButtonElement;
expect(confirmButton.disabled).toBe(true);
expect(confirmButton).toHaveAttribute("aria-disabled", "true");
expect(confirmButton.textContent).toBe("Create");
confirmButton.click();
await act(() => fireEvent.click(confirmButton));
expect(actionMock).not.toHaveBeenCalled();
const cancelButton = container.querySelector(
".iac-button-bar button:last-child"
) as HTMLButtonElement;
cancelButton.click();
await act(() => fireEvent.click(cancelButton));
expect(closeMock).toHaveBeenCalled();
});

Expand All @@ -70,7 +72,7 @@ describe("BaseIModel", () => {
const confirmButton = container.querySelector(
".iac-button-bar button:first-child"
) as HTMLButtonElement;
expect(confirmButton.disabled).toBe(true);
expect(confirmButton).toHaveAttribute("aria-disabled", "true");
expect(confirmButton.textContent).toBe("Create");

expect(container.querySelector(".test-extent-map")).toBeTruthy();
Expand All @@ -88,12 +90,16 @@ describe("BaseIModel", () => {
const name = container.querySelector(
".iac-inputs-container input"
) as HTMLInputElement;
fireEvent.change(name, { target: { value: new Array(260).join("a") } });
await waitFor(async () =>
fireEvent.change(name, {
target: { value: new Array(260).join("a") },
})
);
getByText("The value exceeds allowed 255 characters.");
const confirmButton = container.querySelector(
".iac-button-bar button:first-child"
) as HTMLButtonElement;
expect(confirmButton.disabled).toBe(true);
expect(confirmButton).toHaveAttribute("aria-disabled", "true");
});

it("should show base page with filled values", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { fireEvent, render } from "@testing-library/react";
import "@testing-library/jest-dom";

import { act, fireEvent, render, screen } from "@testing-library/react";
import React from "react";

import { IModelContext, InnerIModelContext } from "../context/imodel-context";
Expand Down Expand Up @@ -41,22 +43,28 @@ describe("ButtonBar", () => {
it("should show buttons with value from context API", async () => {
const { getByText } = render(renderFunction());

fireEvent.click(getByText(innerContextValue.confirmButtonText));
await act(() =>
fireEvent.click(getByText(innerContextValue.confirmButtonText))
);
expect(callbackFun).toHaveBeenCalled();
});

it("should disable create button if isPrimaryButtonDisabled context prop is true", async () => {
const { getByText } = render(
renderFunction({ isPrimaryButtonDisabled: true })
);
render(renderFunction({ isPrimaryButtonDisabled: true }));

const buttonConfirm = getByText(
innerContextValue.confirmButtonText
) as HTMLInputElement;
const buttonCancel = getByText(
innerContextValue.cancelButtonText
) as HTMLInputElement;
expect(buttonConfirm.closest("button")?.disabled).toBe(true);
expect(buttonCancel.closest("button")?.disabled).toBe(false);
const buttonConfirm = (await screen.findByRole("button", {
name: innerContextValue.confirmButtonText,
})) as HTMLButtonElement;
const buttonCancel = (await screen.findByRole("button", {
name: innerContextValue.cancelButtonText,
})) as HTMLButtonElement;
expect(buttonConfirm.closest("button")).toHaveAttribute(
"aria-disabled",
"true"
);
expect(buttonCancel.closest("button")).not.toHaveAttribute(
"aria-disabled",
"true"
);
});
});
Loading