Skip to content

Commit c699adb

Browse files
committed
test: add e2e test bed with some tests
1 parent ee4ddf2 commit c699adb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+486
-88
lines changed

angular.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"src/assets"
2424
],
2525
"styles": [
26-
"src/styles.css"
26+
"node_modules/simple-line-icons/css/simple-line-icons.css",
27+
"src/scss/style.scss"
2728
],
2829
"scripts": []
2930
},
@@ -72,7 +73,7 @@
7273
"tsConfig": "src/tsconfig.spec.json",
7374
"karmaConfig": "src/karma.conf.js",
7475
"styles": [
75-
"src/styles.css"
76+
"src/scss/style.scss"
7677
],
7778
"scripts": [],
7879
"assets": [

e2e/protractor.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exports.config = {
1212
'browserName': 'chrome'
1313
},
1414
directConnect: true,
15-
baseUrl: 'http://localhost:4200/',
15+
baseUrl: 'http://localhost:4201/',
1616
framework: 'jasmine',
1717
jasmineNodeOpts: {
1818
showColors: true,
@@ -25,4 +25,4 @@ exports.config = {
2525
});
2626
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
2727
}
28-
};
28+
};

e2e/src/app.e2e-spec.ts

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,55 @@
1-
import { AppPage } from './app.po';
1+
import { AppDashboard } from './app.po';
22

