Follow up 7f5fac4e - Stub global Notification api
Co-authored-by: Benjamin Scharf <bs@zammad.com> Co-authored-by: Dominik Klein <dk@zammad.com>
This commit is contained in:
@@ -45,10 +45,6 @@ describe('OnlineNotification', () => {
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vi.stubGlobal('Notification', {
|
||||
requestPermission: () => Promise.resolve('granted'),
|
||||
})
|
||||
})
|
||||
|
||||
it('displays notification logo without unseen notifications', async () => {
|
||||
|
||||
@@ -1004,7 +1004,7 @@ describe('Ticket detail view', () => {
|
||||
it('should reset form after ticket updates', async () => {
|
||||
const ticket = createDummyTicket({
|
||||
state: {
|
||||
id: convertToGraphQLId('Ticket::State', 2),
|
||||
id: convertToGraphQLId('Ticket::State', 3),
|
||||
name: 'open',
|
||||
stateType: {
|
||||
id: convertToGraphQLId('TicketStateType', 2),
|
||||
@@ -1106,6 +1106,12 @@ describe('Ticket detail view', () => {
|
||||
},
|
||||
})
|
||||
|
||||
expect(view.getByLabelText('Group')).toHaveTextContent('Users')
|
||||
const attributesContainer = view.getByTestId('ticket-attributes')
|
||||
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
within(attributesContainer).getByLabelText('Group'),
|
||||
).toHaveTextContent('Users'),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
import { describe } from 'vitest'
|
||||
import { ref } from 'vue'
|
||||
|
||||
import { useBrowserNotifications } from '#shared/composables/useBrowserNotifications.ts'
|
||||
|
||||
let permission = vi.hoisted((): string | undefined => 'granted')
|
||||
|
||||
vi.mock('@vueuse/core', () => ({
|
||||
usePermission: () => ref(permission),
|
||||
}))
|
||||
|
||||
describe('useBrowserNotifications', () => {
|
||||
it('should request granted notification permission', () => {
|
||||
const { requestNotification } = useBrowserNotifications()
|
||||
|
||||
const requestPermissionSpy = vi.spyOn(Notification, 'requestPermission')
|
||||
|
||||
requestNotification()
|
||||
|
||||
expect(requestPermissionSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('returns granted permission when requestNotification is called', async () => {
|
||||
const { requestNotification, isGranted } = useBrowserNotifications()
|
||||
|
||||
await requestNotification()
|
||||
|
||||
expect(isGranted.value).toBe(true)
|
||||
})
|
||||
|
||||
it('has by default no notification permission', () => {
|
||||
permission = undefined
|
||||
// vi.restoreAllMocks ... does not work here
|
||||
const { notificationPermission, isGranted } = useBrowserNotifications()
|
||||
|
||||
expect(notificationPermission.value).toBe(undefined)
|
||||
expect(isGranted.value).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
import { type OnlineNotificationConnection } from '#shared/graphql/types.ts'
|
||||
import type { DeepPartial } from '#shared/types/utils.ts'
|
||||
|
||||
export default (): DeepPartial<OnlineNotificationConnection> => ({
|
||||
__typename: 'OnlineNotificationConnection',
|
||||
edges: [],
|
||||
pageInfo: {
|
||||
__typename: 'PageInfo',
|
||||
endCursor: null,
|
||||
hasNextPage: false,
|
||||
},
|
||||
})
|
||||
@@ -4,7 +4,7 @@ import { loadErrorMessages, loadDevMessages } from '@apollo/client/dev'
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { toBeDisabled } from '@testing-library/jest-dom/matchers'
|
||||
import { configure } from '@testing-library/vue'
|
||||
import { expect } from 'vitest'
|
||||
import { expect, vi } from 'vitest'
|
||||
import * as matchers from 'vitest-axe/matchers'
|
||||
import 'vitest-axe/extend-expect'
|
||||
|
||||
@@ -38,6 +38,15 @@ Object.defineProperty(window, 'fetch', {
|
||||
configurable: true,
|
||||
})
|
||||
|
||||
Object.defineProperty(globalThis, 'Notification', {
|
||||
value: {
|
||||
permission: undefined,
|
||||
requestPermission: async () => Promise.resolve('granted'),
|
||||
name: 'Notification',
|
||||
},
|
||||
writable: true,
|
||||
})
|
||||
|
||||
class DOMRectList {
|
||||
length = 0
|
||||
|
||||
|
||||
@@ -16588,7 +16588,7 @@ msgstr ""
|
||||
msgid "Token-based API access has been disabled by the administrator."
|
||||
msgstr ""
|
||||
|
||||
#: lib/user_agent.rb:249
|
||||
#: lib/user_agent.rb:234
|
||||
msgid "Too many redirections for the original URL, halting."
|
||||
msgstr ""
|
||||
|
||||
@@ -18391,7 +18391,7 @@ msgstr ""
|
||||
msgid "Zammad Helpdesk"
|
||||
msgstr ""
|
||||
|
||||
#: lib/user_agent.rb:141
|
||||
#: lib/user_agent.rb:126
|
||||
msgid "Zammad User Agent"
|
||||
msgstr ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user