2018-01-16 05:40:24 -05:00
|
|
|
import { browser, by, element, ElementFinder } from 'protractor';
|
2017-01-27 03:20:51 -05:00
|
|
|
import { SitePage } from './app.po';
|
|
|
|
|
|
|
|
describe('site App', function() {
|
|
|
|
let page: SitePage;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2017-05-15 17:52:39 -04:00
|
|
|
SitePage.setWindowWidth(1050); // Make the window wide enough to show the SideNav side-by-side.
|
2017-01-27 03:20:51 -05:00
|
|
|
page = new SitePage();
|
|
|
|
});
|
|
|
|
|
2017-02-02 15:10:47 -05:00
|
|
|
it('should show features text after clicking "Features"', () => {
|
2017-11-13 15:56:01 -05:00
|
|
|
page.navigateTo('');
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.getTopMenuLink('features'));
|
2017-03-27 11:38:14 -04:00
|
|
|
expect(page.getDocViewerText()).toMatch(/Progressive web apps/i);
|
2017-01-27 03:20:51 -05:00
|
|
|
});
|
2017-02-07 15:57:18 -05:00
|
|
|
|
2017-11-14 20:01:00 -05:00
|
|
|
it('should set appropriate window titles', () => {
|
2017-11-13 15:56:01 -05:00
|
|
|
page.navigateTo('');
|
2017-11-14 20:01:00 -05:00
|
|
|
expect(browser.getTitle()).toBe('Angular');
|
|
|
|
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.getTopMenuLink('features'));
|
2017-11-14 20:01:00 -05:00
|
|
|
expect(browser.getTitle()).toBe('Angular - FEATURES & BENEFITS');
|
|
|
|
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.homeLink);
|
2017-11-14 20:01:00 -05:00
|
|
|
expect(browser.getTitle()).toBe('Angular');
|
|
|
|
});
|
|
|
|
|
2018-01-16 05:40:24 -05:00
|
|
|
it('should not navigate when clicking on nav-item headings (sub-menu toggles)', () => {
|
|
|
|
// Show the sidenav.
|
|
|
|
page.navigateTo('docs');
|
|
|
|
expect(page.locationPath()).toBe('/docs');
|
|
|
|
|
|
|
|
// Get the top-level nav-item headings (sub-menu toggles).
|
|
|
|
const navItemHeadings = page.getNavItemHeadings(page.sidenav, 1);
|
|
|
|
|
|
|
|
// Test all headings (and sub-headings).
|
|
|
|
expect(navItemHeadings.count()).toBeGreaterThan(0);
|
|
|
|
navItemHeadings.each(heading => testNavItemHeading(heading!, 1));
|
|
|
|
|
|
|
|
// Helpers
|
2018-04-14 03:44:09 -04:00
|
|
|
function expectToBeCollapsed(elementFinder: ElementFinder) {
|
|
|
|
expect(elementFinder.getAttribute('class')).toMatch(/\bcollapsed\b/);
|
|
|
|
expect(elementFinder.getAttribute('class')).not.toMatch(/\bexpanded\b/);
|
2018-01-16 05:40:24 -05:00
|
|
|
}
|
|
|
|
|
2018-04-14 03:44:09 -04:00
|
|
|
function expectToBeExpanded(elementFinder: ElementFinder) {
|
|
|
|
expect(elementFinder.getAttribute('class')).not.toMatch(/\bcollapsed\b/);
|
|
|
|
expect(elementFinder.getAttribute('class')).toMatch(/\bexpanded\b/);
|
2018-01-16 05:40:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNavItemHeading(heading: ElementFinder, level: number) {
|
|
|
|
const children = page.getNavItemHeadingChildren(heading, level);
|
|
|
|
|
|
|
|
// Headings are initially collapsed.
|
|
|
|
expectToBeCollapsed(children);
|
|
|
|
|
|
|
|
// Ensure heading does not cause navigation when expanding.
|
|
|
|
page.click(heading);
|
|
|
|
expectToBeExpanded(children);
|
|
|
|
expect(page.locationPath()).toBe('/docs');
|
|
|
|
|
|
|
|
// Recursively test child-headings (while this heading is expanded).
|
|
|
|
const nextLevel = level + 1;
|
|
|
|
const childNavItemHeadings = page.getNavItemHeadings(children, nextLevel);
|
|
|
|
childNavItemHeadings.each(childHeading => testNavItemHeading(childHeading!, nextLevel));
|
|
|
|
|
|
|
|
// Ensure heading does not cause navigation when collapsing.
|
|
|
|
page.click(heading);
|
|
|
|
expectToBeCollapsed(children);
|
|
|
|
expect(page.locationPath()).toBe('/docs');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-11-13 15:56:01 -05:00
|
|
|
it('should show the tutorial index page at `/tutorial` after jitterbugging through features', () => {
|
2017-03-21 03:02:58 -04:00
|
|
|
// check that we can navigate directly to the tutorial page
|
2017-11-13 15:56:01 -05:00
|
|
|
page.navigateTo('tutorial');
|
2017-03-21 03:02:58 -04:00
|
|
|
expect(page.getDocViewerText()).toMatch(/Tutorial: Tour of Heroes/i);
|
|
|
|
|
|
|
|
// navigate to a different page
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.getTopMenuLink('features'));
|
2017-05-24 23:08:21 -04:00
|
|
|
expect(page.getDocViewerText()).toMatch(/Progressive web apps/i);
|
2017-03-21 03:02:58 -04:00
|
|
|
|
2017-04-15 03:37:41 -04:00
|
|
|
// Show the menu
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.docsMenuLink);
|
2017-03-29 17:13:40 -04:00
|
|
|
|
2017-06-08 18:46:32 -04:00
|
|
|
// Tutorial folder should still be expanded because this test runs in wide mode
|
2017-03-29 17:13:40 -04:00
|
|
|
// Navigate to the tutorial introduction via a link in the sidenav
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.getNavItem(/introduction/i));
|
2017-03-21 03:02:58 -04:00
|
|
|
expect(page.getDocViewerText()).toMatch(/Tutorial: Tour of Heroes/i);
|
|
|
|
});
|
|
|
|
|
2017-03-22 16:24:40 -04:00
|
|
|
it('should render `{@example}` dgeni tags as `<code-example>` elements with HTML escaped content', () => {
|
|
|
|
page.navigateTo('guide/component-styles');
|
|
|
|
const codeExample = element.all(by.css('code-example')).first();
|
2017-03-26 16:32:29 -04:00
|
|
|
expect(page.getInnerHtml(codeExample)).toContain('<h1>Tour of Heroes</h1>');
|
2017-03-22 16:24:40 -04:00
|
|
|
});
|
2017-03-13 21:08:23 -04:00
|
|
|
|
2017-06-01 17:03:10 -04:00
|
|
|
describe('scrolling to the top', () => {
|
|
|
|
it('should scroll to the top when navigating to another page', () => {
|
2017-10-12 05:59:51 -04:00
|
|
|
page.navigateTo('guide/security');
|
2017-11-02 15:40:14 -04:00
|
|
|
|
2017-06-01 17:03:10 -04:00
|
|
|
page.scrollToBottom();
|
2017-11-13 15:56:01 -05:00
|
|
|
expect(page.getScrollTop()).toBeGreaterThan(0);
|
2017-06-01 17:03:10 -04:00
|
|
|
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.getNavItem(/api/i));
|
2017-11-13 15:56:01 -05:00
|
|
|
expect(page.locationPath()).toBe('/api');
|
|
|
|
expect(page.getScrollTop()).toBe(0);
|
2017-06-01 17:03:10 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should scroll to the top when navigating to the same page', () => {
|
2017-10-12 05:59:51 -04:00
|
|
|
page.navigateTo('guide/security');
|
2017-11-02 15:40:14 -04:00
|
|
|
|
2017-06-01 17:03:10 -04:00
|
|
|
page.scrollToBottom();
|
2017-11-13 15:56:01 -05:00
|
|
|
expect(page.getScrollTop()).toBeGreaterThan(0);
|
2017-06-01 17:03:10 -04:00
|
|
|
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.getNavItem(/security/i));
|
2017-11-13 15:56:01 -05:00
|
|
|
expect(page.locationPath()).toBe('/guide/security');
|
|
|
|
expect(page.getScrollTop()).toBe(0);
|
2017-06-01 17:03:10 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-04-19 04:27:45 -04:00
|
|
|
describe('tutorial docs', () => {
|
|
|
|
it('should not render a paragraph element inside the h1 element', () => {
|
|
|
|
page.navigateTo('tutorial/toh-pt1');
|
|
|
|
expect(element(by.css('h1 p')).isPresent()).toBeFalsy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-03-29 16:20:09 -04:00
|
|
|
describe('contributors page', () => {
|
|
|
|
const groupButtons = element(by.css('.group-buttons')).all(by.css('.filter-button'));
|
|
|
|
const contributors = element(by.css('.contributor-group')).all(by.css('aio-contributor'));
|
|
|
|
|
|
|
|
beforeAll(() => page.navigateTo('about'));
|
|
|
|
|
|
|
|
it('should have the expected groups', () => {
|
|
|
|
expect(groupButtons.count()).toBe(3);
|
|
|
|
|
|
|
|
const texts = groupButtons.map<string>(btn => btn && btn.getText());
|
|
|
|
expect(texts).toEqual(['ANGULAR', 'COLLABORATORS', 'GDE']);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have contributors listed in each group', async () => {
|
|
|
|
const getContributorNames =
|
|
|
|
() => contributors.all(by.css('h3')).map<string>(c => c && c.getText());
|
|
|
|
|
|
|
|
const names1 = getContributorNames();
|
|
|
|
expect(contributors.count()).toBeGreaterThan(1);
|
|
|
|
|
|
|
|
groupButtons.get(1).click();
|
|
|
|
const names2 = getContributorNames();
|
|
|
|
expect(contributors.count()).toBeGreaterThan(1);
|
|
|
|
expect(names2).not.toEqual(names1);
|
|
|
|
|
|
|
|
groupButtons.get(2).click();
|
|
|
|
const names3 = getContributorNames();
|
|
|
|
expect(contributors.count()).toBeGreaterThan(1);
|
|
|
|
expect(names3).not.toEqual(names2);
|
|
|
|
expect(names3).not.toEqual(names1);
|
|
|
|
|
|
|
|
groupButtons.get(0).click();
|
|
|
|
const names4 = getContributorNames();
|
|
|
|
expect(contributors.count()).toBeGreaterThan(1);
|
|
|
|
expect(names4).not.toEqual(names3);
|
|
|
|
expect(names4).not.toEqual(names2);
|
|
|
|
expect(names4).toEqual(names1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-10-19 08:58:27 -04:00
|
|
|
describe('google analytics', () => {
|
2017-03-13 21:08:23 -04:00
|
|
|
|
2017-10-19 08:58:27 -04:00
|
|
|
it('should call ga with initial URL', done => {
|
|
|
|
let path: string;
|
|
|
|
page.navigateTo('api');
|
|
|
|
page.locationPath()
|
|
|
|
.then(p => path = p)
|
2017-11-13 15:56:01 -05:00
|
|
|
.then(() => page.ga())
|
|
|
|
.then(calls => {
|
2017-10-19 08:58:27 -04:00
|
|
|
// The last call (length-1) will be the `send` command
|
|
|
|
// The second to last call (length-2) will be the command to `set` the page url
|
|
|
|
expect(calls[calls.length - 2]).toEqual(['set', 'page', path]);
|
2017-03-13 21:08:23 -04:00
|
|
|
done();
|
2017-11-13 15:56:01 -05:00
|
|
|
});
|
2017-03-13 21:08:23 -04:00
|
|
|
});
|
|
|
|
|
2017-10-19 08:58:27 -04:00
|
|
|
it('should call ga with new URL on navigation', done => {
|
2017-03-13 21:08:23 -04:00
|
|
|
let path: string;
|
2017-11-13 15:56:01 -05:00
|
|
|
page.navigateTo('');
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.getTopMenuLink('features'));
|
2017-03-13 21:08:23 -04:00
|
|
|
page.locationPath()
|
|
|
|
.then(p => path = p)
|
2017-11-13 15:56:01 -05:00
|
|
|
.then(() => page.ga())
|
|
|
|
.then(calls => {
|
2017-10-19 08:58:27 -04:00
|
|
|
// The last call (length-1) will be the `send` command
|
|
|
|
// The second to last call (length-2) will be the command to `set` the page url
|
|
|
|
expect(calls[calls.length - 2]).toEqual(['set', 'page', path]);
|
2017-03-13 21:08:23 -04:00
|
|
|
done();
|
2017-11-13 15:56:01 -05:00
|
|
|
});
|
2017-03-13 21:08:23 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-10-12 05:59:25 -04:00
|
|
|
describe('404 page', () => {
|
2018-01-19 09:58:23 -05:00
|
|
|
it('should add or remove the "noindex" meta tag depending upon the validity of the page', () => {
|
|
|
|
page.navigateTo('');
|
|
|
|
expect(element(by.css('meta[name="robots"]')).isPresent()).toBeFalsy();
|
|
|
|
|
|
|
|
page.navigateTo('does/not/exist');
|
|
|
|
expect(element(by.css('meta[name="robots"][content="noindex"]')).isPresent()).toBeTruthy();
|
|
|
|
|
2018-01-16 05:40:24 -05:00
|
|
|
page.click(page.getTopMenuLink('features'));
|
2018-01-19 09:58:23 -05:00
|
|
|
expect(element(by.css('meta[name="robots"]')).isPresent()).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
2017-10-12 05:59:25 -04:00
|
|
|
it('should search the index for words found in the url', () => {
|
|
|
|
page.navigateTo('http/router');
|
2017-11-13 15:56:01 -05:00
|
|
|
const results = page.getSearchResults();
|
|
|
|
|
2018-09-17 12:37:18 -04:00
|
|
|
expect(results).toContain('HttpRequest');
|
2017-11-13 15:56:01 -05:00
|
|
|
expect(results).toContain('Router');
|
2017-10-12 05:59:25 -04:00
|
|
|
});
|
|
|
|
});
|
2018-06-09 09:48:40 -04:00
|
|
|
|
|
|
|
describe('suggest edit link', () => {
|
|
|
|
it('should be present on all docs pages', () => {
|
|
|
|
page.navigateTo('tutorial/toh-pt1');
|
|
|
|
expect(page.ghLinks.count()).toEqual(1);
|
|
|
|
/* tslint:disable:max-line-length */
|
|
|
|
expect(page.ghLinks.get(0).getAttribute('href'))
|
|
|
|
.toMatch(/https:\/\/github\.com\/angular\/angular\/edit\/master\/aio\/content\/tutorial\/toh-pt1\.md\?message=docs%3A%20describe%20your%20change\.\.\./);
|
|
|
|
|
|
|
|
page.navigateTo('guide/http');
|
|
|
|
expect(page.ghLinks.count()).toEqual(1);
|
|
|
|
/* tslint:disable:max-line-length */
|
|
|
|
expect(page.ghLinks.get(0).getAttribute('href'))
|
|
|
|
.toMatch(/https:\/\/github\.com\/angular\/angular\/edit\/master\/aio\/content\/guide\/http\.md\?message=docs%3A%20describe%20your%20change\.\.\./);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not be present on top level pages', () => {
|
|
|
|
page.navigateTo('features');
|
|
|
|
expect(page.ghLinks.count()).toEqual(0);
|
|
|
|
});
|
|
|
|
});
|
2017-01-27 03:20:51 -05:00
|
|
|
});
|