-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add alerts to authenticate & collection page (#76)
* feat: added alerts to authenticate page * feat: added alerts to collections page * build: fixed missing import * test: fixed jest config * fix: improved styling of alerts * test: added basic tests for showing alerts Co-authored-by: Wouter Janssens <wouter@digita.ai>
- Loading branch information
Showing
14 changed files
with
245 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,20 +1,23 @@ | ||
import type {Config} from '@jest/types'; | ||
|
||
const config: Config.InitialOptions = { | ||
preset: 'ts-jest/presets/js-with-ts', | ||
testMatch: ['**/+(*.)+(spec).+(ts)'], | ||
transformIgnorePatterns: ['node_modules/(?!(lit-element|lit-html|rx-lit)/)'], | ||
moduleNameMapper: { | ||
'~(.*)': '<rootDir>/lib/$1', | ||
}, | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
diagnostics: { | ||
warnOnly: true, | ||
preset: 'ts-jest/presets/js-with-ts', | ||
testMatch: ['**/+(*.)+(spec).+(ts)'], | ||
transformIgnorePatterns: ['node_modules/(?!(lit-element|lit-html|rx-lit)/)'], | ||
moduleNameMapper: { | ||
'~(.*)': '<rootDir>/lib/$1', | ||
}, | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
diagnostics: { | ||
warnOnly: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
transform: { | ||
'^.+\\.ts?$': 'ts-jest' | ||
}, | ||
}; | ||
|
||
export default config; | ||
export default config; |
This file contains 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 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 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
55 changes: 55 additions & 0 deletions
55
packages/nde-erfgoed-manage/lib/features/authenticate/authenticate-root.component.spec.ts
This file contains 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,55 @@ | ||
import { FormActors } from '@digita-ai/nde-erfgoed-components'; | ||
import { ConsoleLogger, LoggerLevel, SolidMockService } from '@digita-ai/nde-erfgoed-core'; | ||
import { interpret, Interpreter } from 'xstate'; | ||
import { AuthenticateRootComponent } from './authenticate-root.component'; | ||
import { AuthenticateContext, authenticateMachine } from './authenticate.machine'; | ||
|
||
const solid = new SolidMockService(new ConsoleLogger(LoggerLevel.silly, LoggerLevel.silly)); | ||
|
||
describe('AuthenticateRootComponent', () => { | ||
let component: AuthenticateRootComponent; | ||
let machine: Interpreter<AuthenticateContext>; | ||
|
||
beforeEach(() => { | ||
machine = interpret(authenticateMachine(solid)); | ||
component = window.document.createElement('nde-authenticate-root') as AuthenticateRootComponent; | ||
|
||
component.actor = machine; | ||
component.formActor = machine.children.get(FormActors.FORM_MACHINE); | ||
}); | ||
|
||
afterEach(() => { | ||
document.getElementsByTagName('html')[0].innerHTML = ''; | ||
}); | ||
|
||
it('should be correctly instantiated', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should show alerts when set', async () => { | ||
component.alerts = [ { | ||
type: 'success', | ||
message: 'Foo', | ||
} ]; | ||
|
||
window.document.body.appendChild(component); | ||
await component.updateComplete; | ||
|
||
const alerts = window.document.body.getElementsByTagName('nde-authenticate-root')[0].shadowRoot.querySelectorAll('nde-alert'); | ||
|
||
expect(alerts).toBeTruthy(); | ||
expect(alerts.length).toBe(1); | ||
}); | ||
|
||
it('should not show alerts when unset', async () => { | ||
component.alerts = null; | ||
|
||
window.document.body.appendChild(component); | ||
await component.updateComplete; | ||
|
||
const alerts = window.document.body.getElementsByTagName('nde-authenticate-root')[0].shadowRoot.querySelectorAll('nde-alert'); | ||
|
||
expect(alerts).toBeTruthy(); | ||
expect(alerts.length).toBe(0); | ||
}); | ||
}); |
This file contains 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.