]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/e2e/src/po/login.po.ts
Add ability for admins to set default p2p policy
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / login.po.ts
index 90b65c7ea216ba037540d904f664888ffee7c854..486b9a6d8b5a164b58f400d5e1c13b678e130ca7 100644 (file)
@@ -1,20 +1,43 @@
-import { browser, element, by } from 'protractor'
+import { go } from '../utils'
 
 export class LoginPage {
+
   async loginAsRootUser () {
-    await browser.get('/login')
+    await go('/login')
+
+    await browser.execute(`window.localStorage.setItem('no_instance_config_warning_modal', 'true')`)
+    await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`)
+
+    await $('input#username').setValue('root')
+    await $('input#password').setValue('test' + this.getSuffix())
+
+    await browser.pause(1000)
+
+    await $('form input[type=submit]').click()
 
-    element(by.css('input#username')).sendKeys('root')
-    element(by.css('input#password')).sendKeys('test1')
+    await this.getLoggedInInfoElem().waitForExist()
 
-    await browser.sleep(1000)
+    await expect(this.getLoggedInInfoElem()).toHaveText('root')
+  }
+
+  async logout () {
+    await $('.logged-in-more').click()
+
+    const logout = () => $('.dropdown-item*=Log out')
 
-    await element(by.css('form input[type=submit]')).click()
+    await logout().waitForDisplayed()
+    await logout().click()
+
+    await $('.login-buttons-block').waitForDisplayed()
+  }
 
-    expect(this.getLoggedInInfo().getText()).toContain('root')
+  private getLoggedInInfoElem () {
+    return $('.logged-in-display-name')
   }
 
-  private getLoggedInInfo () {
-    return element(by.css('.logged-in-display-name'))
+  private getSuffix () {
+    return browser.config.baseUrl
+      ? browser.config.baseUrl.slice(-1)
+      : '1'
   }
 }