Skip to content

Commit 439e719

Browse files
riokritchieCommonGuy
authored andcommitted
Update example project for 1.18.0
1 parent 879bf20 commit 439e719

37 files changed

+213
-38
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
// A configured authentication can be selected in the "Auth" tab.
2+
// A configured authentication can be selected in the "Auth" tab.
33
// It is also accessible via templating.
44
// Send the operation and take a look at the "Trace" tab to see the sent authentication value.
55
// Change the active environment and send the operation again to see the updated value.
66
"name": "{{ auth.configs.myauth.name }}"
7-
}
7+
}

example-project/Kreya features/Script/Advanced script.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22

33
kreya.variables.delete('messages');
44

5-
// Invoke operations and access variable set by them
5+
// Invoke operations and access variables set by them
66
await kreya.invokeOperation('../Scripting/Advanced scripting example');
77
kreya.test('messages should be set', () => {
88
const messages = kreya.variables.get('messages');
@@ -12,9 +12,9 @@ kreya.test('messages should be set', () => {
1212
// Invoke operations multiple times
1313
for (let i = 0; i < 3; i++) {
1414
const result = await kreya.invokeOperation('../../REST/Get book');
15-
15+
1616
if (!result.success) {
1717
// Stop the loop if an error occurs
1818
break;
1919
}
20-
}
20+
}

example-project/Kreya features/Script/Simple script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ await kreya.invokeOperation('../../REST/Delete book');
33

44
await kreya.invokeOperation('../../gRPC/Say hello (unary call)');
55

6-
await kreya.invokeOperation('../../WebSocket/Echo');
6+
await kreya.invokeOperation('../../WebSocket/Echo');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"message": "{{ vars.messages ? vars.messages[0] : 'no messages set' }}"
3-
}
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"message": "{{ vars.messages ? vars.messages[1] : 'no messages set' }}"
3-
}
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"message": "{{ vars.messages ? vars.messages[2] : 'no messages set' }}"
3-
}
3+
}

example-project/Kreya features/Scripting/Advanced scripting example.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const messages = ['first message', 'second message', 'third message'];
66
// store the messages as a "user variable", which is persisted
77
kreya.variables.set('messages', messages);
88

9-
kreyaGrpc.onResponse(msg => {
9+
kreya.grpc.onResponse(msg => {
1010
kreya.test('Should equal the sent message', () => expect(msg.content.message).to.eql(messages[msg.index]));
1111
});
1212

13-
kreyaGrpc.onCallCompleted(call => {
13+
kreya.grpc.onCallCompleted(call => {
1414
kreya.test('Status should be ok', () => expect(call.status.code).to.equal(0));
1515

1616
kreya.trace(`Got ${call.responseCount} responses`);
1717
kreya.test('Response count should match sent messages', () => expect(call.responseCount).to.eql(messages.length));
18-
});
18+
});

example-project/Kreya features/Scripting/File system access.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { expect } from 'chai';
33

44
const expectedResponse = await readFile('book-1-expected-response.json', 'utf8');
55

6-
kreyaRest.onCallCompleted(call => {
6+
kreya.rest.onCallCompleted(call => {
77
kreya.test('Response should match snapshot', () => {
88
expect(call.response.rawContentText).to.eql(expectedResponse);
99
});
10-
});
10+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
kreya.rest.onCallCompleted(async ctx => {
2+
const dates = ctx.response.content.days.map(d => d.date);
3+
const quantities = ctx.response.content.days.map(d => d.quantity);
4+
await kreya.preview.html(
5+
`
6+
<html>
7+
<body>
8+
<div id="chart" style="width: 100%; height: 100%;"></div>
9+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.6.0/dist/echarts.min.js"></script>
10+
<script>
11+
const chart = echarts.init(document.getElementById('chart'));
12+
chart.setOption({
13+
title: {
14+
text: 'Sales of "${ctx.response.content.book.name}"'
15+
},
16+
animation: false,
17+
xAxis: {
18+
data: ${JSON.stringify(dates)}
19+
},
20+
yAxis: {},
21+
series: [{
22+
type: 'bar',
23+
data: ${JSON.stringify(quantities)}
24+
}]
25+
});
26+
27+
window.addEventListener('resize', () => chart.resize());
28+
</script>
29+
</body>
30+
</html>
31+
`,
32+
'Sales',
33+
);
34+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"details": {
3+
"path": "/v1/books/{id}/sales",
4+
"method": "GET",
5+
"pathParams": [
6+
{
7+
"key": "id",
8+
"value": "1"
9+
}
10+
]
11+
},
12+
"script": {
13+
"src": "Scripting Preview HTML Chart.js"
14+
},
15+
"requests": [
16+
{
17+
"contentType": "none"
18+
}
19+
],
20+
"operationType": "unary",
21+
"invokerName": "rest",
22+
"typeHint": "GET"
23+
}

0 commit comments

Comments
 (0)