aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/suites-local/user-settings.e2e-spec.ts
blob: b87501cd1efa65a3f040e10c8f2a29c511047cd0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { AnonymousSettingsPage } from '../po/anonymous-settings.po'
import { LoginPage } from '../po/login.po'
import { MyAccountPage } from '../po/my-account.po'
import { VideoUploadPage } from '../po/video-upload.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { go, isMobileDevice, isSafari, waitServerUp } from '../utils'

describe('User settings', () => {
  let videoUploadPage: VideoUploadPage
  let loginPage: LoginPage
  let videoWatchPage: VideoWatchPage
  let myAccountPage: MyAccountPage
  let anonymousSettingsPage: AnonymousSettingsPage

  before(async () => {
    await waitServerUp()

    loginPage = new LoginPage()
    videoUploadPage = new VideoUploadPage()
    videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
    myAccountPage = new MyAccountPage()
    anonymousSettingsPage = new AnonymousSettingsPage()

    await browser.maximizeWindow()
  })

  describe('P2P', function () {
    let videoUrl: string

    async function goOnVideoWatchPage () {
      await go(videoUrl)
      await videoWatchPage.waitWatchVideoName('video')
    }

    async function checkP2P (enabled: boolean) {
      await goOnVideoWatchPage()
      expect(await videoWatchPage.isPrivacyWarningDisplayed()).toEqual(enabled)

      await videoWatchPage.goOnAssociatedEmbed()
      expect(await videoWatchPage.isEmbedWarningDisplayed()).toEqual(enabled)
    }

    before(async () => {
      await loginPage.loginAsRootUser()
      await videoUploadPage.navigateTo()
      await videoUploadPage.uploadVideo()
      await videoUploadPage.validSecondUploadStep('video')

      await videoWatchPage.waitWatchVideoName('video')

      videoUrl = await browser.getUrl()
    })

    beforeEach(async function () {
      await goOnVideoWatchPage()
    })

    it('Should have P2P enabled for a logged in user', async function () {
      await checkP2P(true)
    })

    it('Should disable P2P for a logged in user', async function () {
      await myAccountPage.navigateToMySettings()
      await myAccountPage.clickOnP2PCheckbox()

      await checkP2P(false)
    })

    it('Should have P2P enabled for anonymous users', async function () {
      await loginPage.logout()

      await checkP2P(true)
    })

    it('Should disable P2P for an anonymous user', async function () {
      await anonymousSettingsPage.openSettings()
      await anonymousSettingsPage.clickOnP2PCheckbox()

      await checkP2P(false)
    })
  })
})