parent
260477e5e8
commit
54447774d1
|
|
@ -0,0 +1,9 @@
|
||||||
|
actions:
|
||||||
|
- title: 'Test me {{ test_me.name }}'
|
||||||
|
popupOnStart: execution-dialog-stdout-only
|
||||||
|
entity: testrows
|
||||||
|
shell: echo "{{ test_me.val }}"
|
||||||
|
|
||||||
|
entities:
|
||||||
|
- name: testrows
|
||||||
|
file: entities/data.json
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{"name":"INT with 10 numbers","val":1234567890}
|
||||||
|
{"name":"INT with 6 numbers","val":123456}
|
||||||
|
{"name":"INT with 7 numbers","val":1234567}
|
||||||
|
{"name":"FLOAT with 6 numbers","val":1.234567}
|
||||||
|
{"name":"FLOAT with 10 numbers","val":1.234567890}
|
||||||
|
|
@ -11,6 +11,22 @@ export async function getActionButtons (dashboardTitle = null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getExecutionDialogOutput() {
|
||||||
|
await webdriver.wait(new Condition('Dialog with long int is visible', async () => {
|
||||||
|
const dialog = await webdriver.findElement({ id: 'execution-results-popup' })
|
||||||
|
return await dialog.isDisplayed()
|
||||||
|
}));
|
||||||
|
|
||||||
|
const ret = await webdriver.executeScript('return window.logEntries.get(window.executionDialog.executionTrackingId).output')
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function closeExecutionDialog() {
|
||||||
|
const btnClose = await webdriver.findElements(By.css('[title="Close"]'))
|
||||||
|
await btnClose[0].click()
|
||||||
|
}
|
||||||
|
|
||||||
export function takeScreenshotOnFailure (test, webdriver) {
|
export function takeScreenshotOnFailure (test, webdriver) {
|
||||||
if (test.state === 'failed') {
|
if (test.state === 'failed') {
|
||||||
const title = test.fullTitle();
|
const title = test.fullTitle();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
// Issue: https://github.com/OliveTin/OliveTin/issues/616
|
||||||
|
import { describe, it, before, after } from 'mocha'
|
||||||
|
import { expect } from 'chai'
|
||||||
|
import {
|
||||||
|
getRootAndWait,
|
||||||
|
getActionButtons,
|
||||||
|
closeExecutionDialog,
|
||||||
|
takeScreenshotOnFailure,
|
||||||
|
getExecutionDialogOutput,
|
||||||
|
} from '../lib/elements.js'
|
||||||
|
|
||||||
|
describe('config: entities', function () {
|
||||||
|
before(async function () {
|
||||||
|
await runner.start('entityFilesWithLongIntsUseStandardForm')
|
||||||
|
})
|
||||||
|
|
||||||
|
after(async () => {
|
||||||
|
await runner.stop()
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Entity buttons are rendered', async function() {
|
||||||
|
await getRootAndWait()
|
||||||
|
|
||||||
|
const buttons = await getActionButtons()
|
||||||
|
|
||||||
|
expect(buttons).to.not.be.null
|
||||||
|
expect(buttons).to.have.length(5)
|
||||||
|
|
||||||
|
const buttonInt10 = await buttons[2]
|
||||||
|
expect(await buttonInt10.getAttribute('title')).to.be.equal('Test me INT with 10 numbers')
|
||||||
|
await buttonInt10.click()
|
||||||
|
expect(await getExecutionDialogOutput()).to.be.equal('1234567890\n', 'Expected output to be an int')
|
||||||
|
|
||||||
|
await closeExecutionDialog()
|
||||||
|
|
||||||
|
const buttonFloat10 = await buttons[0]
|
||||||
|
expect(await buttonFloat10.getAttribute('title')).to.be.equal('Test me FLOAT with 10 numbers')
|
||||||
|
await buttonFloat10.click()
|
||||||
|
expect(await getExecutionDialogOutput()).to.be.equal('1.234568\n', 'Expected output to be a float')
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -26,7 +26,7 @@ compile-x64-win:
|
||||||
|
|
||||||
compile: compile-armhf compile-x64-lin compile-x64-win
|
compile: compile-armhf compile-x64-lin compile-x64-win
|
||||||
|
|
||||||
codestyle:
|
codestyle: go-tools
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
go vet ./...
|
go vet ./...
|
||||||
gocyclo -over 4 internal
|
gocyclo -over 4 internal
|
||||||
|
|
@ -39,6 +39,10 @@ unittests:
|
||||||
go tool cover -html=reports/unittests.out -o reports/unittests.html
|
go tool cover -html=reports/unittests.out -o reports/unittests.html
|
||||||
|
|
||||||
go-tools:
|
go-tools:
|
||||||
|
go install "github.com/fzipp/gocyclo/cmd/gocyclo"
|
||||||
|
go install "github.com/go-critic/go-critic/cmd/gocritic"
|
||||||
|
|
||||||
|
go-tools-all:
|
||||||
go install "github.com/bufbuild/buf/cmd/buf"
|
go install "github.com/bufbuild/buf/cmd/buf"
|
||||||
go install "github.com/fzipp/gocyclo/cmd/gocyclo"
|
go install "github.com/fzipp/gocyclo/cmd/gocyclo"
|
||||||
go install "github.com/go-critic/go-critic/cmd/gocritic"
|
go install "github.com/go-critic/go-critic/cmd/gocritic"
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -142,11 +143,22 @@ func serializeValueToSv(prefix string, value interface{}) {
|
||||||
serializeMapToSv(prefix, m)
|
serializeMapToSv(prefix, m)
|
||||||
} else if s, ok := value.([]interface{}); ok { // if value is a slice we need to flatten it
|
} else if s, ok := value.([]interface{}); ok { // if value is a slice we need to flatten it
|
||||||
serializeSliceToSv(prefix, s)
|
serializeSliceToSv(prefix, s)
|
||||||
|
} else if f, ok := value.(float64); ok {
|
||||||
|
if canConvertToInt64(f) {
|
||||||
|
s := int64(f)
|
||||||
|
sv.Set(prefix, fmt.Sprintf("%d", s))
|
||||||
|
} else {
|
||||||
|
sv.Set(prefix, fmt.Sprintf("%f", f))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sv.Set(prefix, fmt.Sprintf("%v", value))
|
sv.Set(prefix, fmt.Sprintf("%v", value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func canConvertToInt64(f float64) bool {
|
||||||
|
return f >= math.MinInt64 && f <= math.MaxInt64 && f == math.Trunc(f)
|
||||||
|
}
|
||||||
|
|
||||||
func serializeMapToSv(prefix string, m map[string]interface{}) {
|
func serializeMapToSv(prefix string, m map[string]interface{}) {
|
||||||
for k, v := range m {
|
for k, v := range m {
|
||||||
serializeValueToSv(prefix+"."+k, v)
|
serializeValueToSv(prefix+"."+k, v)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package entityfiles
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
sv "github.com/OliveTin/OliveTin/internal/stringvariables"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLoadObjectPerLineJsonFile(t *testing.T) {
|
||||||
|
filename := "testdata/object-per-line.json"
|
||||||
|
|
||||||
|
assert.Equal(t, "", sv.Get("entities.testrow.0.val"), "Value should match expected value")
|
||||||
|
|
||||||
|
loadEntityFileJson(filename, "testrow")
|
||||||
|
|
||||||
|
assert.Equal(t, "1234567890", sv.Get("entities.testrow.0.val"), "Value should match expected value")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{"name":"INT with 10 numbers","val":1234567890}
|
||||||
|
{"name":"INT with 6 numbers","val":123456}
|
||||||
|
{"name":"INT with 7 numbers","val":1234567}
|
||||||
|
{"name":"FLOAT with 6 numbers","val":1.234567}
|
||||||
|
{"name":"FLOAT with 10 numbers","val":1.234567890}
|
||||||
Loading…
Reference in New Issue