From 31ef92fc366ada3bf37a5bd727abaf880ab360ee Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Fri, 17 Mar 2017 23:02:03 +0000 Subject: [PATCH] build(aio): fix generated github links The change from `modules` to `packages` needed to be applied to these links. --- aio/e2e/app.e2e-spec.ts | 8 ++++++++ aio/e2e/app.po.ts | 12 +++++++++--- aio/transforms/templates/lib/githubLinks.html | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/aio/e2e/app.e2e-spec.ts b/aio/e2e/app.e2e-spec.ts index ec85677381..851af5b775 100644 --- a/aio/e2e/app.e2e-spec.ts +++ b/aio/e2e/app.e2e-spec.ts @@ -17,6 +17,14 @@ describe('site App', function() { it('should convert a doc with a code-example'); + describe('api-docs', () => { + it('should show a link to github', () => { + page.navigateTo('api/common/NgClass'); + expect(page.ghLink.getAttribute('href')) + .toMatch(/https:\/\/github.com\/angular\/angular\/tree\/.+\/packages\/common\/src\/directives\/ng_class\.ts/); + }); + }); + describe('google analytics', () => { beforeEach(done => page.gaReady.then(done)); diff --git a/aio/e2e/app.po.ts b/aio/e2e/app.po.ts index 1fcf251346..8f00e39a9c 100644 --- a/aio/e2e/app.po.ts +++ b/aio/e2e/app.po.ts @@ -1,16 +1,22 @@ -import { browser, element, by, promise } from 'protractor'; +import { browser, element, by, promise, ElementFinder } from 'protractor'; + +const githubRegex = /https:\/\/github.com\/angular\/angular\//; export class SitePage { links = element.all(by.css('md-toolbar a')); docViewer = element(by.css('aio-doc-viewer')); codeExample = element.all(by.css('aio-doc-viewer pre > code')); + ghLink = this.docViewer + .all(by.css('a')) + .filter((a: ElementFinder) => a.getAttribute('href').then(href => githubRegex.test(href))) + .first(); featureLink = element(by.css('md-toolbar a[href="features"]')); gaReady: promise.Promise; ga = () => browser.executeScript('return window["gaCalls"]') as promise.Promise; locationPath = () => browser.executeScript('return document.location.pathname') as promise.Promise; - navigateTo() { - return browser.get('/').then(_ => this.replaceGa(_)); + navigateTo(pageUrl = '') { + return browser.get('/' + pageUrl).then(_ => this.replaceGa(_)); } getDocViewerText() { diff --git a/aio/transforms/templates/lib/githubLinks.html b/aio/transforms/templates/lib/githubLinks.html index 53d5132765..c077673de2 100644 --- a/aio/transforms/templates/lib/githubLinks.html +++ b/aio/transforms/templates/lib/githubLinks.html @@ -1,5 +1,5 @@ {% macro githubHref(doc, versionInfo) -%} -https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInfo.repo $}/tree/{$ versionInfo.currentVersion.isSnapshot and versionInfo.currentVersion.SHA or versionInfo.currentVersion.raw $}/modules/{$ doc.fileInfo.projectRelativePath $}#L{$ doc.location.start.line+1 $}-L{$ doc.location.end.line+1 $} +https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInfo.repo $}/tree/{$ versionInfo.currentVersion.isSnapshot and versionInfo.currentVersion.SHA or versionInfo.currentVersion.raw $}/packages/{$ doc.fileInfo.projectRelativePath $}#L{$ doc.location.start.line+1 $}-L{$ doc.location.end.line+1 $} {%- endmacro %} {% macro githubViewLink(doc, versionInfo) -%}