diff --git a/e2e/app.e2e-spec.ts b/e2e/app.e2e-spec.ts index 40a0b075..7e2a1898 100644 --- a/e2e/app.e2e-spec.ts +++ b/e2e/app.e2e-spec.ts @@ -1,14 +1,20 @@ import { Gns3WebUiPage } from './app.po'; -describe('gns3-web-ui App', () => { +describe('GNS3 Web UI Application', () => { let page: Gns3WebUiPage; beforeEach(() => { page = new Gns3WebUiPage(); }); - it('should display title', () => { - page.navigateTo(); - expect(page.getTitleText()).toEqual('GNS3 Web UI'); + it('should have correct page title', async () => { + // arrange + await page.navigateTo(); + + // act + let text = await page.getTitleText(); + + // assert + expect(text).toEqual('GNS3 Web UI'); }); }); diff --git a/e2e/app.po.ts b/e2e/app.po.ts index 458a6e6a..f0086fa6 100644 --- a/e2e/app.po.ts +++ b/e2e/app.po.ts @@ -6,7 +6,7 @@ export class Gns3WebUiPage { } getTitleText() { - return browser.getTitle(); + return browser.driver.getTitle(); } getParagraphText() { diff --git a/e2e/helpers/server.po.ts b/e2e/helpers/server.po.ts new file mode 100644 index 00000000..c7d6c71e --- /dev/null +++ b/e2e/helpers/server.po.ts @@ -0,0 +1,20 @@ +import { browser, by, element } from 'protractor'; + +export class ServersPage { + maximizeWindow() { + browser.driver.manage().window().maximize(); + } + + navigateToServersPage() { + return browser.get('/servers'); + } + + getAddServerNotificationText() { + return browser.driver.findElement(by.className('mat-card-content')).getText(); + // return element(by.className('mat-card-content')[0]).getText(); + } + + checkServersTable() { + return browser.driver.findElement(by.className('mat-cell cdk-column-id mat-column-id ng-star-inserted')).getText(); + } +} diff --git a/e2e/servers.e2e-spec.ts b/e2e/servers.e2e-spec.ts new file mode 100644 index 00000000..ced12d32 --- /dev/null +++ b/e2e/servers.e2e-spec.ts @@ -0,0 +1,27 @@ +import { ServersPage } from './helpers/server.po'; + +describe('gns3-web-ui App', () => { + let page: ServersPage; + + beforeEach(() => { + page = new ServersPage(); + }); + + it('should be able to add server', async () => { + // arrange + page.maximizeWindow(); + await page.navigateToServersPage(); + + // act + let text = await page.getAddServerNotificationText(); + + // assert + expect(text).toBe("We've discovered GNS3 server on 127.0.0.1:3080, would you like to add to the list?"); + + // let firstRowOfServersTable = await page.checkServersTable(); + + // console.log('answer ********************* ', firstRowOfServersTable); + + // expect(true).toBe(true); + }); +}); diff --git a/package.json b/package.json index f973a565..cca64095 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,8 @@ }, "devDependencies": { "@angular-devkit/build-angular": "^0.803.10", + "@angular-devkit/core": "^8.3.23", + "@angular-devkit/schematics": "^8.3.23", "@angular/cli": "^8.3.10", "@angular/compiler-cli": "^8.2.11", "@angular/language-service": "^8.2.11",