@adobe/aio-cli-plugin-api-mesh 1.5.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,16 +81,16 @@ describe('delete command tests', () => {
81
81
  });
82
82
  });
83
83
 
84
- afterEach(() => {
85
- jest.restoreAllMocks();
86
- });
84
+ // afterEach(() => {
85
+ // jest.restoreAllMocks();
86
+ // });
87
87
 
88
88
  test('snapshot delete command description', () => {
89
89
  expect(DeleteCommand.description).toMatchInlineSnapshot(`"Delete the config of a given mesh"`);
90
90
  expect(DeleteCommand.args).toMatchInlineSnapshot(`undefined`);
91
91
  expect(DeleteCommand.flags).toMatchInlineSnapshot(`
92
- Object {
93
- "autoConfirmAction": Object {
92
+ {
93
+ "autoConfirmAction": {
94
94
  "allowNo": false,
95
95
  "char": "c",
96
96
  "default": false,
@@ -98,7 +98,7 @@ describe('delete command tests', () => {
98
98
  "parse": [Function],
99
99
  "type": "boolean",
100
100
  },
101
- "ignoreCache": Object {
101
+ "ignoreCache": {
102
102
  "allowNo": false,
103
103
  "char": "i",
104
104
  "default": false,
@@ -108,7 +108,7 @@ describe('delete command tests', () => {
108
108
  },
109
109
  }
110
110
  `);
111
- expect(DeleteCommand.aliases).toMatchInlineSnapshot(`Array []`);
111
+ expect(DeleteCommand.aliases).toMatchInlineSnapshot(`[]`);
112
112
  });
113
113
 
