Skip to content

Commit 8463e68

Browse files
committed
test(extension): retain denied keyboard sends alongside mouse coverage
1 parent feb178b commit 8463e68

1 file changed

Lines changed: 46 additions & 42 deletions

File tree

‎apps/sim/scripts/test-browser-extension-e2e.ts‎

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,48 +2023,52 @@ try {
20232023
assert.equal(manual.length, 1)
20242024
assert(manual[0].text.includes('ORCHID-482') && !manual[0].text.includes('JADE-231'))
20252025

2026-
await openScenario(target, `${org ? 'organization' : 'workspace'}-denied`)
2027-
await expect(input()).toBeVisible()
2028-
await restricted.bringToFront()
2029-
const draft = 'Keep this draft if access is unavailable'
2030-
await input().fill(draft)
2031-
count = received.length
2032-
phase = 'denied-send'
2033-
await frame()
2034-
.getByRole('button', { name: org ? 'Send' : 'Send message', exact: true })
2035-
.click()
2036-
await expect(
2037-
shell.getByRole('button', { name: 'Request site access', exact: true })
2038-
).toBeEnabled()
2039-
await expect(input()).toHaveValue(draft)
2040-
await expect
2041-
.poll(() => input().evaluate((element) => Boolean(element.closest('[inert]'))))
2042-
.toBe(false)
2043-
assert.equal(received.length, count)
2044-
assert(
2045-
await frame().evaluate(() => document.hasFocus()),
2046-
'The denied mouse send must keep the chat document focused'
2047-
)
2048-
await expect(input()).toBeFocused()
2049-
await shell.keyboard.type(' Continue typing after the denied capture.')
2050-
await expect(input()).toHaveValue(`${draft} Continue typing after the denied capture.`)
2051-
assert.equal(received.length, count)
2052-
await screenshot(`reference-${org ? 'organization' : 'workspace'}-denied`)
2053-
const accessNotice = await shell
2054-
.getByRole('status')
2055-
.first()
2056-
.evaluate((status) => status.firstChild?.textContent?.trim())
2057-
assert(accessNotice)
2058-
assert.equal(
2059-
await frame().getByText(accessNotice, { exact: true }).count(),
2060-
0,
2061-
'Access guidance covered the composer twice'
2062-
)
2063-
await setReference(false)
2064-
phase = 'opt-out-send'
2065-
await input().press('Enter')
2066-
await expect.poll(() => received.length).toBe(count + 1)
2067-
assert.equal(submittedPages(received[count]).length, 0)
2026+
for (const gesture of ['keyboard', 'mouse'] as const) {
2027+
await openScenario(target, `${org ? 'organization' : 'workspace'}-denied-${gesture}`)
2028+
await expect(input()).toBeVisible()
2029+
await restricted.bringToFront()
2030+
const draft = 'Keep this draft if access is unavailable'
2031+
await input().fill(draft)
2032+
count = received.length
2033+
phase = `denied-${gesture}-send`
2034+
if (gesture === 'keyboard') await input().press('Enter')
2035+
else
2036+
await frame()
2037+
.getByRole('button', { name: org ? 'Send' : 'Send message', exact: true })
2038+
.click()
2039+
await expect(
2040+
shell.getByRole('button', { name: 'Request site access', exact: true })
2041+
).toBeEnabled()
2042+
await expect(input()).toHaveValue(draft)
2043+
await expect
2044+
.poll(() => input().evaluate((element) => Boolean(element.closest('[inert]'))))
2045+
.toBe(false)
2046+
assert.equal(received.length, count)
2047+
assert(
2048+
await frame().evaluate(() => document.hasFocus()),
2049+
`The denied ${gesture} send must keep the chat document focused`
2050+
)
2051+
await expect(input()).toBeFocused()
2052+
await shell.keyboard.type(' Continue typing after the denied capture.')
2053+
await expect(input()).toHaveValue(`${draft} Continue typing after the denied capture.`)
2054+
assert.equal(received.length, count)
2055+
await screenshot(`reference-${org ? 'organization' : 'workspace'}-denied-${gesture}`)
2056+
const accessNotice = await shell
2057+
.getByRole('status')
2058+
.first()
2059+
.evaluate((status) => status.firstChild?.textContent?.trim())
2060+
assert(accessNotice)
2061+
assert.equal(
2062+
await frame().getByText(accessNotice, { exact: true }).count(),
2063+
0,
2064+
'Access guidance covered the composer twice'
2065+
)
2066+
await setReference(false)
2067+
phase = 'opt-out-send'
2068+
await input().press('Enter')
2069+
await expect.poll(() => received.length).toBe(count + 1)
2070+
assert.equal(submittedPages(received[count]).length, 0)
2071+
}
20682072
}
20692073
} finally {
20702074
await browserContext.unroute(endpoint)

0 commit comments

Comments
 (0)