Repository navigation
Display event release lifecycle badges and details #928
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
Open
alisawavezen12
wants to merge
8
commits into
master
Choose a base branch
from
feat/event-release-status
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
15c9db4
Add event release lifecycle status and details
alisawavezen12 6545492
chore
alisawavezen12 53238ec
Clarify release status and latest release context
alisawavezen12 e72317b
Show release status alongside truncated event titles
alisawavezen12 168fa1b
Show current occurrence alongside lifecycle releases
alisawavezen12 499a020
Cache project releases in Vuex and fetch lazily
alisawavezen12 8b822d1
Use server-provided event novelty for release badges
alisawavezen12 e89fa70
Allow partial errors when fetching project releases
alisawavezen12 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
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
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
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,139 @@ | ||
| import { afterEach, describe, expect, it } from 'vitest'; | ||
| import { createApp, h, nextTick, reactive, type App } from 'vue'; | ||
| import { createI18n } from 'vue-i18n'; | ||
| import en from '../../i18n/messages/en.json'; | ||
| import ru from '../../i18n/messages/ru.json'; | ||
| import type { HawkEvent } from '../../types/events'; | ||
| import EventReleaseStatus from './EventReleaseStatus.vue'; | ||
|
|
||
| type ReleaseState = Pick<HawkEvent, 'firstSeenInRelease' | 'resolvedInRelease' | 'regressionInRelease' | 'isNew'>; | ||
|
|
||
| let app: App | undefined; | ||
| let host: HTMLDivElement; | ||
|
|
||
| afterEach(() => { | ||
| app?.unmount(); | ||
| host.remove(); | ||
| }); | ||
|
|
||
| /** | ||
| * Mount the badge with the real translations and reactive event state. | ||
| * @param event - lifecycle fields from the event | ||
| * @param locale - UI language | ||
| * @returns badge container | ||
| */ | ||
| function mount(event: ReleaseState, locale = 'en'): HTMLDivElement { | ||
| host = document.createElement('div'); | ||
| document.body.append(host); | ||
| app = createApp({ render: () => h(EventReleaseStatus, { event }) }); | ||
| app.use(createI18n({ legacy: false, | ||
| locale, | ||
| messages: { en, | ||
| ru } })); | ||
| app.mount(host); | ||
|
|
||
| return host; | ||
| } | ||
|
|
||
| describe('EventReleaseStatus', () => { | ||
| it.each([ | ||
| {}, | ||
| { firstSeenInRelease: null, | ||
| resolvedInRelease: null, | ||
| regressionInRelease: null }, | ||
| ])('hides the badge without lifecycle data: %j', (event) => { | ||
| expect(mount(event).querySelector('.event-release-status')).toBeNull(); | ||
| expect(host.textContent).toBe(''); | ||
| }); | ||
|
|
||
| it.each([undefined, null, '', ' ', 'null', 'undefined', ' NULL ', ' Undefined ', 'NaN'])( | ||
| 'hides non-meaningful release values: %j', (release) => { | ||
| expect(mount({ firstSeenInRelease: release, | ||
| resolvedInRelease: release, | ||
| regressionInRelease: release, | ||
| isNew: true }).querySelector('.event-release-status')).toBeNull(); | ||
| } | ||
| ); | ||
|
|
||
| it('falls back to valid metadata when higher-priority fields are placeholders', () => { | ||
| mount({ firstSeenInRelease: 'original', | ||
| resolvedInRelease: 'fixed', | ||
| regressionInRelease: 'null' }); | ||
| expect(host.textContent?.trim()).toBe('Resolved'); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ['en', 'firstSeen', { firstSeenInRelease: 'build/start#1' }, 'New', | ||
| 'The event first appeared in release build/start#1, the project\'s latest release.'], | ||
| ['ru', 'firstSeen', { firstSeenInRelease: 'build/start#1' }, 'Новое', | ||
| 'Событие впервые появилось в релизе build/start#1. Это последний релиз проекта.'], | ||
| ['en', 'resolved', { firstSeenInRelease: 'z-original', | ||
| resolvedInRelease: 'a-fixed' }, 'Resolved', | ||
| 'No occurrences observed starting with release a-fixed. This is an automatic estimate: the event may be fixed.'], | ||
| ['ru', 'resolved', { firstSeenInRelease: 'z-original', | ||
| resolvedInRelease: 'a-fixed' }, 'Исправлено', | ||
| 'Не наблюдалось начиная с релиза a-fixed. Это автоматическая оценка: событие потенциально исправлено.'], | ||
| ['en', 'regression', { firstSeenInRelease: 'z-original', | ||
| resolvedInRelease: 'z-fixed', | ||
| regressionInRelease: 'a/again#2' }, 'Regression', | ||
| 'The event reappeared in release a/again#2 after it was considered fixed.'], | ||
| ['ru', 'regression', { firstSeenInRelease: 'z-original', | ||
| resolvedInRelease: 'z-fixed', | ||
| regressionInRelease: 'a/again#2' }, 'Регрессия', | ||
| 'Событие вернулось в релизе a/again#2 после предполагаемого исправления.'], | ||
| ] as const)('renders %s %s with the server flag and lifecycle priority', (locale, status, event, label, tooltip) => { | ||
| const badge = mount({ ...event, | ||
| isNew: true }, locale).querySelector('.event-release-status'); | ||
|
|
||
| expect(badge?.textContent?.trim()).toBe(label); | ||
| expect(badge?.getAttribute('title')).toBe(tooltip); | ||
| expect(badge?.classList.contains(`event-release-status--${status}`)).toBe(true); | ||
| expect(host.querySelectorAll('.event-release-status')).toHaveLength(1); | ||
| for (const release of Object.values(event)) { | ||
| expect(badge?.textContent).not.toContain(release); | ||
| } | ||
| }); | ||
|
|
||
| it.each([undefined, false])( | ||
| 'hides the new badge when isNew is unavailable or false: %j', (isNew) => { | ||
| mount({ firstSeenInRelease: 'original', | ||
| isNew }); | ||
| expect(host.querySelector('.event-release-status')).toBeNull(); | ||
| } | ||
| ); | ||
|
|
||
| it('removes the new badge when the server flag changes', async () => { | ||
| const event = reactive<ReleaseState>({ firstSeenInRelease: 'current', | ||
| isNew: true }); | ||
|
|
||
| mount(event); | ||
| expect(host.textContent?.trim()).toBe('New'); | ||
|
|
||
| event.isNew = false; | ||
| await nextTick(); | ||
| expect(host.querySelector('.event-release-status')).toBeNull(); | ||
| }); | ||
|
|
||
| it('returns to resolved when a regression is cleared reactively', async () => { | ||
| const event = reactive<ReleaseState>({ | ||
| firstSeenInRelease: 'original', | ||
| resolvedInRelease: 'z-fixed', | ||
| regressionInRelease: 'a-regression', | ||
| }); | ||
|
|
||
| mount(event); | ||
| expect(host.textContent?.trim()).toBe('Regression'); | ||
|
|
||
| event.regressionInRelease = null; | ||
| await nextTick(); | ||
|
|
||
| const badge = host.querySelector('.event-release-status'); | ||
|
|
||
| expect(badge?.textContent?.trim()).toBe('Resolved'); | ||
| expect(badge?.getAttribute('title')).toBe( | ||
| 'No occurrences observed starting with release z-fixed. This is an automatic estimate: the event may be fixed.' | ||
| ); | ||
| expect(badge?.classList.contains('event-release-status--resolved')).toBe(true); | ||
| expect(badge?.classList.contains('event-release-status--regression')).toBe(false); | ||
| }); | ||
| }); |
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,97 @@ | ||
| <template> | ||
| <span | ||
| v-if="status" | ||
| class="event-release-status" | ||
| :class="`event-release-status--${status}`" | ||
| :title="tooltip" | ||
| > | ||
| {{ $t(`event.releaseStatus.${status}`) }} | ||
| </span> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| import { defineComponent, type PropType } from 'vue'; | ||
| import type { HawkEvent } from '@/types/events'; | ||
| import { isMeaningfulRelease } from '@/utils'; | ||
|
|
||
| type EventReleaseState = Pick<HawkEvent, 'firstSeenInRelease' | 'resolvedInRelease' | 'regressionInRelease' | 'isNew'>; | ||
|
|
||
| export default defineComponent({ | ||
| name: 'EventReleaseStatus', | ||
| props: { | ||
|
|
||
| event: { | ||
| type: Object as PropType<EventReleaseState>, | ||
| required: true, | ||
| }, | ||
| }, | ||
| computed: { | ||
| /** | ||
| * A regression supersedes the previous resolution; release names are opaque. | ||
| */ | ||
| status(): 'firstSeen' | 'resolved' | 'regression' | null { | ||
| if (isMeaningfulRelease(this.event.regressionInRelease)) { | ||
| return 'regression'; | ||
| } | ||
|
|
||
| if (isMeaningfulRelease(this.event.resolvedInRelease)) { | ||
| return 'resolved'; | ||
| } | ||
|
|
||
| if (this.event.isNew === true && isMeaningfulRelease(this.event.firstSeenInRelease)) { | ||
| return 'firstSeen'; | ||
| } | ||
|
|
||
| return null; | ||
| }, | ||
| /** | ||
| * Explain the status and its release without expanding the visible badge. | ||
| */ | ||
| tooltip(): string { | ||
| switch (this.status) { | ||
| case 'firstSeen': | ||
| return this.$t('event.releaseStatusTooltip.firstSeen', { release: this.event.firstSeenInRelease }); | ||
| case 'resolved': | ||
| return this.$t('event.releaseStatusTooltip.resolved', { release: this.event.resolvedInRelease }); | ||
| case 'regression': | ||
| return this.$t('event.releaseStatusTooltip.regression', { release: this.event.regressionInRelease }); | ||
| default: | ||
| return ''; | ||
| } | ||
| }, | ||
| }, | ||
| }); | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .event-release-status { | ||
| display: inline-block; | ||
| min-width: 0; | ||
| max-width: 100%; | ||
| padding: 2px 9px; | ||
| overflow: hidden; | ||
|
|
||
| font-size: 11px; | ||
| font-weight: 600; | ||
| line-height: 16px; | ||
| white-space: nowrap; | ||
| text-overflow: ellipsis; | ||
| vertical-align: middle; | ||
| background-color: transparent; | ||
| border: 1px solid currentColor; | ||
| border-radius: 999px; | ||
| cursor: help; | ||
|
|
||
| &--firstSeen { | ||
| color: var(--color-text-highlighted); | ||
| } | ||
|
|
||
| &--resolved { | ||
| color: var(--color-indicator-positive); | ||
| } | ||
|
|
||
| &--regression { | ||
| color: var(--color-indicator-warning); | ||
| } | ||
| } | ||
| </style> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need to throw here. In GraphQL data can be successfully received along with some errors.