mirror of https://github.com/buster-so/buster.git
additional types fixes
This commit is contained in:
parent
a7aea69277
commit
b28f6e1e35
|
@ -137,7 +137,9 @@ describe('removeApprovedDomainsHandler (integration)', () => {
|
|||
const userWithoutOrg = await createUserWithoutOrganization();
|
||||
const request = { domains: ['remove1.com'] };
|
||||
|
||||
await expect(removeApprovedDomainsHandler(request, userWithoutOrg)).rejects.toThrow(HTTPException);
|
||||
await expect(removeApprovedDomainsHandler(request, userWithoutOrg)).rejects.toThrow(
|
||||
HTTPException
|
||||
);
|
||||
await expect(removeApprovedDomainsHandler(request, userWithoutOrg)).rejects.toMatchObject({
|
||||
status: 403,
|
||||
message: 'User is not associated with an organization',
|
||||
|
|
|
@ -123,19 +123,15 @@ describe('security-utils', () => {
|
|||
it('should reject other roles', () => {
|
||||
const roles = ['member', 'viewer', 'user', 'guest'];
|
||||
|
||||
roles.forEach((role) => {
|
||||
for (const role of roles) {
|
||||
expect(() => checkAdminPermissions(role)).toThrow(HTTPException);
|
||||
expect(() => checkAdminPermissions(role)).toThrow(
|
||||
'Insufficient admin permissions'
|
||||
);
|
||||
});
|
||||
expect(() => checkAdminPermissions(role)).toThrow('Insufficient admin permissions');
|
||||
}
|
||||
});
|
||||
|
||||
it('should reject null role', () => {
|
||||
expect(() => checkAdminPermissions(null)).toThrow(HTTPException);
|
||||
expect(() => checkAdminPermissions(null)).toThrow(
|
||||
'Insufficient admin permissions'
|
||||
);
|
||||
expect(() => checkAdminPermissions(null)).toThrow('Insufficient admin permissions');
|
||||
});
|
||||
|
||||
it('should reject undefined role', () => {
|
||||
|
@ -158,12 +154,12 @@ describe('security-utils', () => {
|
|||
it('should reject other roles', () => {
|
||||
const roles = ['admin', 'member', 'viewer', 'user'];
|
||||
|
||||
roles.forEach((role) => {
|
||||
for (const role of roles) {
|
||||
expect(() => checkWorkspaceAdminPermission(role)).toThrow(HTTPException);
|
||||
expect(() => checkWorkspaceAdminPermission(role)).toThrow(
|
||||
'Only workspace admins can update workspace settings'
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should reject null role', () => {
|
||||
|
|
|
@ -29,7 +29,9 @@ export async function createTestUserInDb(userData: Partial<User> = {}): Promise<
|
|||
// Try to clean up any partial user data
|
||||
await db.delete(usersToOrganizations).where(eq(usersToOrganizations.userId, id));
|
||||
// Re-throw to let the test handle it
|
||||
throw new Error(`Failed to create test user: Database trigger tried to add user to non-existent organization. ${error.message}`);
|
||||
throw new Error(
|
||||
`Failed to create test user: Database trigger tried to add user to non-existent organization. ${error.message}`
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
@ -68,12 +70,7 @@ export async function createTestOrgMemberInDb(
|
|||
const existing = await db
|
||||
.select()
|
||||
.from(usersToOrganizations)
|
||||
.where(
|
||||
and(
|
||||
eq(usersToOrganizations.userId, userId),
|
||||
isNull(usersToOrganizations.deletedAt)
|
||||
)
|
||||
);
|
||||
.where(and(eq(usersToOrganizations.userId, userId), isNull(usersToOrganizations.deletedAt)));
|
||||
|
||||
if (existing.length > 0) {
|
||||
// Delete existing memberships silently
|
||||
|
@ -136,7 +133,8 @@ export async function cleanupTestOrganization(orgId: string): Promise<void> {
|
|||
.limit(1);
|
||||
|
||||
if (pgResult[0]) {
|
||||
await db.delete(datasetsToPermissionGroups)
|
||||
await db
|
||||
.delete(datasetsToPermissionGroups)
|
||||
.where(eq(datasetsToPermissionGroups.permissionGroupId, pgResult[0].id));
|
||||
}
|
||||
|
||||
|
@ -161,7 +159,10 @@ export async function getOrganizationFromDb(orgId: string): Promise<Organization
|
|||
}
|
||||
|
||||
// Helper to verify user organization membership
|
||||
export async function verifyUserOrgMembership(userId: string, organizationId: string): Promise<{
|
||||
export async function verifyUserOrgMembership(
|
||||
userId: string,
|
||||
organizationId: string
|
||||
): Promise<{
|
||||
organizationId: string;
|
||||
role: string;
|
||||
} | null> {
|
||||
|
|
|
@ -47,7 +47,14 @@ describe('WorkspaceSettingsService', () => {
|
|||
});
|
||||
|
||||
it('should handle all string values correctly', () => {
|
||||
const roles = ['workspace_admin', 'data_admin', 'querier', 'restricted_querier', 'viewer', 'none'];
|
||||
const roles = [
|
||||
'workspace_admin',
|
||||
'data_admin',
|
||||
'querier',
|
||||
'restricted_querier',
|
||||
'viewer',
|
||||
'none',
|
||||
];
|
||||
|
||||
roles.forEach((role) => {
|
||||
const settings = {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||
"extends": ["../../biome.json"],
|
||||
"overrides": [
|
||||
{
|
||||
"include": ["**/*.ts"],
|
||||
"linter": {
|
||||
"rules": {
|
||||
"suspicious": {
|
||||
"noConsoleLog": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -2,5 +2,8 @@
|
|||
"name": "@buster/supabase",
|
||||
"version": "0.0.1",
|
||||
"private": false,
|
||||
"scripts": {}
|
||||
"scripts": {
|
||||
"lint": "biome check .",
|
||||
"lint:fix": "biome check . --write"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"extends": "../typescript-config/base.json",
|
||||
"include": ["volumes/**/*"]
|
||||
}
|
Loading…
Reference in New Issue