Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(test) : Add tests for Query Tab (#2793)
Browse files Browse the repository at this point in the history
- Add tests for creating a new workitem from query tab
  • Loading branch information
Raunak1203 authored and jarifibrahim committed Oct 25, 2018
1 parent d6bf14f commit 9dba43d
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tests/page_objects/app.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $, browser, by, ExpectedConditions as until } from 'protractor';
import { $, browser, by, element, ExpectedConditions as until } from 'protractor';
import * as support from '../support';
import { BaseElement, Clickable } from '../ui';

Expand All @@ -10,6 +10,7 @@ export abstract class AppPage extends BasePage {
planTab = new Clickable(this.mainNavBar.element(by.xpath("//span[text()='Plan']")), 'Plan Tab');
backLogTab = new Clickable(this.mainNavBar.element(by.xpath("//span[text()=' Backlog ']")), 'Backlog Tab');
boardTab = new Clickable(this.mainNavBar.element(by.xpath("//span[text()=' Board ']")), 'Board Tab');
QueryTab = new Clickable(element(by.cssContainingText('.nav.persistent-secondary li>a', 'Query')), 'Query Tab');

/**
* Extend this class, to describe Application Page(after logging in)
Expand Down Expand Up @@ -49,4 +50,8 @@ export abstract class AppPage extends BasePage {
async clickBoardTab() {
await this.boardTab.clickWhenReady();
}

async clickQueryTab() {
await this.QueryTab.clickWhenReady();
}
}
1 change: 1 addition & 0 deletions src/tests/page_objects/planner/planner.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class PlannerPage extends AppPage {
iteration = new planner.Iteration($('fab-planner-iteration-modal'));
detailPage = new planner.WorkItemDetailPage($('work-item-detail'));
confirmModalButton = new planner.WorkItemList($('#modal-confirm'));
query = new planner.Query($('planner-query'));

constructor(url: string) {
super(url);
Expand Down
38 changes: 38 additions & 0 deletions src/tests/specs/query-tab.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { browser } from 'protractor';
import { PlannerPage } from '../page_objects/planner';
import * as support from '../support';

describe('Query tests', () => {
let planner: PlannerPage;
let c = new support.Constants();
let testData;

beforeAll(async () => {
await support.desktopTestSetup();
planner = new PlannerPage(browser.baseUrl);
await planner.openInBrowser();
await planner.waitUntilUrlContains('typegroup');
testData = await c.browserName[browser.browserName];
});

it('should display search query result', async () => {
let searchQuery = `typegroup.name : ${testData.group1}`;
await planner.clickQueryTab();
await planner.waitUntilUrlContains('query');
expect(await browser.getCurrentUrl()).toContain('query');
await planner.query.enterQuery(searchQuery);
expect(await planner.query.getDataTableHeaderCellCount()).toBe(8);
});

it('should create a new Workitem', async () => {
let title: string = 'Create work item from query page',
searchQuery: string = `title:${title}`;
await planner.clickQueryTab();
await planner.waitUntilUrlContains('query');
await planner.query.createWorkItem(title);
await planner.quickPreview.notificationToast.untilCount(1);
expect(await planner.quickPreview.notificationToast.count()).toBe(1);
await planner.query.enterQuery(searchQuery);
expect(await planner.query.hasWorkItem(title)).toBe(true);
});
});
1 change: 1 addition & 0 deletions src/tests/ui/planner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './settings';
export * from './toolbarHeader';
export * from './iteration';
export * from './workitem-detailpage';
export * from './query-tab';


export interface WorkItem {
Expand Down
30 changes: 30 additions & 0 deletions src/tests/ui/planner/query-tab.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Key } from 'protractor';
import * as ui from '../../ui';
import { BaseElement, Clickable } from './../base.element';
import { WorkItemList } from './workitem-list';

export class Query extends WorkItemList {
private queryTextInput = new ui.TextInput(this.$('input[placeholder="Enter your Query..."]'), 'Enter your Query');
private createWorkItemButton = new ui.BaseElement(this.$('.f8-query__create-workitem> button'), ' Create work Item');
private createWorkItemMenu = new ui.BaseElement(this.$('.f8-query__create-workitem-menu'), 'create work item menu');
private titleTextInput = new ui.TextInput(this.createWorkItemMenu.$('input[placeholder=" Type your title...."]'), 'title');
private createButton = new ui.Clickable(this.createWorkItemMenu.$('#quickadd-save'), 'create button');

async enterQuery(query: string , append: boolean = false) {
await this.queryTextInput.ready();
if (!append) {
await this.queryTextInput.clear();
}
await this.queryTextInput.enterText(query);
await this.queryTextInput.enterText(Key.ENTER);
await this.datatableHeaderCell.untilCount(8);
}

async createWorkItem(title: string) {
await this.createWorkItemButton.ready();
await this.createWorkItemButton.clickWhenReady();
await this.createWorkItemMenu.untilDisplayed();
await this.titleTextInput.enterText(title);
await this.createButton.clickWhenReady();
}
}

0 comments on commit 9dba43d

Please sign in to comment.