Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Audit widget RELEASE #118

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"cSpell.words": ["setversion"]
"cSpell.words": ["setversion"],
"workbench.colorCustomizations": {
dorsha marked this conversation as resolved.
Show resolved Hide resolved
"activityBar.background": "#29310A",
"titleBar.activeBackground": "#39450E",
"titleBar.activeForeground": "#F9FCEF"
}
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,19 @@ The widget lets you:
Example:
[Manage Access Keys](./projects/demo-app/src/app/manage-access-keys/manage-access-keys.component.html)

#### AuditManagement

The `AuditManagement` widget will let you embed an audit table in your site.

###### Usage

```html
<audit-management tenant="tenant-id" widgetId="audit-management-widget" />
```

Example:
[Manage Audit](./projects/demo-app/src/app/manage-audit/manage-audit.component.html)

## Code Example

You can find an example angular app in the [examples folder](./projects/demo-app).
Expand Down
136 changes: 77 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
]
},
"dependencies": {
"@descope/user-management-widget": "0.4.27",
"@descope/role-management-widget": "0.1.26",
"@descope/access-key-management-widget": "0.1.26",
"@descope/web-component": "3.8.32",
"@descope/access-key-management-widget": "0.1.35",
"@descope/audit-management-widget": "0.1.0",
"@descope/role-management-widget": "0.1.35",
"@descope/user-management-widget": "0.4.36",
"@descope/web-component": "3.8.39",
"tslib": "^2.3.0"
},
"optionalDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion projects/angular-sdk/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@descope/web-component",
"@descope/user-management-widget",
"@descope/role-management-widget",
"@descope/access-key-management-widget"
"@descope/access-key-management-widget",
"@descope/audit-management-widget"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuditManagementComponent } from './audit-management.component';
import createSdk from '@descope/web-js-sdk';
import { DescopeAuthConfig } from '../../types/types';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import mocked = jest.mocked;

jest.mock('@descope/web-js-sdk');
//Mock DescopeAuditManagementWidget
jest.mock('@descope/audit-management-widget', () => {
return jest.fn(() => {
// Create a mock DOM element
return document.createElement('descope-audit-management-widget');
});
});

describe('DescopeAuditManagementComponent', () => {
let component: AuditManagementComponent;
let fixture: ComponentFixture<AuditManagementComponent>;
let mockedCreateSdk: jest.Mock;
const onSessionTokenChangeSpy = jest.fn();
const onAuditChangeSpy = jest.fn();
const afterRequestHooksSpy = jest.fn();
const mockConfig: DescopeAuthConfig = {
projectId: 'someProject'
};

beforeEach(() => {
mockedCreateSdk = mocked(createSdk);

mockedCreateSdk.mockReturnValue({
onSessionTokenChange: onSessionTokenChangeSpy,
onAuditChange: onAuditChangeSpy,
httpClient: {
hooks: {
afterRequest: afterRequestHooksSpy
}
}
});

TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
DescopeAuthConfig,
{ provide: DescopeAuthConfig, useValue: mockConfig }
]
});

fixture = TestBed.createComponent(AuditManagementComponent);
component = fixture.componentInstance;
component.projectId = '123';
component.tenant = 'tenant-1';
component.widgetId = 'widget-1';
component.logger = { info: jest.fn(), error: jest.fn(), warn: jest.fn() };
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
const html: HTMLElement = fixture.nativeElement;
const webComponentHtml = html.querySelector(
'descope-audit-management-widget'
);
expect(webComponentHtml).toBeDefined();
});

it('should correctly setup attributes based on inputs', () => {
const html: HTMLElement = fixture.nativeElement;
const webComponentHtml = html.querySelector(
'descope-audit-management-widget'
)!;
expect(webComponentHtml.getAttribute('project-id')).toStrictEqual('123');
expect(webComponentHtml.getAttribute('tenant')).toStrictEqual('tenant-1');
expect(webComponentHtml.getAttribute('widget-id')).toStrictEqual(
'widget-1'
);
expect(webComponentHtml.getAttribute('logger')).toBeDefined();
});
});
Loading
Loading