Skip to content

Commit 4e5757a

Browse files
committed
test(org): prove each page's first paint from its server seeds
1 parent 5b53bc5 commit 4e5757a

1 file changed

Lines changed: 56 additions & 6 deletions

File tree

‎apps/sim/scripts/test-org-redesign-e2e.ts‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,12 +2747,17 @@ async function blastRadiusChecks() {
27472747
const PREFETCHED_ON_LAYOUT = [
27482748
{ label: 'chat list', pattern: /^\/api\/mothership\/chats\?/ },
27492749
{ label: 'profile', pattern: /^\/api\/users\/me\/profile/ },
2750+
{ label: 'workspace list', pattern: /^\/api\/workspaces(\?|$)/ },
27502751
]
2751-
const PREFETCHED_ON_HOME = [
2752+
const PREFETCHED_INVENTORY = [
27522753
{ label: 'connected accounts', pattern: /\/connected-accounts(\?|$)/ },
27532754
{ label: 'search integrations', pattern: /\/api\/knowledge\/sim-search\/integrations/ },
2754-
{ label: 'search history', pattern: /\/search\/history(\?|$)/ },
27552755
]
2756+
const PREFETCHED_HISTORY = [{ label: 'search history', pattern: /\/search\/history(\?|$)/ }]
2757+
const PREFETCHED_SECRET_SOURCE = [
2758+
{ label: 'secret source', pattern: /\/secrets\/source|\/secret-source/ },
2759+
]
2760+
const PREFETCHED_LINKS = [{ label: 'links first page', pattern: /\/sim-links(\?(?!.*cursor=)|$)/ }]
27562761

27572762
async function firstPaintChecks() {
27582763
section('6 First paint')
@@ -2761,32 +2766,77 @@ async function firstPaintChecks() {
27612766
name: 'Home',
27622767
path: 'home',
27632768
primary: (page: Page) => composer(page),
2764-
prefetched: [...PREFETCHED_ON_LAYOUT, ...PREFETCHED_ON_HOME],
2769+
prefetched: [...PREFETCHED_ON_LAYOUT, ...PREFETCHED_INVENTORY, ...PREFETCHED_HISTORY],
27652770
},
27662771
{
27672772
name: 'Search',
27682773
path: 'search?mode=search',
27692774
primary: (page: Page) => searchField(page),
2770-
prefetched: PREFETCHED_ON_LAYOUT,
2775+
prefetched: [...PREFETCHED_ON_LAYOUT, ...PREFETCHED_HISTORY],
27712776
},
27722777
{
27732778
name: 'Integrations',
27742779
path: 'integrations',
27752780
primary: (page: Page) => page.getByRole('link', { name: /^Gmail/ }),
2776-
prefetched: PREFETCHED_ON_LAYOUT,
2781+
prefetched: [...PREFETCHED_ON_LAYOUT, ...PREFETCHED_INVENTORY, ...PREFETCHED_SECRET_SOURCE],
27772782
},
27782783
{
27792784
name: 'Links',
27802785
path: 'links',
27812786
primary: (page: Page) => page.getByRole('row').nth(1),
2782-
prefetched: PREFETCHED_ON_LAYOUT,
2787+
prefetched: [...PREFETCHED_ON_LAYOUT, ...PREFETCHED_LINKS],
2788+
},
2789+
{
2790+
name: 'Links by opens',
2791+
path: 'links?sort=popular&dir=desc',
2792+
primary: (page: Page) => page.getByRole('row').nth(1),
2793+
prefetched: [...PREFETCHED_ON_LAYOUT, ...PREFETCHED_LINKS],
27832794
},
27842795
] satisfies {
27852796
name: string
27862797
path: string
27872798
primary: (page: Page) => Locator
27882799
prefetched: { label: string; pattern: RegExp }[]
27892800
}[]
2801+
await check(
2802+
'Links paints its first page from the server, even with the client read refused',
2803+
async () => {
2804+
await withSession(MEMBER, async ({ page }) => {
2805+
const reads: string[] = []
2806+
await page.route(`**/api/organizations/${ORGANIZATION_ID}/sim-links**`, (route) => {
2807+
reads.push(route.request().url())
2808+
return route.fulfill({ status: 500, json: { error: 'The client must not need this' } })
2809+
})
2810+
await page.goto(url(`${root}/links`))
2811+
await expect(
2812+
page.getByRole('row').filter({ hasText: NAMED_LINKS.handbook.name })
2813+
).toBeVisible()
2814+
await expect(page.getByRole('button', { name: /Retry/ })).toHaveCount(0)
2815+
assert.deepEqual(
2816+
reads.filter((address) => !address.includes('cursor=')),
2817+
[],
2818+
'The seeded first page was fetched again'
2819+
)
2820+
await page.goto(url(`${root}/links?sort=popular&dir=desc`))
2821+
await expect(page.getByRole('row').nth(1)).toContainText(NAMED_LINKS.mostUsed.name)
2822+
await page.goto(url(`${root}/links?search=${NAMED_LINKS.mostUsed.name}`))
2823+
await expect(page.getByRole('row').nth(1)).toContainText(NAMED_LINKS.mostUsed.name)
2824+
assert.deepEqual(
2825+
reads.filter((address) => !address.includes('cursor=')),
2826+
[],
2827+
'A seeded view of the URL was fetched again'
2828+
)
2829+
})
2830+
},
2831+
{ allow: [/sim-links/] }
2832+
)
2833+
await check('the Links document already carries the first page of rows', async () => {
2834+
await withSession(MEMBER, async ({ page, context }) => {
2835+
await page.goto(url(`${root}/home`))
2836+
const html = await (await context.request.get(url(`${root}/links`))).text()
2837+
assert(html.includes(NAMED_LINKS.handbook.url), 'The document holds the seeded rows')
2838+
})
2839+
})
27902840
for (const persona of [MEMBER, ADMIN]) {
27912841
for (const entry of pages) {
27922842
await check(

0 commit comments

Comments
 (0)