diff --git a/__tests__/formatter/__snapshots__/javascript.test.ts.snap b/__tests__/formatter/__snapshots__/javascript.test.ts.snap index 252391e1..cd9bfc1f 100644 --- a/__tests__/formatter/__snapshots__/javascript.test.ts.snap +++ b/__tests__/formatter/__snapshots__/javascript.test.ts.snap @@ -3,8 +3,9 @@ exports[`Synthetics JavaScript formatter inline journeys 1`] = ` "step('Go to https://vigneshh.in/', async () => { await page.goto('https://vigneshh.in/'); - await page.click('a:has-text(\\"Go to bag\\")'); - expect(await page.textContent('text=Babel Minify')).toBe('babel'); + expect(await page.isVisible('text=Babel Minify')).toBeTruthy(); + expect(await page.isEditable('text=Babel Minify')).toBeTruthy(); + expect(await page.textContent('text=Babel Minify')).toMatch('Babel'); }); step('Click text=Babel Minify', async () => { const [page1] = await Promise.all([ @@ -25,8 +26,9 @@ exports[`Synthetics JavaScript formatter suite journeys 1`] = ` journey('Recorded journey', async ({ page, context }) => { step('Go to https://vigneshh.in/', async () => { await page.goto('https://vigneshh.in/'); - await page.click('a:has-text(\\"Go to bag\\")'); - expect(await page.textContent('text=Babel Minify')).toBe('babel'); + expect(await page.isVisible('text=Babel Minify')).toBeTruthy(); + expect(await page.isEditable('text=Babel Minify')).toBeTruthy(); + expect(await page.textContent('text=Babel Minify')).toMatch('Babel'); }); step('Click text=Babel Minify', async () => { const [page1] = await Promise.all([ diff --git a/__tests__/formatter/javascript.test.ts b/__tests__/formatter/javascript.test.ts index 42eee54b..d8c1184a 100644 --- a/__tests__/formatter/javascript.test.ts +++ b/__tests__/formatter/javascript.test.ts @@ -55,14 +55,24 @@ const recorderActions: Array = [ isMainFrame: true, frameUrl: 'https://vigneshh.in/', action: { - name: 'click', - selector: 'a:has-text("Go to bag")', + name: 'assert', + isAssert: true, + command: 'isVisible', + selector: 'text=Babel Minify', + signals: [], + }, + }, + { + pageAlias: 'page', + isMainFrame: true, + frameUrl: 'https://vigneshh.in/', + action: { + name: 'assert', + isAssert: true, + command: 'isEditable', + selector: 'text=Babel Minify', signals: [], - button: 'left', - modifiers: 0, - clickCount: 1, }, - committed: true, }, { pageAlias: 'page', @@ -73,7 +83,7 @@ const recorderActions: Array = [ isAssert: true, command: 'textContent', selector: 'text=Babel Minify', - value: 'babel', + value: 'Babel', signals: [], }, }, diff --git a/src/formatter/javascript.ts b/src/formatter/javascript.ts index bc66921b..76b6b806 100644 --- a/src/formatter/javascript.ts +++ b/src/formatter/javascript.ts @@ -264,11 +264,16 @@ function toAssertCall(pageAlias, action) { const { command, selector, value } = action; switch (command) { case 'textContent': + case 'innerText': return `expect(await ${pageAlias}.${command}(${quote( selector - )})).toBe(${quote(value)});`; + )})).toMatch(${quote(value)});`; case 'isVisible': case 'isHidden': + case 'isChecked': + case 'isEditable': + case 'isEnabled': + case 'isDisabled': return `expect(await ${pageAlias}.${command}(${quote( selector )})).toBeTruthy();`;