Skip to content

Commit d0e0ea6

Browse files
committed
test(org): simplify the redesign suite and narrow what it excuses
1 parent 2aaf8f6 commit d0e0ea6

4 files changed

Lines changed: 346 additions & 434 deletions

File tree

‎.github/scripts/http-e2e.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ case "$group" in
311311
bun --no-env-file scripts/org-redesign-e2e/scripted-agent.ts 3031 \
312312
> "$report_dir/org-redesign-agent.log" 2>&1 &
313313
agent_pid=$!
314+
wait_ready "$agent_pid" http://127.0.0.1:3031/health 'scripted agent'
314315
start_app org-redesign 3029 'organization redesign' record-http-status
315316
start_realtime org-redesign 3030
316317
wait_for_browsers

‎apps/sim/scripts/org-redesign-seed.ts‎

Lines changed: 38 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import {
2323
userStats,
2424
workspace,
2525
} from '@sim/db/schema'
26+
import { assertDisposableTestDatabaseUrl } from '@sim/db/testing/test-infrastructure'
2627
import { generateId } from '@sim/utils/id'
28+
import { generateRandomHex } from '@sim/utils/random'
29+
import { normalizeEmail } from '@sim/utils/string'
2730
import { hashPassword } from 'better-auth/crypto'
2831
import { inArray } from 'drizzle-orm'
2932
import { getCredentialGroupProviderAdapter } from '@/lib/credential-groups/provider-registry'
@@ -65,11 +68,7 @@ import {
6568
* Seeds the organization `test-org-redesign-e2e.ts` runs against. Ids are stable and a rerun starts
6669
* over, so a failed run can be repeated against the same database.
6770
*/
68-
const databaseUrl = process.env.DATABASE_URL
69-
if (!databaseUrl) throw new Error('DATABASE_URL must be set')
70-
if (!/test/i.test(new URL(databaseUrl).pathname)) {
71-
throw new Error('Seed only a dedicated test database')
72-
}
71+
assertDisposableTestDatabaseUrl(process.env.DATABASE_URL ?? '')
7372

7473
const CREDENTIAL_GROUP_ID = 'org-redesign-credential-group'
7574
const allUserIds = EVERYONE.map(({ userId }) => userId)
@@ -78,43 +77,23 @@ const passwordHash = await hashPassword(PASSWORD)
7877

7978
/** Workspace access per viewer: admins hold all of it, members only what they were given. */
8079
function workspacePermissions() {
81-
const rows: {
82-
id: string
83-
userId: string
84-
entityType: 'workspace'
85-
entityId: string
80+
const rows = (
81+
viewers: readonly (typeof MEMBER | typeof ADMIN | typeof OWNER)[],
82+
entityId: string,
8683
permissionType: 'admin' | 'write'
87-
}[] = []
88-
for (const { id: entityId } of WORKSPACES) {
89-
for (const viewer of [OWNER, ADMIN]) {
90-
rows.push({
91-
id: `${entityId}-${viewer.key}`,
92-
userId: viewer.userId,
93-
entityType: 'workspace',
94-
entityId,
95-
permissionType: 'admin',
96-
})
97-
}
98-
}
99-
for (const viewer of [MEMBER, CONNECTED]) {
100-
rows.push(
101-
{
102-
id: `${MEMBER_ADMIN_WORKSPACE.id}-${viewer.key}`,
103-
userId: viewer.userId,
104-
entityType: 'workspace',
105-
entityId: MEMBER_ADMIN_WORKSPACE.id,
106-
permissionType: 'admin',
107-
},
108-
{
109-
id: `${MEMBER_WRITE_WORKSPACE.id}-${viewer.key}`,
110-
userId: viewer.userId,
111-
entityType: 'workspace',
112-
entityId: MEMBER_WRITE_WORKSPACE.id,
113-
permissionType: 'write',
114-
}
115-
)
116-
}
117-
return rows
84+
) =>
85+
viewers.map(({ key, userId }) => ({
86+
id: `${entityId}-${key}`,
87+
userId,
88+
entityType: 'workspace' as const,
89+
entityId,
90+
permissionType,
91+
}))
92+
return [
93+
...WORKSPACES.flatMap(({ id }) => rows([OWNER, ADMIN], id, 'admin')),
94+
...rows([MEMBER, CONNECTED], MEMBER_ADMIN_WORKSPACE.id, 'admin'),
95+
...rows([MEMBER, CONNECTED], MEMBER_WRITE_WORKSPACE.id, 'write'),
96+
]
11897
}
11998

12099
/** The numbered rows sort after the named ones, and creators and activity vary across them. */
@@ -164,7 +143,7 @@ await db.transaction(async (tx) => {
164143
id: userId,
165144
email,
166145
name,
167-
normalizedEmail: email.toLowerCase(),
146+
normalizedEmail: normalizeEmail(email),
168147
emailVerified: true,
169148
createdAt: now,
170149
updatedAt: now,
@@ -268,26 +247,22 @@ await db.transaction(async (tx) => {
268247
membershipMode: 'explicit',
269248
},
270249
])
271-
await tx.insert(permissionGroupMember).values([
272-
...[MEMBER, CONNECTED, ...FILLERS].map(({ key, userId }) => ({
273-
id: `org-redesign-group-member-${key}`,
274-
permissionGroupId: STANDARD_GROUP_ID,
275-
organizationId: ORGANIZATION_ID,
276-
userId,
277-
})),
278-
{
279-
id: `org-redesign-group-member-${NARROW.key}`,
280-
permissionGroupId: NARROW_GROUP_ID,
281-
organizationId: ORGANIZATION_ID,
282-
userId: NARROW.userId,
283-
},
284-
...[OWNER, ADMIN].map(({ key, userId }) => ({
285-
id: `org-redesign-group-member-${key}`,
286-
permissionGroupId: FULL_GROUP_ID,
287-
organizationId: ORGANIZATION_ID,
288-
userId,
289-
})),
290-
])
250+
await tx.insert(permissionGroupMember).values(
251+
(
252+
[
253+
[STANDARD_GROUP_ID, [MEMBER, CONNECTED, ...FILLERS]],
254+
[NARROW_GROUP_ID, [NARROW]],
255+
[FULL_GROUP_ID, [OWNER, ADMIN]],
256+
] as const
257+
).flatMap(([permissionGroupId, people]) =>
258+
people.map(({ key, userId }) => ({
259+
id: `org-redesign-group-member-${key}`,
260+
permissionGroupId,
261+
organizationId: ORGANIZATION_ID,
262+
userId,
263+
}))
264+
)
265+
)
291266

292267
for (const { id, name } of WORKSPACES) {
293268
await tx.insert(project).values({
@@ -413,7 +388,7 @@ await db.transaction(async (tx) => {
413388
credentialGroupId: CREDENTIAL_GROUP_ID,
414389
email: CONNECTED.email,
415390
status: 'completed',
416-
invitationTokenHash: generateId().replaceAll('-', '').repeat(2),
391+
invitationTokenHash: generateRandomHex(64),
417392
invitationExpiresAt: new Date(now.getTime() + 86_400_000),
418393
invitedAt: now,
419394
})

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,16 @@ try {
21182118
await expect(frame().getByRole('textbox', { name: 'Ask Sim', exact: true })).toBeVisible()
21192119
await expect(frame().getByRole('button', { name: 'Voice input', exact: true })).toBeVisible()
21202120
await expect(frame().locator('[data-platform-ui]')).toHaveCount(0)
2121+
await expect(frame().getByRole('region', { name: 'Email', exact: true })).toHaveCount(0)
2122+
assert.deepEqual(
2123+
await frame().evaluate(() =>
2124+
performance
2125+
.getEntriesByType('resource')
2126+
.map((entry) => entry.name)
2127+
.filter((name) => /\/home\/(email|calendar)|\/usage\/activity/.test(name))
2128+
),
2129+
[]
2130+
)
21212131
await screenshot('organization-new-chat')
21222132
await setPanelViewport(320, 844)
21232133
await screenshot('organization-microphone-320')

0 commit comments

Comments
 (0)