3-
describe('workspace-project App', () => {
4-
let page: AppPage;
3+
describe('CoreUI template', () => {
4+
let page: AppDashboard;
5+
const sleep = 300;
56

6-
beforeEach(() => {
7-
page = new AppPage();
7+
page = new AppDashboard();
8+
const browser = page.getBrowser();
9+
browser.driver.manage().window().setSize(600, 800);
10+
browser.sleep(sleep);
11+
page.navigateTo();
12+
13+
// beforeEach(() => {
14+
// page = new AppDashboard();
15+
// page.navigateTo();
16+
// });
17+
18+
it('should display CoreUI Dashboard', () => {
19+
expect(page.getParagraphText()).toEqual('CoreUI Dashboard');
20+
});
21+
22+
it('should toggle `sidebar-minimized` body.class on `sidebar-minimizer` click', () => {
23+
browser.manage().window().maximize();
24+
browser.sleep(1000);
25+
const body = page.getBody();
26+
expect(body.getAttribute('class')).not.toContain('sidebar-minimized');
27+
const button = page.getByCss('.sidebar-minimizer');
28+
button.click();
29+
browser.sleep(sleep);
30+
expect(body.getAttribute('class')).toContain('sidebar-minimized');
31+
browser.sleep(sleep);
32+
button.click();
33+
browser.sleep(sleep);
34+
expect(body.getAttribute('class')).not.toContain('sidebar-minimized');
35+
browser.driver.manage().window().setSize(600, 800);
36+
browser.sleep(1000);
837
});
938

10-
it('should display welcome message', () => {
11-
page.navigateTo();
12-
expect(page.getParagraphText()).toEqual('Welcome to app!');
39+
it('should toggle `sidebar-show` body.class on `navbar-toggler` click', () => {
40+
browser.driver.manage().window().setSize(600, 800);
41+
browser.sleep(1000);
42+
const body = page.getBody();
43+
expect(body.getAttribute('class')).not.toContain('sidebar-show');
44+
const button1 = page.getByCss('.navbar-toggler.d-lg-none').first();
45+
browser.sleep(sleep);
46+
button1.click();
47+
browser.sleep(sleep);
48+
expect(body.getAttribute('class')).toContain('sidebar-show');
49+
const button2 = page.getByCss('.navbar-toggler').first();
50+
browser.sleep(sleep);
51+
button2.click();
52+
browser.sleep(sleep);
53+
expect(body.getAttribute('class')).not.toContain('sidebar-show');
1354
});
1455
});

e2e/src/app.po.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import { browser, by, element } from 'protractor';
22

3-
export class AppPage {
3+
export class AppDashboard {
4+
5+
getBrowser() {
6+
return browser;
7+
}
8+
49
navigateTo() {
510
return browser.get('/');
611
}
712

813
getParagraphText() {
9-
return element(by.css('app-root h1')).getText();
14+
return element(by.xpath('/html/body/app-dashboard/div/main/div/ng-component/div/span')).getText();
15+
}
16+
getBody() {
17+
return element(by.xpath('/html/body'));
1018
}
19+
getByCss(selector) {
20+
return element.all(by.css(selector));
21+
}
22+
23+
1124
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"scripts": {
1818
"ng": "ng",
1919
"start": "ng serve",
20-
"build": "ng build",
2120
"build-lib": "ng build @coreui/angular --prod",
2221
"test": "ng test",
2322
"test-lib": "ng test @coreui/angular",

projects/coreui/angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coreui/angular",
3-
"version": "2.6.2",
3+
"version": "2.6.3",
44
"description": "CoreUI Angular Bootstrap 4 components",
55
"license": "MIT",
66
"homepage": "https://coreui.io/angular",

src/app/_nav.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { INavData } from '../../dist/@coreui/angular';
2+
3+
export const navItems: INavData[] = [
4+
{
5+
name: 'Dashboard',
6+
url: '/dashboard',
7+
icon: 'icon-speedometer',
8+
badge: {
9+
variant: 'info',
10+
text: 'NEW'
11+
}
12+
},
13+
{
14+
name: 'Disabled',
15+
url: '/dashboard',
16+
icon: 'icon-ban',
17+
attributes: { disabled: true },
18+
},
19+
{
20+
name: 'Download CoreUI',
21+
url: 'http://coreui.io/angular/',
22+
icon: 'icon-cloud-download',
23+
class: 'mt-auto',
24+
variant: 'success',
25+
attributes: { target: '_blank', rel: 'noopener' }
26+
},
27+
{
28+
name: 'Try CoreUI PRO',
29+
url: 'http://coreui.io/pro/angular/',
30+
icon: 'icon-layers',
31+
variant: 'danger',
32+
attributes: { target: '_blank', rel: 'noopener' }
33+
}
34+
];

src/app/app.component.html

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/app/app.component.spec.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { RouterTestingModule } from '@angular/router/testing';
12
import { TestBed, async } from '@angular/core/testing';
23
import { AppComponent } from './app.component';
34
describe('AppComponent', () => {
@@ -6,22 +7,12 @@ describe('AppComponent', () => {
67
declarations: [
78
AppComponent
89
],
10+
imports: [ RouterTestingModule ]
911
}).compileComponents();
1012
}));
1113
it('should create the app', async(() => {
1214
const fixture = TestBed.createComponent(AppComponent);
1315
const app = fixture.debugElement.componentInstance;
1416
expect(app).toBeTruthy();
1517
}));
16-
it(`should have as title 'app'`, async(() => {
17-
const fixture = TestBed.createComponent(AppComponent);
18-
const app = fixture.debugElement.componentInstance;
19-
expect(app.title).toEqual('app');
20-
}));
21-
it('should render title in a h1 tag', async(() => {
22-
const fixture = TestBed.createComponent(AppComponent);
23-
fixture.detectChanges();
24-
const compiled = fixture.debugElement.nativeElement;
25-
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
26-
}));
2718
});

src/app/app.component.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
2+
import { Router, NavigationEnd } from '@angular/router';
23

34
@Component({
4-
selector: 'app-root',
5-
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.css']
5+
// tslint:disable-next-line
6+
selector: 'body',
7+
template: '<router-outlet></router-outlet>'
78
})
8-
export class AppComponent {
9-
title = 'app';
9+
export class AppComponent implements OnInit {
10+
title = 'CoreUI 2 for Angular 8';
11+
constructor(private router: Router) { }
12+
13+
ngOnInit() {
14+
this.router.events.subscribe((evt) => {
15+
if (!(evt instanceof NavigationEnd)) {
16+
return;
17+
}
18+
window.scrollTo(0, 0);
19+
});
20+
}
1021
}

0 commit comments

Comments
 (0)