114
114
  test('should fail if mesh id is missing', async () => {
@@ -119,10 +119,10 @@ describe('delete command tests', () => {
119
119
  expect(err.message).toMatchInlineSnapshot(
120
120
  `"Unable to delete. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again."`,
121
121
  );
122
- expect(logSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
122
+ expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
123
123
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
124
- Array [
125
- Array [
124
+ [
125
+ [
126
126
  "Unable to delete. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again.",
127
127
  ],
128
128
  ]
@@ -137,13 +137,13 @@ describe('delete command tests', () => {
137
137
 
138
138
  expect(runResult).toBe('Delete cancelled');
139
139
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
140
- Array [
141
- Array [
140
+ [
141
+ [
142
142
  "Delete cancelled",
143
143
  ],
144
144
  ]
145
145
  `);
146
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
146
+ expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
147
147
  });
148
148
 
149
149
  test('should not ask for prompt if autoConfirmAction is set', async () => {
@@ -158,24 +158,24 @@ describe('delete command tests', () => {
158
158
  const runResult = await DeleteCommand.run();
159
159
 
160
160
  expect(runResult).toMatchInlineSnapshot(`
161
- Object {
161
+ {
162
162
  "status": "success",
163
163
  }
164
164
  `);
165
165
  expect(promptConfirm).not.toHaveBeenCalled();
166
166
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
167
- Array [
168
- Array [
167
+ [
168
+ [
169
169
  "Successfully deleted mesh %s",
170
170
  "mesh_id",
171
171
  ],
172
- Array [
172
+ [
173
173
  "Successfully unsubscribed API Key %s",
174
174
  "dummy_client_id",
175
175
  ],
176
176
  ]
177
177
  `);
178
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
178
+ expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
179
179
  });
180
180
 
181
181
  test('should fail if mesh delete fails', async () => {
@@ -189,15 +189,15 @@ describe('delete command tests', () => {
189
189
  ),
190
190
  );
191
191
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
192
- Array [
193
- Array [
192
+ [
193
+ [
194
194
  "mesh delete failed",
195
195
  ],
196
196
  ]
197
197
  `);
198
198
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
199
- Array [
200
- Array [
199
+ [
200
+ [
201
201
  "Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
202
202
  ],
203
203
  ]
@@ -215,19 +215,19 @@ describe('delete command tests', () => {
215
215
  ),
216
216
  );
217
217
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
218
- Array [
219
- Array [
218
+ [
219
+ [
220
220
  "Successfully deleted mesh %s",
221
221
  "mesh_id",
222
222
  ],
223
- Array [
223
+ [
224
224
  "unable to get api key",
225
225
  ],
226
226
  ]
227
227
  `);
228
228
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
229
- Array [
230
- Array [
229
+ [
230
+ [
231
231
  "Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
232
232
  ],
233
233
  ]
@@ -245,19 +245,19 @@ describe('delete command tests', () => {
245
245
  ),
246
246
  );
247
247
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
248
- Array [
249
- Array [
248
+ [
249
+ [
250
250
  "Successfully deleted mesh %s",
251
251
  "mesh_id",
252
252
  ],
253
- Array [
253
+ [
254
254
  "unsubscribe api failed",
255
255
  ],
256
256
  ]
257
257
  `);
258
258
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
259
- Array [
260
- Array [
259
+ [
260
+ [
261
261
  "Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
262
262
  ],
263
263
  ]
@@ -269,13 +269,13 @@ describe('delete command tests', () => {
269
269
 
270
270
  expect(initRequestId).toHaveBeenCalled();
271
271
  expect(runResult).toMatchInlineSnapshot(`
272
- Object {
272
+ {
273
273
  "status": "success",
274
274
  }
275
275
  `);
276
276
  expect(deleteMesh.mock.calls).toMatchInlineSnapshot(`
277
- Array [
278
- Array [
277
+ [
278
+ [
279
279
  "1234",
280
280
  "5678",
281
281
  "123456789",
@@ -284,8 +284,8 @@ describe('delete command tests', () => {
284
284
  ]
285
285
  `);
286
286
  expect(getApiKeyCredential.mock.calls).toMatchInlineSnapshot(`
287
- Array [
288
- Array [
287
+ [
288
+ [
289
289
  "1234",
290
290
  "5678",
291
291
  "123456789",
@@ -293,8 +293,8 @@ describe('delete command tests', () => {
293
293
  ]
294
294
  `);
295
295
  expect(unsubscribeCredentialFromMeshService.mock.calls).toMatchInlineSnapshot(`
296
- Array [
297
- Array [
296
+ [
297
+ [
298
298
  "1234",
299
299
  "5678",
300
300
  "123456789",
@@ -303,17 +303,17 @@ describe('delete command tests', () => {
303
303
  ]
304
304
  `);
305
305
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
306
- Array [
307
- Array [
306
+ [
307
+ [
308
308
  "Successfully deleted mesh %s",
309
309
  "mesh_id",
310
310
  ],
311
- Array [
311
+ [
312
312
  "Successfully unsubscribed API Key %s",
313
313
  "dummy_client_id",
314
314
  ],
315
315
  ]
316
316
  `);
317
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
317
+ expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
318
318
  });
319
319
  });
@@ -74,8 +74,8 @@ describe('describe command tests', () => {
74
74
  expect(DescribeCommand.description).toMatchInlineSnapshot(`"Get details of a mesh"`);
75
75
  expect(DescribeCommand.args).toMatchInlineSnapshot(`undefined`);
76
76
  expect(DescribeCommand.flags).toMatchInlineSnapshot(`
77
- Object {
78
- "ignoreCache": Object {
77
+ {
78
+ "ignoreCache": {
79
79
  "allowNo": false,
80
80
  "char": "i",
81
81
  "default": false,
@@ -85,7 +85,7 @@ describe('describe command tests', () => {
85
85
  },
86
86
  }
87
87
  `);
88
- expect(DescribeCommand.aliases).toMatchInlineSnapshot(`Array []`);
88
+ expect(DescribeCommand.aliases).toMatchInlineSnapshot(`[]`);
89
89
  });
90
90
 
91
91
  test('should error if describe api has failed', async () => {
@@ -99,8 +99,8 @@ describe('describe command tests', () => {
99
99
  ),
100
100
  );
101
101
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
102
- Array [
103
- Array [
102
+ [
103
+ [
104
104
  "Describe api failed Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
105
105
  ],
106
106
  ]
@@ -118,8 +118,8 @@ describe('describe command tests', () => {
118
118
  ),
119
119
  );
120
120
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
121
- Array [
122
- Array [
121
+ [
122
+ [
123
123
  "Unable to get mesh details. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
124
124
  ],
125
125
  ]
@@ -128,21 +128,11 @@ describe('describe command tests', () => {
128
128
 
129
129
  test('should error if mesh id is missing from describe api response', async () => {
130
130
  describeMesh.mockResolvedValueOnce({});
131
-
132
- const runResult = await DescribeCommand.run();
133
-
134
- expect(runResult).toBe(undefined);
135
- expect(logSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
136
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
137
- Array [
138
- Array [
139
- "Unable to get mesh details. Please check the details and try again. RequestId: dummy_request_id",
140
- Object {
141
- "exit": false,
142
- },
143
- ],
144
- ]
145
- `);
131
+ await DescribeCommand.run().catch(err => {
132
+ expect(err.message).toContain(
133
+ 'Unable to get mesh details. Please check the details and try again.',
134
+ );
135
+ });
146
136
  });
147
137
 
148
138
  test('should not fail if api key is missing from mesh details', async () => {
@@ -151,35 +141,35 @@ describe('describe command tests', () => {
151
141
  const runResult = await DescribeCommand.run();
152
142
 
153
143
  expect(runResult).toMatchInlineSnapshot(`
154
- Object {
144
+ {
155
145
  "meshId": "dummy_meshId",
156
146
  }
157
147
  `);
158
148
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
159
- Array [
160
- Array [
149
+ [
150
+ [
161
151
  "Successfully retrieved mesh details
162
152
  ",
163
153
  ],
164
- Array [
154
+ [
165
155
  "Org ID: %s",
166
156
  "1234",
167
157
  ],
168
- Array [
158
+ [
169
159
  "Project ID: %s",
170
160
  "5678",
171
161
  ],
172
- Array [
162
+ [
173
163
  "Workspace ID: %s",
174
164
  "123456789",
175
165
  ],
176
- Array [
166
+ [
177
167
  "Mesh ID: %s",
178
168
  "dummy_meshId",
179
169
  ],
180
170
  ]
181
171
  `);
182
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
172
+ expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
183
173
  });
184
174
 
185
175
  test('should succeed if valid details are provided', async () => {
@@ -192,44 +182,44 @@ describe('describe command tests', () => {
192
182
  selectedWorkspace.id,
193
183
  );
194
184
  expect(runResult).toMatchInlineSnapshot(`
195
- Object {
185
+ {
196
186
  "apiKey": "dummy_apiKey",
197
187
  "meshId": "dummy_meshId",
198
188
  }
199
189
  `);
200
190
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
201
- Array [
202
- Array [
191
+ [
192
+ [
203
193
  "Successfully retrieved mesh details
204
194
  ",
205
195
  ],
206
- Array [
196
+ [
207
197
  "Org ID: %s",
208
198
  "1234",
209
199
  ],
210
- Array [
200
+ [
211
201
  "Project ID: %s",
212
202
  "5678",
213
203
  ],
214
- Array [
204
+ [
215
205
  "Workspace ID: %s",
216
206
  "123456789",
217
207
  ],
218
- Array [
208
+ [
219
209
  "Mesh ID: %s",
220
210
  "dummy_meshId",
221
211
  ],
222
- Array [
212
+ [
223
213
  "API Key: %s",
224
214
  "dummy_apiKey",
225
215
  ],
226
- Array [
216
+ [
227
217
  "Mesh Endpoint: %s
228
218
  ",
229
219
  "https://graph.adobe.io/api/dummy_meshId/graphql?api_key=dummy_apiKey",
230
220
  ],
231
221
  ]
232
222
  `);
233
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
223
+ expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
234
224
  });
235
225
  });
@@ -80,15 +80,15 @@ describe('get command tests', () => {
80
80
  test('snapshot get command', () => {
81
81
  expect(GetCommand.description).toMatchInlineSnapshot(`"Get the config of a given mesh"`);
82
82
  expect(GetCommand.args).toMatchInlineSnapshot(`
83
- Array [
84
- Object {
83
+ [
84
+ {
85
85
  "name": "file",
86
86
  },
87
87
  ]
88
88
  `);
89
89
  expect(GetCommand.flags).toMatchInlineSnapshot(`
90
- Object {
91
- "ignoreCache": Object {
90
+ {
91
+ "ignoreCache": {
92
92
  "allowNo": false,
93
93
  "char": "i",
94
94
  "default": false,
@@ -98,7 +98,7 @@ describe('get command tests', () => {
98
98
  },
99
99
  }
100
100
  `);
101
- expect(GetCommand.aliases).toMatchInlineSnapshot(`Array []`);
101
+ expect(GetCommand.aliases).toMatchInlineSnapshot(`[]`);
102
102
  });
103
103
 
104
104
  test('should fail if mesh id is missing', async () => {
@@ -109,10 +109,10 @@ describe('get command tests', () => {
109
109
  expect(err.message).toMatchInlineSnapshot(
110
110
  `"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again."`,
111
111
  );
112
- expect(logSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
112
+ expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
113
113
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
114
- Array [
115
- Array [
114
+ [
115
+ [
116
116
  "Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again.",
117
117
  ],
118
118
  ]
@@ -128,10 +128,10 @@ describe('get command tests', () => {
128
128
  expect(err.message).toMatchInlineSnapshot(
129
129
  `"Unable to get mesh ID. Please check the details and try again. RequestId: dummy_request_id"`,
130
130
  );
131
- expect(logSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
131
+ expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
132
132
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
133
- Array [
134
- Array [
133
+ [
134
+ [
135
135
  "Unable to get mesh ID. Please check the details and try again. RequestId: dummy_request_id",
136
136
  ],
137
137
  ]
@@ -142,20 +142,11 @@ describe('get command tests', () => {
142
142
  test('should fail if mesh id is not found', async () => {
143
143
  getMesh.mockResolvedValueOnce(null);
144
144
 
145
- const runResult = await GetCommand.run();
146
-
147
- expect(runResult).toMatchInlineSnapshot(`undefined`);
148
- expect(logSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
149
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
150
- Array [
151
- Array [
152
- "Unable to get mesh with the ID dummy_meshId. Please check the mesh ID and try again. RequestId: dummy_request_id",
153
- Object {
154
- "exit": false,
155
- },
156
- ],
157
- ]
158
- `);
145
+ await GetCommand.run().catch(err => {
146
+ expect(err.message).toContain(
147
+ 'Unable to get mesh with the ID dummy_meshId. Please check the mesh ID and try again.',
148
+ );
149
+ });
159
150
  });
160
151
 
161
152
  test('should fail if get mesh method failed', async () => {
@@ -169,15 +160,15 @@ describe('get command tests', () => {
169
160
  ),
170
161
  );
171
162
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
172
- Array [
173
- Array [
163
+ [
164
+ [
174
165
  "get mesh failed",
175
166
  ],
176
167
  ]
177
168
  `);
178
169
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
179
- Array [
180
- Array [
170
+ [
171
+ [
181
172
  "Unable to get mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
182
173
  ],
183
174
  ]
@@ -195,19 +186,19 @@ describe('get command tests', () => {
195
186
  expect(initRequestId).toHaveBeenCalled();
196
187
  expect(runResult).toEqual({ meshId: 'dummy_meshId', mesh: mockGetMeshConfig });
197
188
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
198
- Array [
199
- Array [
189
+ [
190
+ [
200
191
  "Successfully retrieved mesh %s",
201
192
  "{
202
- \\"meshId\\": \\"dummy_meshId\\",
203
- \\"mesh\\": {
204
- \\"meshConfig\\": {
205
- \\"sources\\": [
193
+ "meshId": "dummy_meshId",
194
+ "mesh": {
195
+ "meshConfig": {
196
+ "sources": [
206
197
  {
207
- \\"name\\": \\"<api_name>\\",
208
- \\"handler\\": {
209
- \\"graphql\\": {
210
- \\"endpoint\\": \\"<gql_endpoint>\\"
198
+ "name": "<api_name>",
199
+ "handler": {
200
+ "graphql": {
201
+ "endpoint": "<gql_endpoint>"
211
202
  }
212
203
  }
213
204
  }
@@ -216,13 +207,13 @@ describe('get command tests', () => {
216
207
  }
217
208
  }",
218
209
  ],
219
- Array [
210
+ [
220
211
  "Successfully wrote mesh to file %s",
221
212
  "mesh.json",
222
213
  ],
223
214
  ]
224
215
  `);
225
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
216
+ expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
226
217
  });
227
218
 
228
219
  test('should write to file if file argument is provided', async () => {
@@ -242,27 +233,27 @@ describe('get command tests', () => {
242
233
 
243
234
  expect(runResult).toEqual({ meshId: 'dummy_meshId', mesh: mockGetMeshConfig });
244
235
  expect(writeFile.mock.calls).toMatchInlineSnapshot(`
245
- Array [
246
- Array [
236
+ [
237
+ [
247
238
  "./mesh.json",
248
239
  "{}",
249
240
  ],
250
241
  ]
251
242
  `);
252
243
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
253
- Array [
254
- Array [
244
+ [
245
+ [
255
246
  "Successfully retrieved mesh %s",
256
247
  "{
257
- \\"meshId\\": \\"dummy_meshId\\",
258
- \\"mesh\\": {
259
- \\"meshConfig\\": {
260
- \\"sources\\": [
248
+ "meshId": "dummy_meshId",
249
+ "mesh": {
250
+ "meshConfig": {
251
+ "sources": [
261
252
  {
262
- \\"name\\": \\"<api_name>\\",
263
- \\"handler\\": {
264
- \\"graphql\\": {
265
- \\"endpoint\\": \\"<gql_endpoint>\\"
253
+ "name": "<api_name>",
254
+ "handler": {
255
+ "graphql": {
256
+ "endpoint": "<gql_endpoint>"
266
257
  }
267
258
  }
268
259
  }
@@ -271,13 +262,13 @@ describe('get command tests', () => {
271
262
  }
272
263
  }",
273
264
  ],
274
- Array [
265
+ [
275
266
  "Successfully wrote mesh to file %s",
276
267
  "./mesh.json",
277
268
  ],
278
269
  ]
279
270
  `);
280
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
271
+ expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
281
272
  });
282
273
 
283
274
  test('should log error if failed to write to file', async () => {
@@ -296,27 +287,27 @@ describe('get command tests', () => {
296
287
 
297
288
  expect(runResult).toEqual({ meshId: 'dummy_meshId', mesh: mockGetMeshConfig });
298
289
  expect(writeFile.mock.calls).toMatchInlineSnapshot(`
299
- Array [
300
- Array [
290
+ [
291
+ [
301
292
  "./mesh.json",
302
293
  "{}",
303
294
  ],
304
295
  ]
305
296
  `);
306
297
  expect(logSpy.mock.calls).toMatchInlineSnapshot(`
307
- Array [
308
- Array [
298
+ [
299
+ [
309
300
  "Successfully retrieved mesh %s",
310
301
  "{
311
- \\"meshId\\": \\"dummy_meshId\\",
312
- \\"mesh\\": {
313
- \\"meshConfig\\": {
314
- \\"sources\\": [
302
+ "meshId": "dummy_meshId",
303
+ "mesh": {
304
+ "meshConfig": {
305
+ "sources": [
315
306
  {
316
- \\"name\\": \\"<api_name>\\",
317
- \\"handler\\": {
318
- \\"graphql\\": {
319
- \\"endpoint\\": \\"<gql_endpoint>\\"
307
+ "name": "<api_name>",
308
+ "handler": {
309
+ "graphql": {
310
+ "endpoint": "<gql_endpoint>"
320
311
  }
321
312
  }
322
313
  }
@@ -325,12 +316,12 @@ describe('get command tests', () => {
325
316
  }
326
317
  }",
327
318
  ],
328
- Array [
319
+ [
329
320
  "Unable to write mesh to file %s",
330
321
  "./mesh.json",
331
322
  ],
332
323
  ]
333
324
  `);
334
- expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`Array []`);
325
+ expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
335
326
  });
336
327
  });