1+ import { expect } from 'chai'
2+ import * as dotenv from 'dotenv'
3+ import { Hosting } from '../../types/app/hosting'
4+ dotenv . config ( )
5+ let uploadUid = ''
6+ let deploymentUid = ''
7+ export function hosting ( hosting : Hosting ) {
8+ describe ( 'Hosting api' , ( ) => {
9+ test ( 'create upload url' , done => {
10+ hosting . createUploadUrl ( )
11+ . then ( ( response ) => {
12+ uploadUid = response . upload_uid
13+ expect ( response . upload_uid ) . to . not . equal ( undefined )
14+ expect ( response . form_fields ) . to . not . equal ( undefined )
15+ expect ( response . upload_url ) . to . not . equal ( undefined )
16+ expect ( response . expires_in ) . to . not . equal ( undefined )
17+ done ( )
18+ } )
19+ . catch ( done )
20+ } )
21+
22+ test ( 'isEnable hosting' , done => {
23+ hosting . isEnable ( )
24+ . then ( ( response ) => {
25+ expect ( response . enabled ) . to . not . equal ( false )
26+ done ( )
27+ } )
28+ . catch ( done )
29+ } )
30+ test ( 'test latest live deployment for apps hosting' , done => {
31+ hosting . latestLiveDeployment ( )
32+ . then ( ( response ) => {
33+ expect ( response ) . to . not . equal ( undefined )
34+ done ( )
35+ } )
36+ . catch ( done )
37+ } )
38+
39+ test ( 'test enable apps hosting details' , done => {
40+ hosting . enable ( )
41+ . then ( ( response ) => {
42+ expect ( response . enabled ) . to . not . equal ( true )
43+ done ( )
44+ } )
45+ . catch ( done )
46+ } )
47+
48+ test ( 'test disable apps hosting details' , done => {
49+ hosting . disable ( )
50+ . then ( ( response ) => {
51+ expect ( response . enabled ) . to . not . equal ( false )
52+ done ( )
53+ } )
54+ . catch ( done )
55+ } )
56+ } )
57+ }
58+
59+ export function deployment ( hosting : Hosting ) {
60+ describe ( 'deployment api' , ( ) => {
61+ test ( 'create deployment' , done => {
62+ hosting . deployment ( ) . create ( { uploadUid, fileType : 'SOURCE' } )
63+ . then ( ( response ) => {
64+ deploymentUid = response . uid
65+ expect ( response . deployment_number ) . to . not . equal ( undefined )
66+ expect ( response . deployment_url ) . to . not . equal ( undefined )
67+ expect ( response . environment ) . to . not . equal ( undefined )
68+ expect ( response . uid ) . to . not . equal ( undefined )
69+ expect ( response . urlPath ) . to . not . equal ( undefined )
70+ done ( )
71+ } )
72+ . catch ( done )
73+ } )
74+ test ( 'find all deployment' , done => {
75+ hosting . deployment ( ) . findAll ( )
76+ . then ( ( response ) => {
77+ response . items . forEach ( deployment => {
78+ expect ( deployment . deployment_number ) . to . not . equal ( undefined )
79+ expect ( deployment . deployment_url ) . to . not . equal ( undefined )
80+ expect ( deployment . environment ) . to . not . equal ( undefined )
81+ expect ( deployment . uid ) . to . not . equal ( undefined )
82+ expect ( deployment . urlPath ) . to . not . equal ( undefined )
83+ } )
84+ done ( )
85+ } )
86+ . catch ( done )
87+ } )
88+ test ( 'test get deployment from uid for app hosting' , done => {
89+ hosting . deployment ( deploymentUid ) . fetch ( )
90+ . then ( ( response ) => {
91+ expect ( response . deployment_number ) . to . not . equal ( undefined )
92+ expect ( response . deployment_url ) . to . not . equal ( undefined )
93+ expect ( response . environment ) . to . not . equal ( undefined )
94+ expect ( response . uid ) . to . not . equal ( undefined )
95+ expect ( response . urlPath ) . to . not . equal ( undefined )
96+ done ( )
97+ } )
98+ . catch ( done )
99+ } )
100+
101+ test ( 'test get deployment logs for app hosting' , done => {
102+ hosting . deployment ( deploymentUid ) . logs ( )
103+ . then ( ( response ) => {
104+ for ( const i in response ) {
105+ const deploymentLogs = response [ i ]
106+ expect ( deploymentLogs . message ) . to . not . equal ( undefined )
107+ expect ( deploymentLogs . stage ) . to . not . equal ( undefined )
108+ expect ( deploymentLogs . timestamp ) . to . not . equal ( undefined )
109+ }
110+ done ( )
111+ } )
112+ . catch ( done )
113+ } )
114+
115+ test ( 'test get deployment signed download url for app hosting' , done => {
116+ hosting . deployment ( deploymentUid ) . signedDownloadUrl ( )
117+ . then ( ( response ) => {
118+ expect ( response . download_url ) . to . not . equal ( undefined )
119+ expect ( response . expires_in ) . to . not . equal ( undefined )
120+ done ( )
121+ } )
122+ . catch ( done )
123+ } )
124+ } )
125+ }
0 commit comments