aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/suites-local/video-password.e2e-spec.ts
blob: cd1b1d48efedd32dea27bbf15a2d30cef6c6ea13 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import { LoginPage } from '../po/login.po'
import { SignupPage } from '../po/signup.po'
import { PlayerPage } from '../po/player.po'
import { VideoUploadPage } from '../po/video-upload.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { go, isMobileDevice, isSafari, waitServerUp } from '../utils'
import { MyAccountPage } from '../po/my-account.po'

describe('Password protected videos', () => {
  let videoUploadPage: VideoUploadPage
  let loginPage: LoginPage
  let videoWatchPage: VideoWatchPage
  let signupPage: SignupPage
  let playerPage: PlayerPage
  let myAccountPage: MyAccountPage
  let passwordProtectedVideoUrl: string
  let playlistUrl: string

  const seed = Math.random()
  const passwordProtectedVideoName = seed + ' - password protected'
  const publicVideoName1 = seed + ' - public 1'
  const publicVideoName2 = seed + ' - public 2'
  const videoPassword = 'password'
  const regularUsername = 'user_1'
  const regularUserPassword = 'user password'
  const playlistName = seed + ' - playlist'

  function testRateAndComment () {
    it('Should add and remove like on video', async function () {
      await videoWatchPage.like()
      await videoWatchPage.like()
    })

    it('Should create thread on video', async function () {
      await videoWatchPage.createThread('My first comment')
    })

    it('Should reply to thread on video', async function () {
      await videoWatchPage.createReply('My first reply')
    })
  }

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

    loginPage = new LoginPage(isMobileDevice())
    videoUploadPage = new VideoUploadPage()
    videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
    signupPage = new SignupPage()
    playerPage = new PlayerPage()
    myAccountPage = new MyAccountPage()

    await browser.maximizeWindow()
  })

  describe('Owner', function () {
    before(async () => {
      await loginPage.loginAsRootUser()
    })

    it('Should login, upload a public video and save it to a playlist', async () => {
      await videoUploadPage.navigateTo()
      await videoUploadPage.uploadVideo('video.mp4')
      await videoUploadPage.validSecondUploadStep(publicVideoName1)

      await videoWatchPage.clickOnSave()

      await videoWatchPage.createPlaylist(playlistName)

      await videoWatchPage.saveToPlaylist(playlistName)
      await browser.pause(5000)

    })

    it('Should upload a password protected video', async () => {
      await videoUploadPage.navigateTo()
      await videoUploadPage.uploadVideo('video2.mp4')
      await videoUploadPage.setAsPasswordProtected(videoPassword)
      await videoUploadPage.validSecondUploadStep(passwordProtectedVideoName)

      await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName)

      passwordProtectedVideoUrl = await browser.getUrl()
    })

    it('Should save to playlist the password protected video', async () => {
      await videoWatchPage.clickOnSave()
      await videoWatchPage.saveToPlaylist(playlistName)
    })

    it('Should upload a second public video and save it to playlist', async () => {
      await videoUploadPage.navigateTo()

      await videoUploadPage.uploadVideo('video3.mp4')
      await videoUploadPage.validSecondUploadStep(publicVideoName2)

      await videoWatchPage.clickOnSave()
      await videoWatchPage.saveToPlaylist(playlistName)
    })

    it('Should play video without password', async function () {
      await go(passwordProtectedVideoUrl)

      expect(!await videoWatchPage.isPasswordProtected())

      await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName)

      expect(await videoWatchPage.getPrivacy()).toBe('Password protected')
      await playerPage.playAndPauseVideo(false, 2)
    })

    testRateAndComment()

    it('Should play video on embed without password', async function () {
      await videoWatchPage.goOnAssociatedEmbed()
      await playerPage.playAndPauseVideo(false, 2)
    })

    it('Should have the playlist in my account', async function () {
      await go('/')
      await myAccountPage.navigateToMyPlaylists()
      const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName)

      expect(videosNumberText).toEqual('3 videos')
      await myAccountPage.clickOnPlaylist(playlistName)

      const count = await myAccountPage.countTotalPlaylistElements()
      expect(count).toEqual(3)
    })

    it('Should update the playlist to public', async () => {
      const url = await browser.getUrl()
      const regex = /\/([a-f0-9-]+)$/i
      const match = url.match(regex)
      const uuid = match ? match[1] : null

      await myAccountPage.updatePlaylistPrivacy(uuid, 'Public')
    })

    it('Should watch the playlist', async () => {
      await myAccountPage.clickOnPlaylist(playlistName)
      await myAccountPage.playPlaylist()
      playlistUrl = await browser.getUrl()

      await videoWatchPage.waitUntilVideoName(publicVideoName1, 40 * 1000)
      await videoWatchPage.waitUntilVideoName(passwordProtectedVideoName, 40 * 1000)
      await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000)
    })

    after(async () => {
      await loginPage.logout()
    })
  })

  describe('Regular users', function () {
    before(async () => {
      await signupPage.fullSignup({
        accountInfo: {
          username: regularUsername,
          password: regularUserPassword
        },
        channelInfo: {
          name: 'user_1_channel'
        }
      })
    })

    it('Should requires password to play video', async function () {
      await go(passwordProtectedVideoUrl)

      expect(await videoWatchPage.isPasswordProtected())

      await videoWatchPage.fillVideoPassword(videoPassword)
      await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName)

      expect(await videoWatchPage.getPrivacy()).toBe('Password protected')
      await playerPage.playAndPauseVideo(true, 2)
    })

    testRateAndComment()

    it('Should requires password to play video on embed', async function () {
      await videoWatchPage.goOnAssociatedEmbed(true)
      await playerPage.fillEmbedVideoPassword(videoPassword)
      await playerPage.playAndPauseVideo(false, 2)
    })

    it('Should watch the playlist without password protected video', async () => {
      await go(playlistUrl)
      await playerPage.playVideo()
      await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000)
    })

    after(async () => {
      await loginPage.logout()
    })
  })

  describe('Anonymous users', function () {
    it('Should requires password to play video', async function () {
      await go(passwordProtectedVideoUrl)

      expect(await videoWatchPage.isPasswordProtected())

      await videoWatchPage.fillVideoPassword(videoPassword)
      await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName)

      expect(await videoWatchPage.getPrivacy()).toBe('Password protected')
      await playerPage.playAndPauseVideo(true, 2)
    })

    it('Should requires password to play video on embed', async function () {
      await videoWatchPage.goOnAssociatedEmbed(true)
      await playerPage.fillEmbedVideoPassword(videoPassword)
      await playerPage.playAndPauseVideo(false, 2)
    })

    it('Should watch the playlist without password protected video', async () => {
      await go(playlistUrl)
      await playerPage.playVideo()
      await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000)
    })
  })
})