diff --git a/projects/sandbox/cypress/e2e/debias.cy.ts b/projects/sandbox/cypress/e2e/debias.cy.ts index 8904ca333..9d22cabf1 100644 --- a/projects/sandbox/cypress/e2e/debias.cy.ts +++ b/projects/sandbox/cypress/e2e/debias.cy.ts @@ -5,6 +5,27 @@ context('Sandbox', () => { const txtNoDetections = 'No Biases Found'; const pollInterval = 2000; + it('should toggle the info', () => { + cy.visit('/dataset/3'); + cy.wait(pollInterval); + cy.get(selDebiasLink) + .last() + .click(force); + cy.wait(pollInterval); + + const selHeader = '.debias-header'; + const selInfoToggle = '.debias .open-info'; + const selOverlay = '.debias-overlay.active'; + + cy.get(selHeader).should('have.class', 'closed'); + cy.get(selOverlay).should('not.exist'); + + cy.get(selInfoToggle).click(force); + + cy.get(selHeader).should('not.have.class', 'closed'); + cy.get(selOverlay).should('exist'); + }); + it('should not allow debias checks for failed datasets', () => { cy.visit('/dataset/909'); cy.wait(1000); diff --git a/projects/sandbox/src/app/_directives/is-scrollable/is-scrollable.directive.spec.ts b/projects/sandbox/src/app/_directives/is-scrollable/is-scrollable.directive.spec.ts index 75cbeee1c..7734f4875 100644 --- a/projects/sandbox/src/app/_directives/is-scrollable/is-scrollable.directive.spec.ts +++ b/projects/sandbox/src/app/_directives/is-scrollable/is-scrollable.directive.spec.ts @@ -5,13 +5,34 @@ import { IsScrollableDirective } from '.'; @Component({ imports: [IsScrollableDirective], template: ` -
-
- BACK - FWD +
+
+
Hello
+
Hello
+
Hello
+
Hello
+
+
{{ scrollInfo.canScrollFwd }}
+
{{ scrollInfo.canScrollBack }}
`, - styles: ['.scrollable{ width: 100px; max-width: 100px; }'], + styles: [ + ` + .scrollable { + display: flex; + flex-direction: column; + height: 100px; + width: 100px; + max-height: 100px; + overflow-y: auto; + } + .item { + display: block; + height: 300px; + width: 100px; + } + ` + ], standalone: true }) class TestIsScrollableDirectiveComponent {} @@ -19,6 +40,9 @@ class TestIsScrollableDirectiveComponent {} describe('IsScrollableDirective', () => { let fixture: ComponentFixture; let testComponent: TestIsScrollableDirectiveComponent; + let elScrollable: HTMLElement; + let elOutput1: HTMLElement; + let elOutput2: HTMLElement; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -30,10 +54,43 @@ describe('IsScrollableDirective', () => { beforeEach(() => { fixture = TestBed.createComponent(TestIsScrollableDirectiveComponent); testComponent = fixture.componentInstance; + elScrollable = fixture.debugElement.nativeElement.querySelector('.scrollable'); + elOutput1 = fixture.debugElement.nativeElement.querySelector('.output-1'); + elOutput2 = fixture.debugElement.nativeElement.querySelector('.output-2'); + elScrollable.dispatchEvent(new Event('scroll')); fixture.detectChanges(); }); it('it should create', () => { expect(testComponent).toBeTruthy(); }); + + it('it should re-caluculate on scroll', () => { + expect(elOutput1.innerHTML).toEqual('true'); + expect(elOutput2.innerHTML).toEqual('false'); + + elScrollable.scrollTop = 1000; + elScrollable.dispatchEvent(new Event('scroll')); + fixture.detectChanges(); + + expect(elOutput1.innerHTML).toEqual('false'); + expect(elOutput2.innerHTML).toEqual('true'); + }); + + it('it should re-caluculate when elements are added', () => { + expect(elOutput1.innerHTML).toEqual('true'); + expect(elOutput2.innerHTML).toEqual('false'); + + fixture.debugElement.nativeElement.querySelectorAll('.item').forEach((el: Element) => { + if (el.parentNode) { + el.parentNode.removeChild(el); + } + }); + + elScrollable.dispatchEvent(new Event('scroll')); + fixture.detectChanges(); + + expect(elOutput1.innerHTML).toEqual('false'); + expect(elOutput2.innerHTML).toEqual('false'); + }); }); diff --git a/projects/sandbox/src/app/_directives/is-scrollable/is-scrollable.directive.ts b/projects/sandbox/src/app/_directives/is-scrollable/is-scrollable.directive.ts index 2102a2893..58fa31b5f 100644 --- a/projects/sandbox/src/app/_directives/is-scrollable/is-scrollable.directive.ts +++ b/projects/sandbox/src/app/_directives/is-scrollable/is-scrollable.directive.ts @@ -11,9 +11,7 @@ export class IsScrollableDirective implements AfterViewInit { constructor(private readonly elementRef: ElementRef) { const element = this.elementRef.nativeElement; - new MutationObserver((_: MutationRecord[]) => { - console.log('mutate...'); this.calc(); }).observe(element, { childList: true diff --git a/projects/sandbox/src/app/debias/debias.component.html b/projects/sandbox/src/app/debias/debias.component.html index 37e048e68..fdc6096ab 100644 --- a/projects/sandbox/src/app/debias/debias.component.html +++ b/projects/sandbox/src/app/debias/debias.component.html @@ -18,7 +18,6 @@
-

+

This functionality is one of the results of the de-bias project (2023 - 2024) and is - provided as-is. For more information see: -
- {{ linkUrl }} + +

+ For more information see: + {{ linkUrl }}.

diff --git a/projects/sandbox/src/app/debias/debias.component.scss b/projects/sandbox/src/app/debias/debias.component.scss index 28a5356e3..0261f4e42 100644 --- a/projects/sandbox/src/app/debias/debias.component.scss +++ b/projects/sandbox/src/app/debias/debias.component.scss @@ -1,3 +1,4 @@ +@import 'shared-styles/assets/sass/scss/generic/variables-bp'; @import 'shared-styles/assets/sass/scss/generic/variables-colours'; @import 'shared-styles/assets/sass/scss/iconography/svg-icons-metis'; @@ -104,6 +105,11 @@ $transition-time-open: 0.4s; .debias-header { background-color: $white; + background-image: svg-url-debias($eu-grey-light); + background-size: calc(100% - 3em); + background-repeat: no-repeat; + background-attachment: fixed; + background-position: center 1em; border-right: 1px solid $eu-grey-middle; clear: both; display: flex; @@ -115,10 +121,7 @@ $transition-time-open: 0.4s; max-height: 60vh; overflow-x: hidden; overflow-y: auto; - padding-top: 1em; - padding-bottom: 1em; - padding-left: 1.5em; - padding-right: 1.5em; + padding: 1em 1.5em; position: relative; transform: translateX(0); transition: transform $transition-time-open linear; @@ -161,6 +164,26 @@ $transition-time-open: 0.4s; & + p { margin-top: 1em; } + + &:first-of-type { + padding-top: 3em; + } + } +} + +@media (min-width: $bp-med) { + .debias-header p:first-of-type { + padding-top: 4em; + } +} +@media (min-width: $bp-xl) { + .debias-header p:first-of-type { + padding-top: 7em; + } +} +@media (min-width: $bp-xxl) { + .debias-header p:first-of-type { + padding-top: 8em; } } diff --git a/projects/sandbox/src/app/debias/dedias.component.spec.ts b/projects/sandbox/src/app/debias/dedias.component.spec.ts index 469ea130c..dd274b94e 100644 --- a/projects/sandbox/src/app/debias/dedias.component.spec.ts +++ b/projects/sandbox/src/app/debias/dedias.component.spec.ts @@ -43,6 +43,31 @@ describe('DebiasComponent', () => { expect(component.debiasReport).toBeTruthy(); tick(component.apiSettings.interval); })); + + const getEvent = (): Event => { + return ({ + stopPropagation: jasmine.createSpy() + } as unknown) as Event; + }; + + it('should close the debias info', () => { + const e = getEvent(); + component.debiasHeaderOpen = true; + component.closeDebiasInfo(e); + expect(component.debiasHeaderOpen).toBeFalsy(); + expect(e.stopPropagation).toHaveBeenCalled(); + }); + + it('should toggle the debias info', () => { + const e = getEvent(); + component.debiasHeaderOpen = true; + component.toggleDebiasInfo(e); + expect(component.debiasHeaderOpen).toBeFalsy(); + expect(e.stopPropagation).toHaveBeenCalledTimes(1); + component.toggleDebiasInfo(e); + expect(component.debiasHeaderOpen).toBeTruthy(); + expect(e.stopPropagation).toHaveBeenCalledTimes(2); + }); }); describe('Error Handling', () => {