Skip to content

Commit ac237c4

Browse files
committed
test: add e2e test bed with some tests
1 parent 46e8e26 commit ac237c4

File tree

2 files changed

+69
-10
lines changed

2 files changed

+69
-10
lines changed

e2e/app.e2e-spec.ts

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

3-
describe('core-ui App', function() {
4-
let page: CoreUIPage;
3+
describe('CoreUI template', () => {
4+
let page: AppDashboard;
5+
const sleep = 300;
56

6-
beforeEach(() => {
7-
page = new CoreUIPage();
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', async () => {
19+
expect(await page.getParagraphText()).toEqual('Traffic');
20+
});
21+
22+
it('should display footer containing creativeLabs', async () => {
23+
expect(await page.getFooterText()).toContain('creativeLabs');
24+
});
25+
26+
it('should toggle `sidebar-minimized` body.class on `sidebar-minimizer` click', () => {
27+
browser.manage().window().maximize();
28+
browser.sleep(1000);
29+
const body = page.getBody();
30+
expect(body.getAttribute('class')).not.toContain('sidebar-minimized');
31+
const button = page.getByCss('.sidebar-minimizer');
32+
button.click();
33+
browser.sleep(sleep);
34+
expect(body.getAttribute('class')).toContain('sidebar-minimized');
35+
browser.sleep(sleep);
36+
button.click();
37+
browser.sleep(sleep);
38+
expect(body.getAttribute('class')).not.toContain('sidebar-minimized');
39+
browser.driver.manage().window().setSize(600, 800);
40+
browser.sleep(1000);
841
});
942

10-
it('should display footer containing creativeLabs', () => {
11-
page.navigateTo();
12-
expect(page.getParagraphText()).toContain('creativeLabs');
43+
it('should toggle `sidebar-show` body.class on `navbar-toggler` click', () => {
44+
browser.driver.manage().window().setSize(600, 800);
45+
browser.sleep(1000);
46+
const body = page.getBody();
47+
expect(body.getAttribute('class')).not.toContain('sidebar-show');
48+
const button1 = page.getByCss('.navbar-toggler.d-lg-none').first();
49+
browser.sleep(sleep);
50+
button1.click();
51+
browser.sleep(sleep);
52+
expect(body.getAttribute('class')).toContain('sidebar-show');
53+
const button2 = page.getByCss('.navbar-toggler').first();
54+
browser.sleep(sleep);
55+
button2.click();
56+
browser.sleep(sleep);
57+
expect(body.getAttribute('class')).not.toContain('sidebar-show');
1358
});
1459
});

e2e/app.po.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
import { browser, element, by } from 'protractor';
1+
import { browser, by, element } from 'protractor';
2+
3+
export class AppDashboard {
4+
5+
getBrowser() {
6+
return browser;
7+
}
28

3-
export class CoreUIPage {
49
navigateTo() {
510
return browser.get('/');
611
}
712

813
getParagraphText() {
14+
return element(by.xpath('/html/body/app-dashboard/div/main/div/ng-component/div/div[2]/div[1]/div[1]/div[1]/h4')).getText();
15+
}
16+
getBody() {
17+
return element(by.xpath('/html/body'));
18+
}
19+
getByCss(selector) {
20+
return element.all(by.css(selector));
21+
}
22+
getFooterText() {
923
return element(by.className('app-footer')).getText();
1024
}
1125
}

0 commit comments

Comments
 (0)