Skip to content

Commit

Permalink
feat(app): get experiment link dynamically and add tests for embed menu
Browse files Browse the repository at this point in the history
  • Loading branch information
9inpachi committed Apr 28, 2021
1 parent 8a0c0b1 commit cc9590d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 45 deletions.
16 changes: 4 additions & 12 deletions packages/phoenix-ng/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
"projects/phoenix-app/src/assets",
"projects/phoenix-app/src/api-docs"
],
"styles": [
"projects/phoenix-app/src/styles.scss"
],
"styles": ["projects/phoenix-app/src/styles.scss"],
"allowedCommonJsDependencies": [
"css-element-queries",
"@tweenjs/tween.js"
Expand Down Expand Up @@ -148,9 +146,7 @@
"projects/phoenix-app/src/tsconfig.app.json",
"projects/phoenix-app/src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
Expand All @@ -176,9 +172,7 @@
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.json",
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
Expand Down Expand Up @@ -224,9 +218,7 @@
"projects/phoenix-ui-components/tsconfig.lib.json",
"projects/phoenix-ui-components/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<div id="embedMenuInner">
<app-dark-theme></app-dark-theme>
<app-auto-rotate></app-auto-rotate>
<app-experiment-link
[experimentLink]="experimentLink"
></app-experiment-link>
<app-experiment-link></app-experiment-link>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#embedMenu {
display: none;

#embedMenuInner {
display: flex;
position: absolute;
left: 1rem;
bottom: 1rem;
background: var(--phoenix-background-color-secondary);
border: 1px solid var(--phoenix-background-color-tertiary);
box-shadow: var(--phoenix-box-shadow);
border-radius: 30px;
padding: 0.25rem 0;
}
}
#embedMenu {
display: none;

#embedMenuInner {
display: flex;
position: absolute;
left: 1rem;
bottom: 1rem;
background: var(--phoenix-background-color-secondary);
border: 1px solid var(--phoenix-background-color-tertiary);
box-shadow: var(--phoenix-box-shadow);
border-radius: 30px;
padding: 0.25rem 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ describe('EmbedMenuComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ EmbedMenuComponent ]
})
.compileComponents();
declarations: [EmbedMenuComponent],
}).compileComponents();
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Component, Input } from '@angular/core';
import { Component } from '@angular/core';

@Component({
selector: 'app-embed-menu',
templateUrl: './embed-menu.component.html',
styleUrls: ['./embed-menu.component.scss'],
})
export class EmbedMenuComponent {
@Input() experimentLink: string;
}
export class EmbedMenuComponent {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<app-menu-toggle
*ngIf="experimentLink !== undefined"
tooltip="See full event display"
icon="link"
(click)="goToExperiment()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ describe('ExperimentLinkComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ExperimentLinkComponent ]
})
.compileComponents();
declarations: [ExperimentLinkComponent],
}).compileComponents();
});

beforeEach(() => {
Expand All @@ -22,4 +21,16 @@ describe('ExperimentLinkComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});

it('should initialize experiment link', () => {
expect((component as any).experimentLink).toBeUndefined();
component.ngOnInit();
expect((component as any).experimentLink).toBeTruthy();
});

it('should go to experiment link', () => {
spyOn(window, 'open').and.stub();
component.goToExperiment();
expect(window.open).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Component, Input } from '@angular/core';
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-experiment-link',
templateUrl: './experiment-link.component.html',
styleUrls: ['./experiment-link.component.scss'],
})
export class ExperimentLinkComponent {
@Input() experimentLink: string;
export class ExperimentLinkComponent implements OnInit {
private experimentLink: string;

ngOnInit() {
this.experimentLink = window.location.href.split('?')[0];
}

goToExperiment() {
window.open('this.experimentLink', '_blank');
window.open(this.experimentLink, '_blank');
}
}

0 comments on commit cc9590d

Please sign in to comment.