Skip to content

Commit

Permalink
apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
drizzentic committed Oct 8, 2024
1 parent 70d5447 commit 2513df2
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions test/unit/upgradeDBTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ describe('Upgrade DB Tests', () => {

it('should not create duplicate roles if they already exist', async () => {
// Create an existing role
await new RoleModel({ name: 'admin' }).save()
await new RoleModel({name: 'admin'}).save()

await upgradeFunc()

Expand All @@ -583,9 +583,9 @@ describe('Upgrade DB Tests', () => {
it('should set correct permissions for each role', async () => {
await upgradeFunc()

const managerRole = await RoleModel.findOne({ name: 'manager' })
const adminRole = await RoleModel.findOne({ name: 'admin' })
const operatorRole = await RoleModel.findOne({ name: 'operator' })
const managerRole = await RoleModel.findOne({name: 'manager'})
const adminRole = await RoleModel.findOne({name: 'admin'})
const operatorRole = await RoleModel.findOne({name: 'operator'})

// Helper function to check permissions
const checkPermissions = (role, expectedPermissions) => {
Expand All @@ -600,55 +600,55 @@ describe('Upgrade DB Tests', () => {

// Admin role permissions
checkPermissions(adminRole, {
"channel-view-all": true,
"channel-manage-all": true,
"client-view-all": true,
"client-manage-all": true,
"transaction-view-all": true,
"transaction-view-body-all": true,
"transaction-rerun-all": true,
"user-view": true,
"user-manage": true,
"visualizer-manage": true,
"visualizer-view": true
'channel-view-all': true,
'channel-manage-all': true,
'client-view-all': true,
'client-manage-all': true,
'transaction-view-all': true,
'transaction-view-body-all': true,
'transaction-rerun-all': true,
'user-view': true,
'user-manage': true,
'visualizer-manage': true,
'visualizer-view': true
// Add other admin permissions as needed
})

// Manager role permissions
checkPermissions(managerRole, {
"channel-view-all": true,
"channel-manage-all": true,
"client-view-all": true,
"client-manage-all": true,
"transaction-view-all": true,
"transaction-view-body-all": true,
"transaction-rerun-all": true,
"user-view": true,
"visualizer-manage": true,
"visualizer-view": true
'channel-view-all': true,
'channel-manage-all': true,
'client-view-all': true,
'client-manage-all': true,
'transaction-view-all': true,
'transaction-view-body-all': true,
'transaction-rerun-all': true,
'user-view': true,
'visualizer-manage': true,
'visualizer-view': true
// Add other manager permissions as needed
})

// Operator role permissions
checkPermissions(operatorRole, {
"channel-view-all": true,
"transaction-view-all": true,
"transaction-view-body-all": true,
"transaction-rerun-all": true
'channel-view-all': true,
'transaction-view-all': true,
'transaction-view-body-all': true,
'transaction-rerun-all': true
// Add other operator permissions as needed
})

// Check that operator doesn't have certain permissions
should(operatorRole.permissions["user-manage"]).be.false()
should(operatorRole.permissions["client-manage-all"]).be.false()
should(operatorRole.permissions['user-manage']).be.false()
should(operatorRole.permissions['client-manage-all']).be.false()
})

it('should not create roles if they all already exist', async () => {
// Create all default roles beforehand
await Promise.all([
new RoleModel({ name: 'admin' }).save(),
new RoleModel({ name: 'manager' }).save(),
new RoleModel({ name: 'operator' }).save()
new RoleModel({name: 'admin'}).save(),
new RoleModel({name: 'manager'}).save(),
new RoleModel({name: 'operator'}).save()
])

await upgradeFunc()
Expand All @@ -659,7 +659,7 @@ describe('Upgrade DB Tests', () => {

it('should handle partial existing roles', async () => {
// Create only one default role beforehand
await new RoleModel({ name: 'admin' }).save()
await new RoleModel({name: 'admin'}).save()

await upgradeFunc()

Expand All @@ -671,4 +671,4 @@ describe('Upgrade DB Tests', () => {
roleNames.should.containEql('operator')
})
})
})
})

0 comments on commit 2513df2

Please sign in to comment.