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

Demo console banner #78

Merged
merged 4 commits into from
Mar 2, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ concurrency: preview-${{ github.ref }}
on:
workflow_dispatch:
pull_request:
branches: [project-demo-v1]
branches: ['*demo*']

jobs:
deploy-preview:
Expand Down
29 changes: 29 additions & 0 deletions demo-v1/src/components/Alert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ReactElement, MouseEventHandler } from "react";
import { LinkButton } from "./Components";

function Alert({
title,
onConfirm,
}: {
title: string | ReactElement;
onConfirm: MouseEventHandler<HTMLButtonElement>;
}) {
return (
<div
style={{
backgroundColor: "white",
border: "2px solid #CBD6E2",
padding: "10px",
display: "flex",
fontSize: "13px",
}}
>
{title}
<LinkButton use="transparent-on-primary" onClick={onConfirm}>
&times;
</LinkButton>
</div>
);
}

export default Alert;
23 changes: 19 additions & 4 deletions demo-v1/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useCti } from "../hooks/useCti";
import { useCallDurationTimer } from "../hooks/useTimer";
import { WHITE } from "../visitor-ui-component-library/theme/ColorConstants";
import { ScreenNames } from "../types/ScreenTypes";
import Alert from "./Alert";

export const screens = [
LoginScreen,
Expand All @@ -40,6 +41,7 @@ function App() {
const [dialNumber, setDialNumber] = useState("+1");
const [notes, setNotes] = useState("");
const { callDurationString, startTimer, stopTimer } = useCallDurationTimer();
const [showAlert, setShowAlert] = useState(true);

const handleNextScreen = () => {
if (screenIndex === screens.length - 1) {
Expand All @@ -66,17 +68,21 @@ function App() {

const handleEndCall = () => {
stopTimer();
cti.callCompleted({
engagementId,
});
handleNavigateToScreen(ScreenNames.CallEnded);
};

const handleSaveCall = () => {
resetInputs();
cti.callCompleted({
engagementId,
});
handleNavigateToScreen(ScreenNames.Keypad);
};

const hideAlert = () => {
setShowAlert(false);
};

const screenComponent = useMemo(() => {
const Component = screens[screenIndex];
if (!Component) {
Expand Down Expand Up @@ -116,11 +122,20 @@ function App() {
style={{
backgroundColor: "#f5f8fa",
color: "#516f90",
minWidth: "400px",
width: "400px",
minHeight: "600px",
display: "flex",
flexDirection: "column",
justifyContent: "space-between",
}}
>
{screenComponent}
{showAlert && (
<Alert
title="Open your console to see the incoming and outgoing messages with HubSpot."
onConfirm={hideAlert}
/>
)}
</div>
</ThemeProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion demo-v1/src/components/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const LinkButton = styled(VizExButton).attrs((props) => ({
padding: 0;
`;

export const RoundedButton = styled(Button).attrs((props) => ({
export const RoundedButton = styled(VizExButton).attrs((props) => ({
disabled: props.disabled,
}))`
border-radius: 25px;
Expand Down
38 changes: 38 additions & 0 deletions demo-v1/test/spec/components/App-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { screen, waitForElementToBeRemoved } from "@testing-library/react";
import App from "../../../src/components/App";
import { renderWithWrapper } from "../../render";

describe("App", () => {
it("Shows login screen", () => {
renderWithWrapper(<App />);
expect(
screen.getByText("Log into your calling account")
).toBeInTheDocument();
});

it("Shows alert", () => {
renderWithWrapper(<App />);
expect(
screen.getByText(
/Open your console to see the incoming and outgoing messages with HubSpot./i
)
).toBeInTheDocument();
});

it("Hides alert when confirm button is clicked", async () => {
renderWithWrapper(<App />);
const confirmAlertButton = screen.getByRole("button", { name: /×/i });
confirmAlertButton.click();

await waitForElementToBeRemoved(() =>
screen.getByText(
/Open your console to see the incoming and outgoing messages with HubSpot./i
)
);
expect(
screen.queryByText(
/Open your console to see the incoming and outgoing messages with HubSpot./i
)
).not.toBeInTheDocument();
});
});
4 changes: 2 additions & 2 deletions demo-v1/test/spec/components/screens/KeypadScreen-test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { fireEvent, waitFor } from "@testing-library/react";
import { fireEvent } from "@testing-library/react";
import KeypadScreen, {
validateKeypadInput,
} from "../../../../src/components/screens/KeypadScreen";
import { ScreenNames } from "../../../../src/types/ScreenTypes";
import { renderWithWrapper } from "../../../render";

const noop = () => {};
const noop = (..._args: any[]) => {};

const cti = {
userLoggedOut: noop,
Expand Down
2 changes: 1 addition & 1 deletion demo-v1/test/spec/components/screens/LoginScreen-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fireEvent } from "@testing-library/react";
import LoginScreen from "../../../../src/components/screens/LoginScreen";
import { renderWithWrapper } from "../../../render";

const noop = () => {};
const noop = (..._args: any[]) => {};

const cti = {
userLoggedIn: noop,
Expand Down