Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

chore(website): fix old tests and add new ones for API page upgrades #2308

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions website/test/e2e/api-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ var ApiPage = function() {
this.clickOnExtendsType = function(name) {
$('[ng-if="currentItem.extends"]').element(by.linkText(name)).click();
};

/**
* Gets the text of elements of the menu that aren't children of another
* element or titles (e.g. 'protractor' and 'by' but not 'getText')
*/
this.getAdultNames = function() {
return element.all(by.repeater('item in items')).filter(function(elem) {
return elem.$$('[ng-switch-default]').count().then(function(count) {
return count == 1;
});
}).getText();
};
};

/** @type {ApiPage} */
Expand Down
9 changes: 8 additions & 1 deletion website/test/e2e/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Api', function() {

// Then ensure the child functions are shown.
expect(apiPage.getChildFunctionNames()).toEqual([
'clone', 'locator', 'getWebElement', 'all', 'element', '$$',
'then', 'clone', 'locator', 'getWebElement', 'all', 'element', '$$',
'$', 'isPresent', 'isElementPresent', 'evaluate', 'allowAnimations']);
});

Expand Down Expand Up @@ -133,4 +133,11 @@ describe('Api', function() {
expect(browser.getCurrentUrl()).
toMatch(/api\?view=webdriver.WebDriver.prototype.executeAsyncScript/);
});

it('should sort the menu to put webdriver docs next to the relavant ' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: relevant.

Why don't we just assert expect(apiPage.getAdultNmaes()).toBe(['a', 'b', ..., 'browser', 'webdriver.WebDriver', ..., 'y', 'z'])
So we can assert all the orders?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the files were arranged differently the location of browser and by in the docs might be switched, but that shouldn't break the tests. This test is designed to make sure that webdriver.WebDriver comes directly after browser, since that's how the inheritance works, but not care about the absolute order of everything.

'protractor objects', function() {
expect(apiPage.getAdultNames().then(function(names) {
return names[names.indexOf('browser') + 1];
})).toBe('webdriver.WebDriver');
});
});
8 changes: 4 additions & 4 deletions website/test/unit/api-controller-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ describe('ApiCtrl', function() {
]});

// Expect alias to be the title.
expect(scope.items[1].title).toBe('bar');
expect(scope.items[0].title).toBe('bar');
// Expect the name to be the title.
expect(scope.items[2].title).toBe('foo2');
expect(scope.items[1].title).toBe('foo2');
});

it('should use parent alias to generate title', function() {
Expand All @@ -100,7 +100,7 @@ describe('ApiCtrl', function() {
]});

// Expect the title to be parent + name.
expect(scope.items[2].title).toBe('parent.fn');
expect(scope.items[1].title).toBe('parent.fn');
});

it('should assign type to each item', function() {
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('ApiCtrl', function() {
]});

// Then ensure the extending item has the functions of the parent.
var item = scope.items[3];
var item = scope.items[0];
expect(item.title).toBe('name2');
expect(item.base.name).toBe('name1');
expect(item.base.items.length).toBe(1);
Expand Down