-
Notifications
You must be signed in to change notification settings - Fork 480
Update usage dashboard UI to match official dotCMS UI #34168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+571
−680
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
214200c
Refactor dot-usage-shell component for improved UI and structure
fmontes f3201ce
Update dot-usage-shell component for improved skeleton loading and st…
fmontes 81bd166
Enhance dot-usage-shell component with last updated timestamp
fmontes 66503e6
Refactor dot-usage component tests to use structured metrics format
fmontes 879ce37
Refactor dot-usage service and shell component tests to utilize new H…
fmontes 67e26d1
Add dot-usage service and tests for usage summary functionality
fmontes 317f1ad
Enhance DotUsageShellComponent tests to improve error handling and lo…
fmontes daa6ae1
Add informational message to DotUsageShellComponent for analytics upd…
fmontes 625dde3
Enhance DotUsageShellComponent with accessibility improvements and er…
fmontes d9eada7
Merge branch 'main' into issue-34166-usage-ui
fmontes 1211afb
fix build
fmontes 6d8a1ca
chore: clean up
fmontes d3b0590
Merge branch 'main' into issue-34166-usage-ui
fmontes dbac361
chore: fix lint
fmontes 2603b96
chore: format
fmontes 9b2f2b7
Merge branch 'main' into issue-34166-usage-ui
sfreudenthaler aa6b778
Merge branch 'main' into issue-34166-usage-ui
fmontes c8fbcce
Merge branch 'main' into issue-34166-usage-ui
sfreudenthaler dfb8d81
Merge branch 'main' into issue-34166-usage-ui
sfreudenthaler 8ae2666
chore: trigger CI with timeout fixes from main
sfreudenthaler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
203 changes: 203 additions & 0 deletions
203
core-web/libs/data-access/src/lib/dot-usage/dot-usage.service.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| import { provideHttpClient, HttpErrorResponse } from '@angular/common/http'; | ||
| import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing'; | ||
| import { TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { DotUsageService, UsageApiResponse, UsageSummary } from './dot-usage.service'; | ||
|
|
||
| describe('DotUsageService', () => { | ||
| let service: DotUsageService; | ||
| let httpMock: HttpTestingController; | ||
|
|
||
| const mockSummary: UsageSummary = { | ||
| metrics: { | ||
| content: { | ||
| COUNT_CONTENT: { | ||
| name: 'COUNT_CONTENT', | ||
| value: 1500, | ||
| displayLabel: 'usage.metric.COUNT_CONTENT' | ||
| } | ||
| }, | ||
| site: { | ||
| COUNT_OF_SITES: { | ||
| name: 'COUNT_OF_SITES', | ||
| value: 5, | ||
| displayLabel: 'usage.metric.COUNT_OF_SITES' | ||
| } | ||
| }, | ||
| user: { | ||
| COUNT_OF_USERS: { | ||
| name: 'COUNT_OF_USERS', | ||
| value: 60, | ||
| displayLabel: 'usage.metric.COUNT_OF_USERS' | ||
| } | ||
| }, | ||
| system: { | ||
| COUNT_LANGUAGES: { | ||
| name: 'COUNT_LANGUAGES', | ||
| value: 3, | ||
| displayLabel: 'usage.metric.COUNT_LANGUAGES' | ||
| } | ||
| } | ||
| }, | ||
| lastUpdated: '2024-01-15T15:30:00Z' | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| TestBed.configureTestingModule({ | ||
| providers: [provideHttpClient(), provideHttpClientTesting(), DotUsageService] | ||
| }); | ||
|
|
||
| service = TestBed.inject(DotUsageService); | ||
| httpMock = TestBed.inject(HttpTestingController); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| httpMock.verify(); | ||
| }); | ||
|
|
||
| it('should be created', () => { | ||
| expect(service).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('should get summary successfully', (done) => { | ||
| const mockResponse: UsageApiResponse = { entity: mockSummary }; | ||
|
|
||
| service.getSummary().subscribe((summary) => { | ||
| expect(summary).toEqual(mockSummary); | ||
| done(); | ||
| }); | ||
|
|
||
| const req = httpMock.expectOne('/api/v1/usage/summary'); | ||
| expect(req.request.method).toBe('GET'); | ||
| req.flush(mockResponse); | ||
| }); | ||
|
|
||
| it('should handle HTTP errors', (done) => { | ||
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(); | ||
|
|
||
| service.getSummary().subscribe({ | ||
| next: () => fail('Should have failed'), | ||
| error: (error) => { | ||
| expect(error.status).toBe(401); | ||
| errorSpy.mockRestore(); | ||
| done(); | ||
| } | ||
| }); | ||
|
|
||
| const req = httpMock.expectOne('/api/v1/usage/summary'); | ||
| req.flush('Unauthorized', { status: 401, statusText: 'Unauthorized' }); | ||
| }); | ||
|
|
||
| it('should handle server errors', (done) => { | ||
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(); | ||
|
|
||
| service.getSummary().subscribe({ | ||
| next: () => fail('Should have failed'), | ||
| error: (error) => { | ||
| expect(error.status).toBe(500); | ||
| errorSpy.mockRestore(); | ||
| done(); | ||
| } | ||
| }); | ||
|
|
||
| const req = httpMock.expectOne('/api/v1/usage/summary'); | ||
| req.flush('Internal Server Error', { status: 500, statusText: 'Internal Server Error' }); | ||
| }); | ||
|
|
||
| it('should get error message for 401', () => { | ||
| const error = { status: 401 } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.unauthorized'); | ||
| }); | ||
|
|
||
| it('should get error message for 403', () => { | ||
| const error = { status: 403 } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.forbidden'); | ||
| }); | ||
|
|
||
| it('should get error message for 404', () => { | ||
| const error = { status: 404 } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.notFound'); | ||
| }); | ||
|
|
||
| it('should get error message for 408', () => { | ||
| const error = { status: 408 } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.timeout'); | ||
| }); | ||
|
|
||
| it('should get error message for 500', () => { | ||
| const error = { status: 500 } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.serverError'); | ||
| }); | ||
|
|
||
| it('should get error message for 502', () => { | ||
| const error = { status: 502 } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.badGateway'); | ||
| }); | ||
|
|
||
| it('should get error message for 503', () => { | ||
| const error = { status: 503 } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.serviceUnavailable'); | ||
| }); | ||
|
|
||
| it('should get error message for unknown status', () => { | ||
| const error = { status: 418 } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.requestFailed'); | ||
| }); | ||
|
|
||
| it('should get error message from error.error.message', () => { | ||
| const error = { | ||
| error: { message: 'Custom error message' }, | ||
| status: 400 | ||
| } as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('Custom error message'); | ||
| }); | ||
|
|
||
| it('should get generic error message when no status', () => { | ||
| const error = {} as HttpErrorResponse; | ||
| expect(service.getErrorMessage(error)).toBe('usage.dashboard.error.generic'); | ||
| }); | ||
|
|
||
| it('should refresh data', (done) => { | ||
| const mockResponse: UsageApiResponse = { entity: mockSummary }; | ||
|
|
||
| service.refresh().subscribe((summary) => { | ||
| expect(summary).toEqual(mockSummary); | ||
| done(); | ||
| }); | ||
|
|
||
| const req = httpMock.expectOne('/api/v1/usage/summary'); | ||
| req.flush(mockResponse); | ||
| }); | ||
|
|
||
| it('should handle concurrent requests properly', () => { | ||
| const spy = jest.spyOn(console, 'error').mockImplementation(); | ||
|
|
||
| // Start two requests simultaneously | ||
| service.getSummary().subscribe(); | ||
| service.getSummary().subscribe(); | ||
|
|
||
| const requests = httpMock.match('/api/v1/usage/summary'); | ||
| expect(requests.length).toBe(2); | ||
|
|
||
| // Fulfill both requests | ||
| requests[0].flush({ entity: mockSummary }); | ||
| requests[1].flush({ entity: mockSummary }); | ||
|
|
||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('should validate response structure', (done) => { | ||
| const invalidResponse = { invalidProperty: 'test' }; | ||
|
|
||
| service.getSummary().subscribe({ | ||
| next: (summary) => { | ||
| // Should handle invalid response gracefully | ||
| expect(summary).toBeDefined(); | ||
| done(); | ||
| } | ||
| }); | ||
|
|
||
| const req = httpMock.expectOne('/api/v1/usage/summary'); | ||
| req.flush({ entity: invalidResponse }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| export * from './lib/dot-usage-shell/dot-usage-shell.component'; | ||
| export * from './lib/services/dot-usage.service'; | ||
| export * from './lib.routes'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.