Skip to content

Commit

Permalink
fix(connect): hide Connect when the console is in embedded mode #514
Browse files Browse the repository at this point in the history
Fix #514
  • Loading branch information
tadayosi committed Aug 22, 2023
1 parent d8643d8 commit 780e3df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/hawtio/src/plugins/connect/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { jolokiaService } from '@hawtiosrc/plugins/shared/jolokia-service'
import fetchMock from 'jest-fetch-mock'
import { connectService } from '@hawtiosrc/plugins/shared/connect-service'
import { isActive } from './init'

jest.mock('@hawtiosrc/plugins/shared/connect-service')
jest.mock('@hawtiosrc/plugins/shared/jolokia-service')

describe('isActive', () => {
beforeEach(() => {
Expand All @@ -16,16 +16,16 @@ describe('isActive', () => {
await expect(isActive()).resolves.toEqual(false)
})

test('/proxy/enabled returns not false & connection name is not set', async () => {
test('/proxy/enabled returns not false & jolokia url is null', async () => {
fetchMock.mockResponse('true')
connectService.getCurrentConnectionName = jest.fn(() => null)
jolokiaService.getJolokiaUrl = jest.fn(async () => null)

await expect(isActive()).resolves.toEqual(true)
})

test('/proxy/enabled returns not false & connection name is set', async () => {
test('/proxy/enabled returns not false & jolokia url is not null', async () => {
fetchMock.mockResponse('')
connectService.getCurrentConnectionName = jest.fn(() => 'test-connection')
jolokiaService.getJolokiaUrl = jest.fn(async () => 'test-url')

await expect(isActive()).resolves.toEqual(false)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/hawtio/src/plugins/connect/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connectService } from '@hawtiosrc/plugins/shared/connect-service'
import { jolokiaService } from '@hawtiosrc/plugins/shared'
import { log, PATH_PROXY_ENABLED } from './globals'

export async function isActive(): Promise<boolean> {
Expand All @@ -7,7 +7,7 @@ export async function isActive(): Promise<boolean> {
return false
}

return connectService.getCurrentConnectionName() === null
return (await jolokiaService.getJolokiaUrl()) === null
}

async function isProxyEnabled(): Promise<boolean> {
Expand Down

0 comments on commit 780e3df

Please sign in to comment.