Skip to content

Commit 5e575e0

Browse files
authored
Merge pull request #23 from Fullscript/platform_feature
feat(app): render platform experience (FS Embed) in iframe
2 parents dc4e2a7 + 76f1982 commit 5e575e0

File tree

3 files changed

+53
-32
lines changed

3 files changed

+53
-32
lines changed

src/feature/featurePath.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
type FeaturePaths = "/treatment_plans/new";
1+
type FeaturePaths = "/treatment_plans/new" | "/embed/entry";
22

33
const FEATURE_PATHS: { [key: string]: FeaturePaths } = {
44
treatmentPlan: "/treatment_plans/new",
5+
platform: "/embed/entry",
56
};
67

78
export { FeaturePaths, FEATURE_PATHS };

src/feature/featureType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { EventListenerFunction } from "./eventType";
22

33
const FEATURE_TYPES = {
44
treatmentPlan: "treatmentPlan",
5+
platform: "platform",
56
};
67

78
type FeatureType = keyof typeof FEATURE_TYPES;
@@ -19,7 +20,7 @@ type PatientOptions = {
1920
};
2021
type TreatmentPlanOptions = { patient?: PatientOptions; secretToken: string };
2122

22-
type FeatureOptions<F extends FeatureType> = F extends "treatmentPlan"
23+
type FeatureOptions<F extends FeatureType> = F extends "treatmentPlan" | "platform"
2324
? TreatmentPlanOptions
2425
: Record<any, never>;
2526

src/feature/featureUtil.spec.ts

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FeatureOptions } from "./featureType";
44
import { getFeatureURL } from "./featureUtil";
55

66
describe("getFeatureUrl", () => {
7-
let mockFeatureOptions: FeatureOptions<"treatmentPlan">;
7+
let mockFeatureOptions: FeatureOptions<"treatmentPlan" | "platform">;
88
let mockFullscriptOptions: FullscriptOptions;
99
let mockFrameId: string;
1010
const mockDataToken = "random+data_token";
@@ -31,39 +31,58 @@ describe("getFeatureUrl", () => {
3131
mockFrameId = "uuid";
3232
});
3333

34-
it("returns the proper url", async () => {
35-
const url = await getFeatureURL(
36-
"treatmentPlan",
37-
mockFeatureOptions,
38-
mockFullscriptOptions,
39-
mockFrameId
40-
);
34+
describe("feature type", () => {
35+
it("returns the proper url when the feature type is 'treatmentPlan'", async () => {
36+
const url = await getFeatureURL(
37+
"treatmentPlan",
38+
mockFeatureOptions,
39+
mockFullscriptOptions,
40+
mockFrameId
41+
);
4142

42-
expect(url).toEqual(
43-
`https://us-snd.fullscript.io/api/embeddable/session/treatment_plans/new?data_token=${encodeURIComponent(
44-
mockDataToken
45-
)}&secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
46-
);
43+
expect(url).toEqual(
44+
`https://us-snd.fullscript.io/api/embeddable/session/treatment_plans/new?data_token=${encodeURIComponent(
45+
mockDataToken
46+
)}&secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
47+
);
48+
});
49+
50+
it("returns the proper url when the feature type is 'platform'", async () => {
51+
const url = await getFeatureURL(
52+
"platform",
53+
mockFeatureOptions,
54+
mockFullscriptOptions,
55+
mockFrameId
56+
);
57+
58+
expect(url).toEqual(
59+
`https://us-snd.fullscript.io/api/embeddable/session/embed/entry?data_token=${encodeURIComponent(
60+
mockDataToken
61+
)}&secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
62+
);
63+
});
4764
});
4865

49-
it("returns proper custom url if domain is present", async () => {
50-
const customDomain = "https://staging.r.fullscript.io";
51-
mockFullscriptOptions = {
52-
...mockFullscriptOptions,
53-
domain: customDomain,
54-
};
66+
describe("custome domain", () => {
67+
it("returns proper custom url if domain is present", async () => {
68+
const customDomain = "https://staging.r.fullscript.io";
69+
mockFullscriptOptions = {
70+
...mockFullscriptOptions,
71+
domain: customDomain,
72+
};
5573

56-
const url = await getFeatureURL(
57-
"treatmentPlan",
58-
mockFeatureOptions,
59-
mockFullscriptOptions,
60-
mockFrameId
61-
);
74+
const url = await getFeatureURL(
75+
"treatmentPlan",
76+
mockFeatureOptions,
77+
mockFullscriptOptions,
78+
mockFrameId
79+
);
6280

63-
expect(url).toEqual(
64-
`${customDomain}/api/embeddable/session/treatment_plans/new?data_token=${encodeURIComponent(
65-
mockDataToken
66-
)}&secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
67-
);
81+
expect(url).toEqual(
82+
`${customDomain}/api/embeddable/session/treatment_plans/new?data_token=${encodeURIComponent(
83+
mockDataToken
84+
)}&secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
85+
);
86+
});
6887
});
6988
});

0 commit comments

Comments
 (0)