diff --git a/e2e/community-list-page/community-list-page.e2e-spec.ts b/e2e/community-list-page/community-list-page.e2e-spec.ts new file mode 100644 index 00000000000..84c7257726e --- /dev/null +++ b/e2e/community-list-page/community-list-page.e2e-spec.ts @@ -0,0 +1,28 @@ +import { CommunityListPageProtractor } from './community-list-page.po'; + +describe('protractor CommunityListPage', () => { + let page: CommunityListPageProtractor; + + beforeEach(() => { + page = new CommunityListPageProtractor(); + }); + + it('should contain page-limited top communities (at least 1 expandable community)', () => { + page.navigateToCommunityList(); + expect(page.anExpandableCommunityIsPresent()).toEqual(true) + }); + + describe('if expanded a node and navigating away, tree state gets saved', () => { + it('if navigating back, same node is expanded', () => { + page.navigateToCommunityList(); + const linkOfSecondNodeBeforeExpanding = page.getLinkOfSecondNode(); + page.toggleExpandFirstExpandableCommunity(); + const linkOfSecondNodeAfterExpanding = page.getLinkOfSecondNode(); + page.navigateToHome(); + page.navigateToCommunityList(); + expect(page.getLinkOfSecondNode()).toEqual(linkOfSecondNodeAfterExpanding); + page.toggleExpandFirstExpandableCommunity(); + expect(page.getLinkOfSecondNode()).toEqual(linkOfSecondNodeBeforeExpanding); + }); + }); +}); diff --git a/e2e/community-list-page/community-list-page.po.ts b/e2e/community-list-page/community-list-page.po.ts new file mode 100644 index 00000000000..332aa5a80a8 --- /dev/null +++ b/e2e/community-list-page/community-list-page.po.ts @@ -0,0 +1,32 @@ +import { browser, by, element, protractor } from 'protractor'; + +export class CommunityListPageProtractor { + HOMEPAGE = '/home'; + COMMUNITY_LIST = '/community-list'; + + navigateToHome() { + return browser.get(this.HOMEPAGE); + } + + navigateToCommunityList() { + browser.get(this.COMMUNITY_LIST); + const loading = element(by.css('.ds-loading')); + browser.wait(protractor.ExpectedConditions.invisibilityOf(loading), 10000); + return; + + } + + anExpandableCommunityIsPresent() { + console.log(element(by.css('body'))); + return element(by.css('.expandable-node h5 a')).isPresent(); + } + + toggleExpandFirstExpandableCommunity() { + element(by.css('.expandable-node button')).click(); + } + + getLinkOfSecondNode() { + return element(by.css('.cdk-tree-node h5 a')).getAttribute('href'); + } + +}