Skip to content

Commit 6f7b5f5

Browse files
test: added hosting with launch test case for deploy
1 parent 57af772 commit 6f7b5f5

File tree

1 file changed

+42
-21
lines changed

1 file changed

+42
-21
lines changed

test/unit/commands/app/deploy.test.ts

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const region: { cma: string; cda: string; name: string } =
1111
const developerHubBaseUrl = getDeveloperHubUrl();
1212

1313
describe("app:deploy", () => {
14-
describe("Deploy an with custom hosting", () => {
14+
describe("Deploy an app with custom hosting", () => {
1515
test
1616
.stdout({ print: process.env.PRINT === "true" || false })
1717
.stub(ux.action, "stop", () => {})
@@ -22,7 +22,7 @@ describe("app:deploy", () => {
2222
App: mock.apps[1].name,
2323
Organization: mock.organizations[0].name,
2424
"hosting types": "Custom Hosting",
25-
"app-url": "https://example.com",
25+
appUrl: "https://example.com",
2626
};
2727
return (cases as Record<string, any>)[prompt.name];
2828
})
@@ -35,40 +35,61 @@ describe("app:deploy", () => {
3535
api
3636
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
3737
.reply(200, {
38-
data: mock.apps,
38+
data: mock.apps2,
3939
})
4040
)
4141
.nock(`https://${developerHubBaseUrl}`, (api) =>
42-
api.put(`/manifests/${mock.apps[1].uid}`).reply(200, {
43-
data: mock.apps,
44-
})
42+
api.put(`/manifests/${mock.apps2[1].uid}`).reply(200, mock.deploy_custom_host)
4543
)
46-
.nock(`https://${developerHubBaseUrl}`, (api) =>
44+
.command(["app:deploy"])
45+
.do(({ stdout }) => {
46+
expect(stdout).to.contain(
47+
$t(messages.APP_DEPLOYED, { app: mock.apps[1].name })
48+
);
49+
})
50+
.it("should deploy the app with custom hosting");
51+
});
52+
53+
describe("Deploy an app with Hosting with Launch with existing project", () => {
54+
test
55+
.stdout({ print: process.env.PRINT === "true" || false })
56+
.stub(ux.action, "stop", () => {})
57+
.stub(ux.action, "start", () => {})
58+
.stub(cliux, "inquire", async (...args: any) => {
59+
const [prompt]: any = args;
60+
const cases = {
61+
App: mock.apps2[1].name,
62+
Organization: mock.organizations[0].name,
63+
"hosting types": "Hosting with Launch",
64+
"provider": "launch",
65+
"selected_launch_project":"existing",
66+
"deployment_url": "https://example.com",
67+
"environment_uid": "environment_uid",
68+
"project_uid": "project_uid",
69+
};
70+
return (cases as Record<string, any>)[prompt.name];
71+
})
72+
.nock(region.cma, (api) =>
4773
api
48-
.patch(`/manifests/${mock.apps[1].uid}/hosting/disconnect`)
49-
.reply(200, {
50-
data: mock.apps,
51-
})
74+
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
75+
.reply(200, { organizations: mock.organizations })
5276
)
5377
.nock(`https://${developerHubBaseUrl}`, (api) =>
5478
api
55-
.put(`/manifests/${mock.apps[1].uid}/hosting`, {
56-
hosting: {
57-
provider: "external",
58-
deployment_url: "https://example.com",
59-
},
60-
uid: mock.apps[1].uid,
61-
})
79+
.get("/manifests?limit=50&asc=name&include_count=true&skip=0")
6280
.reply(200, {
63-
data: mock.apps,
81+
data: mock.apps2,
6482
})
6583
)
84+
.nock(`https://${developerHubBaseUrl}`, (api) =>
85+
api.put(`/manifests/${mock.apps2[1].uid}`).reply(200, mock.deploy_launch_host)
86+
)
6687
.command(["app:deploy"])
6788
.do(({ stdout }) => {
6889
expect(stdout).to.contain(
69-
$t(messages.APP_DEPLOYED, { app: mock.apps[1].name })
90+
$t(messages.APP_DEPLOYED, { app: mock.apps2[1].name })
7091
);
7192
})
72-
.it("should deploy the app with custom hosting");
93+
.it("should deploy the app with Hosting with Launch with existing project");
7394
});
7495
});

0 commit comments

Comments
 (0)