Merge pull request #804 from thomasnordquist/chore/add-sparkplug-to-demovideo
add sparkplug decoding to demo video
This commit is contained in:
@@ -19,6 +19,7 @@ export type SceneNames =
|
|||||||
| 'settings'
|
| 'settings'
|
||||||
| 'customize_subscriptions'
|
| 'customize_subscriptions'
|
||||||
| 'keyboard_shortcuts'
|
| 'keyboard_shortcuts'
|
||||||
|
| 'sparkplugb-decoding'
|
||||||
| 'end'
|
| 'end'
|
||||||
|
|
||||||
export class SceneBuilder {
|
export class SceneBuilder {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { showMenu } from './scenarios/showMenu'
|
|||||||
import { showNumericPlot } from './scenarios/showNumericPlot'
|
import { showNumericPlot } from './scenarios/showNumericPlot'
|
||||||
import { showOffDiffCapability } from './scenarios/showOffDiffCapability'
|
import { showOffDiffCapability } from './scenarios/showOffDiffCapability'
|
||||||
import { showZoomLevel } from './scenarios/showZoomLevel'
|
import { showZoomLevel } from './scenarios/showZoomLevel'
|
||||||
|
import { showSparkPlugDecoding } from './scenarios/showSparkplugDecoding'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience method that handles gracefully cleaning up the test run.
|
* A convenience method that handles gracefully cleaning up the test run.
|
||||||
@@ -120,6 +121,11 @@ async function doStuff() {
|
|||||||
await sleep(1000)
|
await sleep(1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await scenes.record('sparkplugb-decoding', async () => {
|
||||||
|
await showText('SparkplugB Decoding', 2000, page, 'top')
|
||||||
|
await showSparkPlugDecoding(page)
|
||||||
|
})
|
||||||
|
|
||||||
// disable this scenario for now until expandTopic is sorted out
|
// disable this scenario for now until expandTopic is sorted out
|
||||||
// await scenes.record('delete_retained_topics', async () => {
|
// await scenes.record('delete_retained_topics', async () => {
|
||||||
// await hideText(page)
|
// await hideText(page)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export async function publishTopic(browser: Page) {
|
|||||||
const topicInput = await browser.locator('//input[contains(@value,"kitchen/lamp/state")][1]')
|
const topicInput = await browser.locator('//input[contains(@value,"kitchen/lamp/state")][1]')
|
||||||
await clickOn(topicInput)
|
await clickOn(topicInput)
|
||||||
await deleteTextWithBackspaces(topicInput, 120, 5)
|
await deleteTextWithBackspaces(topicInput, 120, 5)
|
||||||
await writeText('set', topicInput, 300)
|
await writeText('set', topicInput)
|
||||||
|
|
||||||
const payloadInput = await browser.locator('//*[contains(@class, "ace_text-input")]')
|
const payloadInput = await browser.locator('//*[contains(@class, "ace_text-input")]')
|
||||||
await writeTextPayload(payloadInput, 'off')
|
await writeTextPayload(payloadInput, 'off')
|
||||||
@@ -34,5 +34,6 @@ export async function publishTopic(browser: Page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function writeTextPayload(payloadInput: Locator, text: string) {
|
async function writeTextPayload(payloadInput: Locator, text: string) {
|
||||||
await payloadInput.fill(text)
|
await clickOn(payloadInput)
|
||||||
|
await writeText(text, payloadInput)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { clickOn, deleteTextWithBackspaces, showText, sleep, writeText } from '.
|
|||||||
export async function searchTree(text: string, browser: Page) {
|
export async function searchTree(text: string, browser: Page) {
|
||||||
const searchField = await browser.locator('//input[contains(@placeholder, "Search")]')
|
const searchField = await browser.locator('//input[contains(@placeholder, "Search")]')
|
||||||
await clickOn(searchField, 1)
|
await clickOn(searchField, 1)
|
||||||
await writeText(text, searchField, 100)
|
await writeText(text, searchField)
|
||||||
await sleep(1500)
|
await sleep(1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Page } from 'playwright'
|
import { Page } from 'playwright'
|
||||||
import { moveToCenterOfElement, clickOn, clickOnHistory, expandTopic, sleep, writeText } from '../util'
|
import { moveToCenterOfElement, clickOn, clickOnHistory, expandTopic, sleep } from '../util'
|
||||||
|
|
||||||
export async function showNumericPlot(browser: Page) {
|
export async function showNumericPlot(browser: Page) {
|
||||||
await expandTopic('kitchen/coffee_maker', browser)
|
await expandTopic('kitchen/coffee_maker', browser)
|
||||||
|
|||||||
9
src/spec/scenarios/showSparkplugDecoding.ts
Normal file
9
src/spec/scenarios/showSparkplugDecoding.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { Page } from 'playwright'
|
||||||
|
import { expandTopic, sleep } from '../util'
|
||||||
|
|
||||||
|
export async function showSparkPlugDecoding(browser: Page) {
|
||||||
|
// spell-checker: disable-next-line
|
||||||
|
await expandTopic('spBv1.0/Sparkplug Devices/DDATA/JavaScript Edge Node/Emulated Device', browser)
|
||||||
|
await browser.screenshot({ path: 'screen_sparkplugb_decoding.png' })
|
||||||
|
await sleep(1000)
|
||||||
|
}
|
||||||
@@ -19,15 +19,14 @@ export function sleep(ms: number, required = false) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function writeText(text: string, element: Locator, delay = 0) {
|
export async function writeText(text: string, element: Locator, delay = 30) {
|
||||||
return element.fill(text)
|
element.pressSequentially(text, { delay })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteTextWithBackspaces(element: Locator, delay = 0, count = 0) {
|
export async function deleteTextWithBackspaces(element: Locator, delay = 30, count = 0) {
|
||||||
// @ts-ignore
|
const length = count > 0 ? count : (await element.inputValue()).length
|
||||||
const length = count > 0 ? count : (await element.textContent()).length
|
|
||||||
for (let i = 0; i < length; i += 1) {
|
for (let i = 0; i < length; i += 1) {
|
||||||
await element.press('Backspace')
|
await element.press('Backspace', { delay: 30 })
|
||||||
await sleep(delay)
|
await sleep(delay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user