Skip to content

Commit

Permalink
chore(keycloak): Fix Jest tests with Keycloak.js 26 - but needs tscon…
Browse files Browse the repository at this point in the history
…fig.json change...
  • Loading branch information
grgrzybek authored and tadayosi committed Nov 14, 2024
1 parent 84b18dc commit 072cb39
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/hawtio/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: Config = {
'\\.(css|less)$': '<rootDir>/src/__mocks__/styleMock.js',
'@hawtiosrc/(.*)': '<rootDir>/src/$1',
'react-markdown': '<rootDir>/../../node_modules/react-markdown/react-markdown.min.js',
'keycloak-js': path.resolve(__dirname, './src/__mocks__/keycloak.js'),
'monaco-editor': path.resolve(__dirname, './src/__mocks__/monacoEditor.js'),
'@monaco-editor/react': path.resolve(__dirname, './src/__mocks__/monacoEditor.js'),
'@patternfly/react-code-editor': path.resolve(__dirname, './src/__mocks__/codeEditorMock.js'),
Expand Down
3 changes: 3 additions & 0 deletions packages/hawtio/src/__mocks__/keycloak.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
Keycloak: () => {},
}
4 changes: 2 additions & 2 deletions packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class KeycloakService implements IKeycloakService {

keycloak
.updateToken(KEYCLOAK_TOKEN_MINIMUM_VALIDITY)
.then(refreshed => {
.then((refreshed: boolean) => {
if (refreshed) {
const token = keycloak.token
if (token) {
Expand All @@ -247,7 +247,7 @@ class KeycloakService implements IKeycloakService {
log.debug('Token is still valid')
}
})
.catch(reason => {
.catch((reason: Error) => {
log.error("Couldn't update token:", reason)
errorFn?.()
})
Expand Down
2 changes: 1 addition & 1 deletion packages/hawtio/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"noImplicitThis": true,
"noUncheckedIndexedAccess": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
Expand Down

0 comments on commit 072cb39

Please sign in to comment.