Skip to content

Commit 4e3185a

Browse files
committed
test(extension): cover release review regressions
1 parent d887612 commit 4e3185a

4 files changed

Lines changed: 78 additions & 16 deletions

File tree

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,28 @@ try {
532532
}
533533
assert(snapshot.url === `${pageOrigin}/ticket`, 'Source URL contains query or fragment')
534534
})
535-
await check('Selection attaches only the selected excerpt', async () => {
535+
await check('A focused read-only custom element attaches only the selected excerpt', async () => {
536536
await page.evaluate(() => {
537537
const selected = document.getElementById('selected')
538538
if (!selected) throw new Error('Missing selection fixture')
539+
customElements.define('readable-article', class extends HTMLElement {})
540+
const host = document.createElement('readable-article')
541+
host.tabIndex = 0
542+
selected.replaceWith(host)
543+
host.append(selected)
544+
host.focus()
539545
const range = document.createRange()
540546
range.selectNodeContents(selected)
541-
window.getSelection()?.removeAllRanges()
542-
window.getSelection()?.addRange(range)
547+
const selection = window.getSelection()
548+
selection?.removeAllRanges()
549+
selection?.addRange(range)
550+
if (
551+
document.activeElement !== host ||
552+
host.isContentEditable ||
553+
host.shadowRoot ||
554+
selection?.toString() !== selected.textContent
555+
)
556+
throw new Error('Fixture did not focus and select ordinary custom-element text')
543557
})
544558
await capture('Selection')
545559
await app.waitForFunction(
@@ -551,6 +565,7 @@ try {
551565
snapshot.text === 'The customer needs a replacement by Friday.',
552566
'Selection widened beyond the user excerpt'
553567
)
568+
await page.locator('readable-article').evaluate((host) => host.replaceWith(...host.childNodes))
554569
})
555570
await check('A focused child frame cannot substitute an old parent-page selection', async () => {
556571
await page.evaluate(() => {

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,11 +2030,24 @@ try {
20302030
await input().fill(draft)
20312031
count = received.length
20322032
phase = 'denied-send'
2033-
await input().press('Enter')
2033+
await frame()
2034+
.getByRole('button', { name: org ? 'Send' : 'Send message', exact: true })
2035+
.click()
20342036
await expect(
20352037
shell.getByRole('button', { name: 'Request site access', exact: true })
20362038
).toBeEnabled()
20372039
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.`)
20382051
assert.equal(received.length, count)
20392052
await screenshot(`reference-${org ? 'organization' : 'workspace'}-denied`)
20402053
const accessNotice = await shell

‎apps/sim/scripts/test-landing-seo-e2e.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,34 @@ async function run() {
327327
assert.deepEqual(failures, [])
328328
})
329329

330+
await check(
331+
'legacy Sim aliases preserve queries without redirecting the Sim Links entry',
332+
async () => {
333+
const entry = await get('/sim')
334+
assert.equal(entry.status, 307)
335+
assert(entry.location, 'The Sim Links entry must offer sign-in')
336+
const login = new URL(entry.location, baseUrl)
337+
assert.equal(login.pathname, '/login')
338+
assert.equal(login.searchParams.get('callbackUrl'), '/sim')
339+
for (const path of ['/Sim', '/SIM', '/sIm']) {
340+
const { status, location } = await get(`${path}?home&utm_source=legacy`)
341+
assert.equal(status, 308, path)
342+
assert(location, `${path}: expected the legacy homepage redirect`)
343+
const target = new URL(location, baseUrl)
344+
assert.equal(target.origin, baseUrl.origin, path)
345+
assert.equal(target.pathname, '/', path)
346+
assert.deepEqual(
347+
[...target.searchParams],
348+
[
349+
['home', ''],
350+
['utm_source', 'legacy'],
351+
],
352+
path
353+
)
354+
}
355+
}
356+
)
357+
330358
await check('integration sitemap dates are per integration, not one catalog date', async () => {
331359
const mismatches: string[] = []
332360
for (const integration of integrations) {

‎apps/sim/scripts/test-sim-links-e2e.ts‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -403,24 +403,30 @@ async function run() {
403403
await api({ ...outsider, orgId }, '', { expected: 404 })
404404
})
405405

406-
await check(
407-
'a team bookmark keeps its organization across sign-in and a same-name link elsewhere',
408-
async () => {
409-
const name = 'managed-help'
410-
const path = `/sim-links/${encodeURIComponent(orgId)}/${name}`
411-
const destination = 'https://team.example.com/help'
406+
await check('team bookmarks preserve encoded names and organization across sign-in', async () => {
407+
const destination = 'https://team.example.com/help'
408+
for (const name of ['managed-help', 'managed:help@team&docs']) {
409+
const path = `/sim-links/${encodeURIComponent(orgId)}/${encodeURIComponent(name)}`
412410
await create(owner, { name, url: destination })
413411
await create(outsider, { name, url: 'https://another-team.example.com/help' })
414412
const signedOut = await send(path, null)
413+
assert.equal(signedOut.status, 307, `${name}: expected sign-in redirect`)
415414
const login = new URL(signedOut.headers.get('location') ?? '/', baseUrl)
416-
assert.equal(login.pathname, '/login')
417-
assert.equal(login.searchParams.get('callbackUrl'), path)
418-
assert.equal((await send(path, member)).headers.get('location'), destination)
415+
assert.equal(login.pathname, '/login', name)
416+
assert.equal(login.searchParams.get('callbackUrl'), path, name)
417+
const opened = await send(path, member)
418+
assert.equal(opened.status, 307, `${name}: expected destination redirect`)
419+
assert.equal(opened.headers.get('location'), destination, name)
419420
const denied = await send(path, outsider)
420-
assert.equal(denied.status, 404)
421-
assert(!denied.headers.get('location'))
421+
assert.equal(denied.status, 404, name)
422+
assert(!denied.headers.get('location'), name)
422423
}
423-
)
424+
for (const encodedName of ['%256Danaged-help', 'managed%2Fhelp']) {
425+
const denied = await send(`/sim-links/${encodeURIComponent(orgId)}/${encodedName}`, member)
426+
assert.equal(denied.status, 404, encodedName)
427+
assert(!denied.headers.get('location'), encodedName)
428+
}
429+
})
424430

425431
await check(
426432
'bookmark export requires admin access and drops stale or foreign selections',

0 commit comments

Comments
 (0)