This commit is contained in:
piotrpekala7 2020-02-07 16:52:12 +01:00
parent f744c02c44
commit fce7241bb2
3 changed files with 41 additions and 6 deletions

7
e2e/helpers/common.po.ts Normal file
View File

@ -0,0 +1,7 @@
import { browser, by, element } from 'protractor';
export class TestHelper {
sleep(value: number) {
browser.sleep(value);
}
}

View File

@ -14,7 +14,12 @@ export class ServersPage {
// return element(by.className('mat-card-content')[0]).getText(); // return element(by.className('mat-card-content')[0]).getText();
} }
async clickAddServer() {
let buttons = await browser.driver.findElements(by.className('mat-button mat-button-base'));
await buttons[3].click();
}
checkServersTable() { checkServersTable() {
return browser.driver.findElement(by.className('mat-cell cdk-column-id mat-column-id ng-star-inserted')).getText(); return browser.driver.findElements(by.css('mat-cell'));
} }
} }

View File

@ -1,13 +1,23 @@
import { ServersPage } from './helpers/server.po'; import { ServersPage } from './helpers/server.po';
import { TestHelper } from './helpers/common.po';
import { element } from 'protractor';
describe('gns3-web-ui App', () => { fdescribe('gns3-web-ui App', () => {
let page: ServersPage; let page: ServersPage;
let helper: TestHelper;
beforeEach(() => { beforeEach(() => {
page = new ServersPage(); page = new ServersPage();
helper = new TestHelper();
}); });
it('should be able to add server', async () => { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
};
it('user should have possibility to add server', async () => {
// arrange // arrange
page.maximizeWindow(); page.maximizeWindow();
await page.navigateToServersPage(); await page.navigateToServersPage();
@ -17,11 +27,24 @@ describe('gns3-web-ui App', () => {
// assert // assert
expect(text).toBe("We've discovered GNS3 server on 127.0.0.1:3080, would you like to add to the list?"); 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(); it('user should see added server in the list', async () => {
// arrange
page.maximizeWindow();
await page.navigateToServersPage();
await page.clickAddServer();
helper.sleep(1000);
// console.log('answer ********************* ', firstRowOfServersTable); // act
let firstRowOfServersTable = await page.checkServersTable();
let serverData = [];
await asyncForEach(firstRowOfServersTable, async element => {
serverData.push(await element.getText());
});
// expect(true).toBe(true); // assert
expect(serverData).toContain('127.0.0.1');
expect(serverData).toContain('3080');
}); });
}); });