aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
blob: 71840d7073bca47e6f886d736a223fa23cff17bc (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
83
84
85
86
import { LoginPage } from '../po/login.po'
import { VideoUploadPage } from '../po/video-upload.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { go, isMobileDevice, isSafari, waitServerUp } from '../utils'

describe('Custom server defaults', () => {
  let videoUploadPage: VideoUploadPage
  let loginPage: LoginPage
  let videoWatchPage: VideoWatchPage

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

    loginPage = new LoginPage(isMobileDevice())
    videoUploadPage = new VideoUploadPage()
    videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())

    await browser.maximizeWindow()
  })

  describe('Publish default values', function () {
    before(async function () {
      await loginPage.loginAsRootUser()
    })

    it('Should upload a video with custom default values', async function () {
      await videoUploadPage.navigateTo()
      await videoUploadPage.uploadVideo('video.mp4')
      await videoUploadPage.validSecondUploadStep('video')

      await videoWatchPage.waitWatchVideoName('video')

      expect(await videoWatchPage.getPrivacy()).toBe('Internal')
      expect(await videoWatchPage.getLicence()).toBe('Attribution - Non Commercial')
      expect(await videoWatchPage.isDownloadEnabled()).toBeFalsy()
      expect(await videoWatchPage.areCommentsEnabled()).toBeFalsy()
    })

    after(async function () {
      await loginPage.logout()
    })
  })

  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('video2.mp4')
      await videoUploadPage.setAsPublic()
      await videoUploadPage.validSecondUploadStep('video')

      await videoWatchPage.waitWatchVideoName('video')

      videoUrl = await browser.getUrl()
    })

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

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

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

      await checkP2P(false)
    })
  })
})