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

feat(arcgis): support of arcgis auth and content #343

Merged
merged 5 commits into from
Jan 17, 2024
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
1 change: 0 additions & 1 deletion .env

This file was deleted.

1 change: 1 addition & 0 deletions .env-template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_ARCGIS_REST_CLIENT_ID=abcd
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
build/
coverage/
.env
28 changes: 28 additions & 0 deletions __mocks__/@esri/arcgis-rest-portal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const mockContent = {
items: [
{
id: "new-york",
name: "NewYork.slpk",
url: "https://123.com",
created: 123456,
type: "Scene Service",
typeKeywords: "This is a Hosted Service",
title: "New York",
token: "token-https://123.com",
},
{
id: "turanga-library",
name: "TurangaLibrary.slpk",
url: "https://456.com",
created: 123457,
type: "Scene Service",
typeKeywords: "This is a Hosted Service",
title: "Turanga Library",
token: "token-https://456.com",
},
],
};

export const getUserContent = async (authentication) => {
return mockContent;
};
31 changes: 31 additions & 0 deletions __mocks__/@esri/arcgis-rest-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const mockEmailExpected = "[email protected]";
const mockSessionExpected = '{"usermail": "usermail"}';
const mockTokenExpectedPrefix = "token-";

const session = {
usermail: mockEmailExpected,
serialize: () => {
return mockSessionExpected;
},
getUser: async () => {
return { email: mockEmailExpected };
},
getToken: async (url: string) => {
return mockTokenExpectedPrefix + url;
},
};

export class ArcGISIdentityManager {
static beginOAuth2 = async () => {
return session;
};
static completeOAuth2 = async () => {
return;
};
static destroy = async () => {
return;
};
static deserialize = () => {
return session;
};
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"author": "",
"license": "ISC",
"dependencies": {
"@esri/arcgis-rest-auth": "^3.7.0",
"@esri/arcgis-rest-request": "^4.2.0",
"@esri/arcgis-rest-portal": "^4.4.0",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.17",
Expand Down
3 changes: 3 additions & 0 deletions public/icons/import.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/icons/logout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/esri.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ const THEMES: AppThemes = {
validateTileOk: color_brand_secondary_dark,
validateTileWarning: color_accent_tertiary,
filtrationImage: color_brand_quaternary,
actionIconButtonDisabledColor: color_canvas_primary,
actionIconButtonDisabledBG: dim_canvas_primary,
actionIconButtonTextDisabledColor: dim_canvas_primary,
actionIconButtonTextDisabledColorHover: dim_brand_tertinary,
logoutButtonTextColor: dim_canvas_primary,
logoutButtonIconColorHover: dim_brand_tertinary,
esriImageColor: color_canvas_secondary_inverted,
switchDisabledBackground: hilite_canvas_primary,
switchDisabledBackgroundHovered: dim_canvas_primary,
switchCheckedBackground: color_brand_tertiary,
Expand Down Expand Up @@ -112,6 +119,13 @@ const THEMES: AppThemes = {
validateTileOk: color_brand_secondary,
validateTileWarning: color_accent_primary,
filtrationImage: color_canvas_secondary,
actionIconButtonDisabledColor: color_canvas_secondary,
actionIconButtonDisabledBG: `${color_brand_tertiary}66`,
actionIconButtonTextDisabledColor: `${color_brand_tertiary}66`,
actionIconButtonTextDisabledColorHover: color_brand_tertiary,
logoutButtonTextColor: color_brand_quaternary,
logoutButtonIconColorHover: color_brand_tertiary,
esriImageColor: `${color_brand_tertiary}66`,
switchDisabledBackground: dim_canvas_secondary,
switchDisabledBackgroundHovered: color_canvas_secondary_inverted,
switchCheckedBackground: color_brand_tertiary,
Expand Down Expand Up @@ -152,6 +166,7 @@ export const App = () => {
<Route path={"dashboard"} element={<Pages.Dashboard />} />
<Route path={"viewer"} element={<Pages.ViewerApp />} />
<Route path={"debug"} element={<Pages.DebugApp />} />
<Route path={"auth"} element={<Pages.AuthApp />} />
<Route
path={"compare-across-layers"}
element={
Expand Down
52 changes: 52 additions & 0 deletions src/components/action-icon-button/action-icon-button.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { ButtonSize } from "../../types";
import { renderWithTheme } from "../../utils/testing-utils/render-with-theme";
import PlusIcon from "../../../public/icons/plus.svg";
import { ActionIconButton } from "../action-icon-button/action-icon-button";

const onClickMock = jest.fn();

const callRender = (renderFunc, props = {}) => {
return renderFunc(
<ActionIconButton
Icon={PlusIcon}
style="disabled"
size={ButtonSize.Small}
onClick={onClickMock}
{...props}
/>
);
};

describe("ActionIconButton", () => {
it("Should render small Plus icon in the button", () => {
const { container } = callRender(renderWithTheme, {
children: "Test Button",
});
expect(container).toBeInTheDocument();
const button = screen.getByText("Test Button");
const buttonHeight = getComputedStyle(
button.previousSibling as Element
).getPropertyValue("height");
expect(buttonHeight).toEqual("24px");

userEvent.click(button);
expect(onClickMock).toHaveBeenCalled();
});

it("Should render Big Plus icon in the button", () => {
const { container } = callRender(renderWithTheme, {
children: "Test Button",
size: ButtonSize.Big,
});
expect(container).toBeInTheDocument();
const button = screen.getByText("Test Button");
const buttonHeight = getComputedStyle(
button.previousSibling as Element
).getPropertyValue("height");
expect(buttonHeight).toEqual("40px");
userEvent.click(button);
expect(onClickMock).toHaveBeenCalled();
});
});
Loading