feat(sdk,client): add menu to help navigation between apps
All checks were successful
arcad/edge/pipeline/head This commit looks good
All checks were successful
arcad/edge/pipeline/head This commit looks good
This commit is contained in:
@ -9,4 +9,4 @@ tags: ["test"]
|
||||
metadata:
|
||||
paths:
|
||||
icon: /icon.png
|
||||
minimumRole: visitor
|
||||
minimumRole: superadmin
|
@ -8,7 +8,10 @@
|
||||
<link rel="stylesheet" href="/vendor/mocha.css" />
|
||||
<style>
|
||||
body {
|
||||
background-color: white;
|
||||
background-color: #f7f7f7;
|
||||
}
|
||||
body:not([edge-auto-padding="false"]) #mocha-stats {
|
||||
top: 75px !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@ -30,6 +33,17 @@
|
||||
<script src="/test/fetch-module.js"></script>
|
||||
<script class="mocha-exec">
|
||||
mocha.run();
|
||||
|
||||
Edge.Menu
|
||||
.setAppIconUrl('/icon.png')
|
||||
.setAppTitle('SDK Tests')
|
||||
.setItem('client', 'Client', { linkUrl: '/?grep=Edge', order: 1 })
|
||||
.setItem('auth-module', 'Auth Module', { linkUrl: '/?grep=Auth%20Module' , order: 4})
|
||||
.setItem('net-module', 'Net Module', { linkUrl: '/?grep=Net%20Module' , order: 3})
|
||||
.setItem('rpc', 'Remote Procedure Call', { linkUrl: '/?grep=Remote%20Procedure%20Call' , order: 5})
|
||||
.setItem('file-module', 'File Module', { linkUrl: '/?grep=File%20Module', order: 6})
|
||||
.setItem('app-module', 'App Module', { linkUrl: '/?grep=App%20Module' , order: 7})
|
||||
.setItem('fetch-module', 'Fetch Module', { linkUrl: '/?grep=Fetch%20Module' , order: 8})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,15 +1,15 @@
|
||||
describe('App Module', function() {
|
||||
|
||||
before(() => {
|
||||
return Edge.connect();
|
||||
return Edge.Client.connect();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
Edge.Client.disconnect();
|
||||
});
|
||||
|
||||
it('should list apps', function() {
|
||||
return Edge.rpc("listApps")
|
||||
return Edge.Client.rpc("listApps")
|
||||
.then(apps => {
|
||||
console.log("listApps result:", apps);
|
||||
chai.assert.isNotNull(apps);
|
||||
@ -18,7 +18,7 @@ describe('App Module', function() {
|
||||
});
|
||||
|
||||
it('should retrieve requested app', function() {
|
||||
return Edge.rpc("getApp", { appId: "edge.sdk.client.test" })
|
||||
return Edge.Client.rpc("getApp", { appId: "edge.sdk.client.test" })
|
||||
.then(app => {
|
||||
console.log("getApp result:", app);
|
||||
chai.assert.isNotNull(app);
|
||||
@ -27,7 +27,7 @@ describe('App Module', function() {
|
||||
});
|
||||
|
||||
it('should retrieve requested app url without from address', function() {
|
||||
return Edge.rpc("getAppUrl", { appId: "edge.sdk.client.test" })
|
||||
return Edge.Client.rpc("getAppUrl", { appId: "edge.sdk.client.test" })
|
||||
.then(url => {
|
||||
console.log("getAppUrl result:", url);
|
||||
chai.assert.isNotEmpty(url);
|
||||
@ -35,7 +35,7 @@ describe('App Module', function() {
|
||||
});
|
||||
|
||||
it('should retrieve requested app url with from address', function() {
|
||||
return Edge.rpc("getAppUrl", { appId: "edge.sdk.client.test", from: "127.0.0.2" })
|
||||
return Edge.Client.rpc("getAppUrl", { appId: "edge.sdk.client.test", from: "127.0.0.2" })
|
||||
.then(url => {
|
||||
console.log("getAppUrl result:", url);
|
||||
chai.assert.isNotEmpty(url);
|
||||
|
@ -1,15 +1,15 @@
|
||||
describe('Auth Module', function() {
|
||||
|
||||
before(() => {
|
||||
return Edge.connect();
|
||||
return Edge.Client.connect();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
Edge.Client.disconnect();
|
||||
});
|
||||
|
||||
it('should retrieve user informations', function() {
|
||||
return Edge.rpc("getUserInfo")
|
||||
return Edge.Client.rpc("getUserInfo")
|
||||
.then(userInfo => {
|
||||
console.log("getUserInfo result:", userInfo);
|
||||
chai.assert.property(userInfo, 'subject');
|
||||
|
@ -1,25 +1,25 @@
|
||||
Edge.debug = true;
|
||||
EdgeFrame.debug = true;
|
||||
Edge.Client.debug = true;
|
||||
Edge.Frame.debug = true;
|
||||
|
||||
describe('Edge', function() {
|
||||
|
||||
describe('#connect()', function() {
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
Edge.Client.disconnect();
|
||||
});
|
||||
|
||||
it('should open the connection', function() {
|
||||
return Edge.connect()
|
||||
return Edge.Client.connect()
|
||||
.then(() => {
|
||||
chai.assert.isNotNull(Edge._conn);
|
||||
chai.assert.isNotNull(Edge.Client._conn);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#disconnect()', function() {
|
||||
it('should close the connection', function() {
|
||||
Edge.disconnect();
|
||||
chai.assert.isNull(Edge._conn);
|
||||
Edge.Client.disconnect();
|
||||
chai.assert.isNull(Edge.Client._conn);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
describe('Fetch Module', function () {
|
||||
|
||||
before(() => {
|
||||
return Edge.connect();
|
||||
return Edge.Client.connect();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
Edge.Client.disconnect();
|
||||
});
|
||||
|
||||
it('should fetch an authorized external url', function () {
|
||||
var externalUrl = Edge.externalUrl("http://example.com");
|
||||
var externalUrl = Edge.Client.externalUrl("http://example.com");
|
||||
|
||||
return fetch(externalUrl)
|
||||
.then(res => {
|
||||
@ -22,7 +22,7 @@ describe('Fetch Module', function () {
|
||||
});
|
||||
|
||||
it('should not fetch an unauthorized external url', function () {
|
||||
var externalUrl = Edge.externalUrl("https://google.com");
|
||||
var externalUrl = Edge.Client.externalUrl("https://google.com");
|
||||
|
||||
return fetch(externalUrl)
|
||||
.then(res => {
|
||||
|
@ -1,25 +1,25 @@
|
||||
describe('File Module', function () {
|
||||
|
||||
before(() => {
|
||||
return Edge.connect();
|
||||
return Edge.Client.connect();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
Edge.Client.disconnect();
|
||||
});
|
||||
|
||||
it('should upload then download a blob', function () {
|
||||
const content = JSON.stringify({ "date": new Date() });
|
||||
const blob = new Blob([content], { type: "application/json" });
|
||||
|
||||
return Edge.upload(blob)
|
||||
return Edge.Client.upload(blob)
|
||||
.then(upload => upload.result())
|
||||
.then(result => {
|
||||
|
||||
chai.assert.isNotEmpty(result.blobId);
|
||||
chai.assert.isNotEmpty(result.bucket);
|
||||
|
||||
const blobUrl = Edge.blobUrl(result.bucket, result.blobId);
|
||||
const blobUrl = Edge.Client.blobUrl(result.bucket, result.blobId);
|
||||
chai.assert.isNotEmpty(blobUrl);
|
||||
|
||||
return fetch(blobUrl)
|
||||
|
@ -2,11 +2,11 @@ describe('Net Module', function () {
|
||||
this.timeout(5000);
|
||||
|
||||
before(() => {
|
||||
return Edge.connect();
|
||||
return Edge.Client.connect();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
Edge.Client.disconnect();
|
||||
});
|
||||
|
||||
it('should broadcast a message from server', function (done) {
|
||||
@ -18,12 +18,12 @@ describe('Net Module', function () {
|
||||
|
||||
chai.assert.deepEqual(message, evt.detail);
|
||||
|
||||
Edge.removeEventListener('message', handler);
|
||||
Edge.Client.removeEventListener('message', handler);
|
||||
done();
|
||||
};
|
||||
|
||||
Edge.addEventListener("message", handler);
|
||||
Edge.send(message);
|
||||
Edge.Client.addEventListener("message", handler);
|
||||
Edge.Client.send(message);
|
||||
});
|
||||
|
||||
it('should send a message to the server and echo back', function(done) {
|
||||
@ -35,15 +35,15 @@ describe('Net Module', function () {
|
||||
|
||||
chai.assert.equal(receivedMessage.now, now.toJSON());
|
||||
|
||||
Edge.removeEventListener('message', handler);
|
||||
Edge.Client.removeEventListener('message', handler);
|
||||
done();
|
||||
}
|
||||
|
||||
// Server should echo back message
|
||||
Edge.addEventListener('message', handler);
|
||||
Edge.Client.addEventListener('message', handler);
|
||||
|
||||
// Send message to server
|
||||
Edge.send({ test: 'echo', now });
|
||||
Edge.Client.send({ test: 'echo', now });
|
||||
});
|
||||
|
||||
});
|
@ -1,17 +1,17 @@
|
||||
describe('Remote Procedure Call', function () {
|
||||
|
||||
before(() => {
|
||||
return Edge.connect();
|
||||
return Edge.Client.connect();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
Edge.Client.disconnect();
|
||||
});
|
||||
|
||||
it('should call the remote echo() method and resolve the returned value', function () {
|
||||
const foo = "bar";
|
||||
|
||||
return Edge.rpc('echo', { foo })
|
||||
return Edge.Client.rpc('echo', { foo })
|
||||
.then(result => {
|
||||
console.log(result);
|
||||
chai.assert.equal(result.foo, foo);
|
||||
@ -19,7 +19,7 @@ describe('Remote Procedure Call', function () {
|
||||
});
|
||||
|
||||
it('should call the remote throwErrorFromClient() method and reject with an error', function () {
|
||||
return Edge.rpc('throwErrorFromClient')
|
||||
return Edge.Client.rpc('throwErrorFromClient')
|
||||
.catch(err => {
|
||||
// Assert that it's an "internal" error
|
||||
// See https://www.jsonrpc.org/specification#error_object
|
||||
@ -28,7 +28,7 @@ describe('Remote Procedure Call', function () {
|
||||
});
|
||||
|
||||
it('should call an unregistered method and reject with an error', function () {
|
||||
return Edge.rpc('unregisteredMethod')
|
||||
return Edge.Client.rpc('unregisteredMethod')
|
||||
.catch(err => {
|
||||
// Assert that it's an "method not found" error
|
||||
// See https://www.jsonrpc.org/specification#error_object
|
||||
@ -44,11 +44,11 @@ describe('Remote Procedure Call', function () {
|
||||
for (let i = 0; i <= 1000; i++) {
|
||||
values.push((Math.random() * 1000 | 0));
|
||||
}
|
||||
return Edge.rpc('reset')
|
||||
return Edge.Client.rpc('reset')
|
||||
.then(() => {
|
||||
return Promise.all(values.map(v => Edge.rpc("add", { value: v })));
|
||||
return Promise.all(values.map(v => Edge.Client.rpc("add", { value: v })));
|
||||
})
|
||||
.then(() => Edge.rpc('total'))
|
||||
.then(() => Edge.Client.rpc('total'))
|
||||
.then(remoteTotal => {
|
||||
const localTotal = values.reduce((t, v) => t + v);
|
||||
console.log("Remote total:", remoteTotal, "Local total:", localTotal);
|
||||
|
Reference in New Issue
Block a user