Skip to content

Commit 724ea5a

Browse files
Merge pull request #804 from thomasnordquist/chore/add-sparkplug-to-demovideo
add sparkplug decoding to demo video
2 parents 3229ef5 + e009940 commit 724ea5a

File tree

7 files changed

+26
-10
lines changed

7 files changed

+26
-10
lines changed

src/spec/SceneBuilder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type SceneNames =
1919
| 'settings'
2020
| 'customize_subscriptions'
2121
| 'keyboard_shortcuts'
22+
| 'sparkplugb-decoding'
2223
| 'end'
2324

2425
export class SceneBuilder {

src/spec/demoVideo.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { showMenu } from './scenarios/showMenu'
2121
import { showNumericPlot } from './scenarios/showNumericPlot'
2222
import { showOffDiffCapability } from './scenarios/showOffDiffCapability'
2323
import { showZoomLevel } from './scenarios/showZoomLevel'
24+
import { showSparkPlugDecoding } from './scenarios/showSparkplugDecoding'
2425

2526
/**
2627
* A convenience method that handles gracefully cleaning up the test run.
@@ -120,6 +121,11 @@ async function doStuff() {
120121
await sleep(1000)
121122
})
122123

124+
await scenes.record('sparkplugb-decoding', async () => {
125+
await showText('SparkplugB Decoding', 2000, page, 'top')
126+
await showSparkPlugDecoding(page)
127+
})
128+
123129
// disable this scenario for now until expandTopic is sorted out
124130
// await scenes.record('delete_retained_topics', async () => {
125131
// await hideText(page)

src/spec/scenarios/publishTopic.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function publishTopic(browser: Page) {
1414
const topicInput = await browser.locator('//input[contains(@value,"kitchen/lamp/state")][1]')
1515
await clickOn(topicInput)
1616
await deleteTextWithBackspaces(topicInput, 120, 5)
17-
await writeText('set', topicInput, 300)
17+
await writeText('set', topicInput)
1818

1919
const payloadInput = await browser.locator('//*[contains(@class, "ace_text-input")]')
2020
await writeTextPayload(payloadInput, 'off')
@@ -34,5 +34,6 @@ export async function publishTopic(browser: Page) {
3434
}
3535

3636
async function writeTextPayload(payloadInput: Locator, text: string) {
37-
await payloadInput.fill(text)
37+
await clickOn(payloadInput)
38+
await writeText(text, payloadInput)
3839
}

src/spec/scenarios/searchTree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { clickOn, deleteTextWithBackspaces, showText, sleep, writeText } from '.
44
export async function searchTree(text: string, browser: Page) {
55
const searchField = await browser.locator('//input[contains(@placeholder, "Search")]')
66
await clickOn(searchField, 1)
7-
await writeText(text, searchField, 100)
7+
await writeText(text, searchField)
88
await sleep(1500)
99
}
1010

src/spec/scenarios/showNumericPlot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Page } from 'playwright'
2-
import { moveToCenterOfElement, clickOn, clickOnHistory, expandTopic, sleep, writeText } from '../util'
2+
import { moveToCenterOfElement, clickOn, clickOnHistory, expandTopic, sleep } from '../util'
33

44
export async function showNumericPlot(browser: Page) {
55
await expandTopic('kitchen/coffee_maker', browser)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Page } from 'playwright'
2+
import { expandTopic, sleep } from '../util'
3+
4+
export async function showSparkPlugDecoding(browser: Page) {
5+
// spell-checker: disable-next-line
6+
await expandTopic('spBv1.0/Sparkplug Devices/DDATA/JavaScript Edge Node/Emulated Device', browser)
7+
await browser.screenshot({ path: 'screen_sparkplugb_decoding.png' })
8+
await sleep(1000)
9+
}

src/spec/util/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ export function sleep(ms: number, required = false) {
1919
})
2020
}
2121

22-
export async function writeText(text: string, element: Locator, delay = 0) {
23-
return element.fill(text)
22+
export async function writeText(text: string, element: Locator, delay = 30) {
23+
element.pressSequentially(text, { delay })
2424
}
2525

26-
export async function deleteTextWithBackspaces(element: Locator, delay = 0, count = 0) {
27-
// @ts-ignore
28-
const length = count > 0 ? count : (await element.textContent()).length
26+
export async function deleteTextWithBackspaces(element: Locator, delay = 30, count = 0) {
27+
const length = count > 0 ? count : (await element.inputValue()).length
2928
for (let i = 0; i < length; i += 1) {
30-
await element.press('Backspace')
29+
await element.press('Backspace', { delay: 30 })
3130
await sleep(delay)
3231
}
3332
}

0 commit comments

Comments
 (0)