Skip to content

Commit 8574f57

Browse files
authored
Merge pull request AdobeDocs#36 from AdobeDocs/CEXT-1795-ref
Add local testing topic
2 parents bc3e3d5 + fffcf86 commit 8574f57

File tree

5 files changed

+138
-11
lines changed

5 files changed

+138
-11
lines changed

src/data/navigation/sections/admin-ui-sdk.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@ module.exports = [
77
title: "Installation",
88
path: "/admin-ui-sdk/installation.md"
99
},
10-
{
11-
title: "Admin configuration and testing",
12-
path: "/admin-ui-sdk/configuration.md"
13-
},
1410
{
1511
title: "App UI registration",
1612
path: "/admin-ui-sdk/app-registration.md"
1713
},
1814
{
19-
title: "MenuApp component",
20-
path: "/admin-ui-sdk/reference/menu-app.md"
21-
},
22-
{
23-
title: "PageApp component",
24-
path: "/admin-ui-sdk/reference/page-app.md"
15+
title: "Admin configuration and testing",
16+
path: "/admin-ui-sdk/configuration.md"
2517
},
2618
{
2719
title: "Troubleshooting",

src/pages/_images/fetched-orders.png

190 KB
Loading

src/pages/_images/sdk-config.png

66.7 KB
Loading
-91.4 KB
Binary file not shown.
Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,141 @@
11
---
22
title: Admin configuration and testing
3-
description:
3+
description: Learn how to configure the Admin to enable local testing of your Admin customizations.
44
---
55

66
# Admin configuration and testing
7+
8+
The Adobe Commerce Admin UI SDK allows you to use a local server to view and test your Admin customizations before you submit your app to the Adobe Marketplace.
9+
10+
## Configure the Admin
11+
12+
Navigate to **Stores** > Settings > **Configuration** > **Adobe Services** > **Admin UI SDK** and edit the **General Configuration** screen. When you enable the local service, all calls are automatically redirected to the local server, instead of connecting to Adobe's App Registry. The values you specify must match the contents of your local `server.js` file.
13+
14+
[Test with a sample app](#test-with-a-sample-app) provides a sample `server.js` file.
15+
16+
![Local server configuration](../_images/sdk-config.png)
17+
18+
1. Select **Yes** from the **Enable local service** menu.
19+
20+
1. Set the **Base URL** that points to your localhost, including the port.
21+
22+
1. Set the **IMS Token**. In the sample `server.js` file, this value is set to `dummyToken`.
23+
24+
1. Set the **IMS Org Id**. In the sample `server.js` file, this value is set to `imsOrg`.
25+
26+
1. Save your configuration.
27+
28+
1. Clear the cache.
29+
30+
```bash
31+
bin/magento cache:flush
32+
```
33+
34+
## Test with a sample app
35+
36+
You can download a sample app from the [Commerce UI test extension repository](https://github.com/magento/app-builder-samples) to gain insight on how the Admin SDK injects menus and pages into the Admin.
37+
38+
1. Run the following command to clone and sync the repository:
39+
40+
```bash
41+
git clone git@github.com:magento/app-builder-samples.git
42+
```
43+
44+
1. Change directories to the cloned repository's root directory.
45+
46+
1. Create a `server.js` file to define a local server:
47+
48+
```js
49+
const http = require('https');
50+
const fs = require('fs');
51+
const url = require('url');
52+
53+
const options = {
54+
key: fs.readFileSync('key.pem'),
55+
cert: fs.readFileSync('cert.pem')
56+
};
57+
58+
console.log('Server will listen at : https://localhost ');
59+
http.createServer(options, function (req, res) {
60+
res.writeHead(200, {
61+
'Content-Type': 'application/json',
62+
'Access-Control-Allow-Origin': '*',
63+
'Access-Control-Allow-Headers': '*'
64+
});
65+
let json_response;
66+
67+
console.log(url.parse(req.url,true).pathname);
68+
if (url.parse(req.url,true).pathname == "/config") {
69+
json_response = {
70+
baseUrl: "https://localhost.adobe.io:9090/",
71+
apiKey: "apiKey",
72+
auth: {
73+
schema: "Bearer",
74+
imsToken: "dummyToken"
75+
},
76+
imsOrg: "imsOrg",
77+
version: 1,
78+
service: "commerce",
79+
extensionPoint: "backend-ui"
80+
}
81+
} else {
82+
json_response = [{
83+
"name": "test-extension",
84+
"title": "Test extension",
85+
"description": "No",
86+
"icon": "no",
87+
"publisher": "aQQ6300000008LEGAY",
88+
"endpoints": {
89+
"commerce/backend-ui/1": {
90+
"view": [{
91+
"href": "https://localhost:9080/"
92+
}]
93+
}
94+
},
95+
"xrInfo": {
96+
"supportEmail": "test@adobe.com",
97+
"appId": "4a4c7cf8-bd64-4649-b8ed-662cd0d9c918"
98+
},
99+
"status": "PUBLISHED" }]
100+
}
101+
//console.log(json_response);
102+
res.end( JSON.stringify(json_response) );
103+
}).listen(9090);
104+
```
105+
106+
1. Run the local server:
107+
108+
```bash
109+
node server.js
110+
```
111+
112+
1. Make sure you have access to the localhost server configuration by entering the following URL in your browser:
113+
114+
`https://localhost:9090/config`
115+
116+
The browser displays a JSON file similar to the following:
117+
118+
```json
119+
{
120+
"baseUrl":"https://localhost:9090/",
121+
"apiKey":"apiKey",
122+
"auth":{
123+
"schema":"Bearer",
124+
"imsToken":"dummyToken"
125+
},
126+
"imsOrg":"imsOrg",
127+
"version":1,
128+
"service":"commerce",
129+
"extensionPoint":"backend-ui"
130+
}
131+
```
132+
133+
1. Run your extension locally.
134+
135+
```bash
136+
aio app run
137+
```
138+
139+
1. Check that the menu is correctly added to the Admin.
140+
141+
![Local server configuration](../_images/fetched-orders.png)

0 commit comments

Comments
 (0)