Skip to content

Commit 8463783

Browse files
authored
Fix: issue with docs_enterprise_link call (#510)
* Add target="_blank" to signup links * Add missing trackEvent call * Add interaction tests for ExclusivityBanner * Add play function for 'not shown' test
1 parent a478304 commit 8463783

File tree

5 files changed

+97
-2
lines changed

5 files changed

+97
-2
lines changed

src/components/EnterpriseFeatureBadge/EnterpriseFeatureBadge.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const EnterpriseFeatureBadge: React.FC<
113113
<Button
114114
as="link"
115115
href="https://goteleport.com/signup/"
116+
target="_blank"
116117
className={styles.upsellLink}
117118
onClick={() =>
118119
trackEvent({

src/components/EnterpriseFeatureCallout/EnterpriseFeatureCallout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const EnterpriseFeatureCallout: React.FC<{
1717
{children && <>{children}</>}{" "}
1818
<a
1919
href="https://goteleport.com/signup/"
20+
target="_blank"
2021
onClick={() =>
2122
trackEvent({ event_name: "docs_enterprise_link", emitEvent })
2223
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { userEvent, within } from "@storybook/test";
3+
import { expect } from "@storybook/test";
4+
import ExclusivityBanner from "./ExclusivityBanner";
5+
import ExclusivityContext from "/src/components/ExclusivityBanner/context";
6+
import { collectEvents } from "/src/utils/analytics";
7+
8+
const meta: Meta<typeof ExclusivityBanner> = {
9+
title: "components/ExclusivityBanner",
10+
component: ExclusivityBanner,
11+
};
12+
13+
export default meta;
14+
type Story = StoryObj<typeof ExclusivityBanner>;
15+
16+
export const WithoutExclusivity: Story = {
17+
render: () => (
18+
<ExclusivityContext.Provider value={{ exclusiveFeature: null }}>
19+
<ExclusivityBanner emitEvent={collectEvents()} />
20+
</ExclusivityContext.Provider>
21+
),
22+
play: async ({ canvasElement, step }) => {
23+
const canvas = within(canvasElement);
24+
25+
await step("Verify exclusivity banner is not shown", async () => {
26+
expect(
27+
canvas.queryByText(/is available only with Teleport Enterprise/)
28+
).not.toBeInTheDocument();
29+
});
30+
},
31+
};
32+
33+
export const WithExclusivity: Story = {
34+
render: () => (
35+
<ExclusivityContext.Provider value={{ exclusiveFeature: "Desktop Access" }}>
36+
<ExclusivityBanner emitEvent={collectEvents()} />
37+
</ExclusivityContext.Provider>
38+
),
39+
play: async ({ canvasElement, step }) => {
40+
const canvas = within(canvasElement);
41+
42+
await step("Verify exclusivity banner is shown", async () => {
43+
expect(
44+
canvas.getByText(
45+
"Desktop Access is available only with Teleport Enterprise."
46+
)
47+
).toBeInTheDocument();
48+
49+
const signupLink = canvas.getByText("Start your free trial.");
50+
expect(signupLink).toBeInTheDocument();
51+
expect(signupLink).toHaveAttribute(
52+
"href",
53+
"https://goteleport.com/signup/"
54+
);
55+
});
56+
},
57+
};
58+
59+
export const ExclusivitySignupLinkClick: Story = {
60+
render: () => (
61+
<ExclusivityContext.Provider value={{ exclusiveFeature: "Machine ID" }}>
62+
<ExclusivityBanner emitEvent={collectEvents()} />
63+
</ExclusivityContext.Provider>
64+
),
65+
play: async ({ canvasElement, step }) => {
66+
const canvas = within(canvasElement);
67+
68+
await step("Click signup link in exclusivity banner", async () => {
69+
const signupLink = canvas.getByText("Start your free trial.");
70+
expect(signupLink).toBeInTheDocument();
71+
72+
await userEvent.click(signupLink);
73+
74+
expect((window as any).events).toHaveLength(1);
75+
expect((window as any).events[0]).toEqual({
76+
event: "docs_enterprise_link",
77+
});
78+
});
79+
},
80+
};

src/components/ExclusivityBanner/ExclusivityBanner.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import Button from "../Button";
44
import Icon from "../Icon";
55
import styles from "./ExclusivityBanner.module.css";
66
import ExclusivityContext from "./context";
7+
import { trackEvent } from "@site/src/utils/analytics";
78

89
const STORAGE_KEY = "exclusivity_banner_dismissed";
910

10-
const ExclusivityBanner: React.FC = () => {
11+
const ExclusivityBanner: React.FC<{
12+
emitEvent?: (name: string, params: any) => {};
13+
}> = ({ emitEvent }) => {
1114
const { exclusiveFeature } = useContext(ExclusivityContext);
1215
const [dismissed, setDismissed] = useState<boolean>(() => {
1316
// Initialize from localStorage
@@ -38,7 +41,16 @@ const ExclusivityBanner: React.FC = () => {
3841
<Icon size="sm-md" name="rocketLaunch" />
3942
<p>
4043
{exclusiveFeature} is available only with Teleport Enterprise.{" "}
41-
<a href="https://goteleport.com/signup/">
44+
<a
45+
href="https://goteleport.com/signup/"
46+
target="_blank"
47+
onClick={() =>
48+
trackEvent({
49+
event_name: "docs_enterprise_link",
50+
emitEvent,
51+
})
52+
}
53+
>
4254
Start your free trial.
4355
</a>
4456
</p>

src/components/Pages/Landing/LandingHero/LandingHero.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const LandingHero: React.FC<LandingHeroProps> = ({
4848
{exclusiveFeature} is available only with Teleport Enterprise.{" "}
4949
<a
5050
href="https://goteleport.com/signup/"
51+
target="_blank"
5152
onClick={() =>
5253
trackEvent({
5354
event_name: "docs_enterprise_link",

0 commit comments

Comments
 (0)