-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix journal view to display updated application names after registration changes #4554
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
85c8994
Fix journal view to display updated application names after registrat…
Copilot 665cf7b
#4476: fix process events in right order
ulischulte f62fc58
Update spring-boot-admin-server-ui/src/main/frontend/views/journal/in…
ulischulte cab3e93
#4476: fix process events in right order
ulischulte aa422f5
#4476: tests fix process events in right order
ulischulte a44e5dd
#4476: use screen to test for application names
ulischulte c5051af
#4476: use screen to test for application names
ulischulte 343a027
Merge branch 'master' into copilot/fix-4476
ulischulte 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
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
spring-boot-admin-server-ui/src/main/frontend/views/journal/index.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,124 @@ | ||
import { screen } from '@testing-library/vue'; | ||
import { HttpResponse, http } from 'msw'; | ||
import { beforeEach, describe, expect, it } from 'vitest'; | ||
|
||
import JournalView from './index.vue'; | ||
|
||
import { server } from '@/mocks/server'; | ||
import { render } from '@/test-utils'; | ||
|
||
class InstanceEvent { | ||
constructor({ instance, version, type, timestamp, ...payload }) { | ||
this.instance = instance; | ||
this.version = version; | ||
this.type = type; | ||
this.timestamp = new Date(timestamp); | ||
this.payload = payload; | ||
} | ||
|
||
get key() { | ||
return `${this.instance}-${this.version}`; | ||
} | ||
} | ||
|
||
InstanceEvent.REGISTERED = 'REGISTERED'; | ||
InstanceEvent.REGISTRATION_UPDATED = 'REGISTRATION_UPDATED'; | ||
|
||
describe('Journal View', () => { | ||
beforeEach(() => { | ||
server.use( | ||
http.get('/instances/events', () => { | ||
return HttpResponse.json([{ event: '' }]); | ||
}), | ||
); | ||
}); | ||
|
||
it('should update instance names when registration is updated', () => { | ||
const events = [ | ||
new InstanceEvent({ | ||
instance: 'instance-1', | ||
version: 1, | ||
type: 'REGISTERED', | ||
timestamp: '2023-01-01T10:00:00Z', | ||
registration: { name: 'OLD APP NAME' }, | ||
}), | ||
new InstanceEvent({ | ||
instance: 'instance-1', | ||
version: 2, | ||
type: 'REGISTRATION_UPDATED', | ||
timestamp: '2023-01-01T11:00:00Z', | ||
registration: { name: 'NEW APP NAME' }, | ||
}), | ||
]; | ||
|
||
render(JournalView, { | ||
data() { | ||
return { | ||
events: events, | ||
}; | ||
}, | ||
global: { | ||
mocks: { | ||
$t: (key) => key, | ||
$route: { query: {} }, | ||
$router: { | ||
replace: () => {}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const allByNewText = screen.getAllByText('NEW APP NAME'); | ||
|
||
expect(allByNewText).toBeDefined(); | ||
}); | ||
|
||
it('should handle both REGISTERED and REGISTRATION_UPDATED events', () => { | ||
const events = [ | ||
new InstanceEvent({ | ||
instance: 'instance-1', | ||
version: 1, | ||
type: 'REGISTERED', | ||
timestamp: '2023-01-01T10:00:00Z', | ||
registration: { name: 'App One' }, | ||
}), | ||
new InstanceEvent({ | ||
instance: 'instance-2', | ||
version: 1, | ||
type: 'REGISTERED', | ||
timestamp: '2023-01-01T10:05:00Z', | ||
registration: { name: 'App Two' }, | ||
}), | ||
new InstanceEvent({ | ||
instance: 'instance-2', | ||
version: 2, | ||
type: 'REGISTRATION_UPDATED', | ||
timestamp: '2023-01-01T11:00:00Z', | ||
registration: { name: 'App Two Updated' }, | ||
}), | ||
]; | ||
|
||
render(JournalView, { | ||
data() { | ||
return { | ||
events: events, | ||
}; | ||
}, | ||
global: { | ||
mocks: { | ||
$t: (key) => key, | ||
$route: { query: {} }, | ||
$router: { replace: () => {} }, | ||
}, | ||
}, | ||
}); | ||
|
||
const appOneText = screen.getAllByText('App One'); | ||
|
||
expect(appOneText).toBeDefined(); | ||
|
||
const appTwoText = screen.getAllByText('App Two Updated'); | ||
|
||
expect(appTwoText).toBeDefined(); | ||
}); | ||
}); |
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
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.