Skip to content

Commit

Permalink
Fix main branch precommit issues (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
hasys authored Nov 28, 2024
1 parent e129407 commit d36f7f5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
8 changes: 5 additions & 3 deletions ansible_ai_connect_admin_portal/__mocks__/monaco-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ const editor = {
create: () => {
return {
dispose: () => {},
}
};
},
defineTheme: function() {}
defineTheme: function () {},
};

const monaco = {
editor,
languages: {json: {jsonDefaults: { setDiagnosticsOptions: function () {}}}}
languages: {
json: { jsonDefaults: { setDiagnosticsOptions: function () {} } },
},
};

module.exports = monaco;
4 changes: 2 additions & 2 deletions ansible_ai_connect_admin_portal/__mocks__/monaco-yaml.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const monacoYaml = {
configureMonacoYaml: function () {}
};
configureMonacoYaml: function () {},
};

module.exports = monacoYaml;
2 changes: 1 addition & 1 deletion ansible_ai_connect_admin_portal/src/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function AppHeader(props: AppHeaderProps) {
<ToolbarItem>
<PageMastheadDropdown
id="account-menu"
icon={<UserCircleIcon/>}
icon={<UserCircleIcon />}
userName={userName}
>
<DropdownItem
Expand Down
9 changes: 7 additions & 2 deletions ansible_ai_connect_admin_portal/src/PageMastheadDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DropdownList,
DropdownItem,
} from "@patternfly/react-core";
import React from 'react';
import React from "react";
import { ReactNode, useCallback, useState } from "react";
import { useBreakpoint } from "@ansible/ansible-ui-framework";

Expand All @@ -32,7 +32,12 @@ export function PageMastheadDropdown(props: PageMastheadDropdownProps) {
id={id}
onSelect={onSelect}
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle ref={toggleRef} onClick={onToggle} isExpanded={isOpen} data-testid="page-masthead-dropdown__button">
<MenuToggle
ref={toggleRef}
onClick={onToggle}
isExpanded={isOpen}
data-testid="page-masthead-dropdown__button"
>
<Flex
alignItems={{ default: "alignItemsCenter" }}
flexWrap={{ default: "nowrap" }}
Expand Down
4 changes: 3 additions & 1 deletion ansible_ai_connect_admin_portal/src/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe("App", () => {
adminDashboardUrl={"http://admin_dashboard-url/"}
/>,
);
const accountMenu = await screen.findByTestId("page-masthead-dropdown__button");
const accountMenu = await screen.findByTestId(
"page-masthead-dropdown__button",
);
expect(accountMenu).toBeInTheDocument();
expect(accountMenu).toHaveTextContent("Batman");
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import { AppHeader } from "../AppHeader";
import { BrowserRouter } from 'react-router-dom';
import { BrowserRouter } from "react-router-dom";

describe("AppHeader", () => {
// Store the original 'location' object so that it can be restored for other tests.
Expand All @@ -23,9 +23,11 @@ describe("AppHeader", () => {
render(
<BrowserRouter>
<AppHeader userName={"Batman"} />
</BrowserRouter>
</BrowserRouter>,
);
const accountMenu = await screen.findByTestId(
"page-masthead-dropdown__button",
);
const accountMenu = await screen.findByTestId("page-masthead-dropdown__button");
expect(accountMenu).toBeInTheDocument();
expect(accountMenu).toHaveTextContent("Batman");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ describe("App", () => {
it("Rendering::With Username", async () => {
window.history.pushState({}, "Test page", "/console");
render(<AppDenied userName={"Batman"} hasSubscription={true} />);
const accountMenu = await screen.findByTestId("page-masthead-dropdown__button");
const accountMenu = await screen.findByTestId(
"page-masthead-dropdown__button",
);
expect(accountMenu).toBeInTheDocument();
expect(accountMenu).toHaveTextContent("Batman");
});

it("Rendering::Without Username", async () => {
window.history.pushState({}, "Test page", "/console");
render(<AppDenied hasSubscription={false} />);
const accountMenu = await screen.findByTestId("page-masthead-dropdown__button");
const accountMenu = await screen.findByTestId(
"page-masthead-dropdown__button",
);
expect(accountMenu).toBeInTheDocument();
expect(accountMenu).toHaveTextContent("UnknownUser");
});
Expand Down

0 comments on commit d36f7f5

Please sign in to comment.