Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add videos bulk actions E2E tests

Chocobozzzf44e644d4bbd
diff --git a/client/e2e/src/po/bulk-update.po.ts b/client/e2e/src/po/bulk-update.po.ts
new file mode 100644
index 0000000000..a06d67b090
--- /dev/null
+++ b/client/e2e/src/po/bulk-update.po.ts
@@ -0,0 +1,107 @@
+import { browserSleep, getCheckbox } from '../utils'
+
+export class BulkUpdatePage {
+ async openBulkUpdate () {
+ const batchActions = $('my-action-dropdown[label="Batch actions"]')
+ await batchActions.waitForDisplayed()
+
+ const toggle = batchActions.$('.dropdown-toggle')
+ await toggle.waitForClickable()
+ await toggle.click()
+
+ const updateItem = await this.getActionItem('Update')
+ await updateItem.waitForClickable()
+ await updateItem.click()
+ }
+
+ async addField (fieldKey: string) {
+ const select = $('.bulk-update-add-field select')
+ await select.waitForDisplayed()
+ await select.selectByAttribute('value', fieldKey)
+ await browserSleep(500)
+ }
+
+ async setDownloadEnabled (enabled: boolean) {
+ const checkbox = await getCheckbox('bulk-downloadEnabled')
+ await checkbox.waitForClickable()
+
+ const input = checkbox.$('input')
+ const isChecked = await input.isSelected()
+
+ if (isChecked !== enabled) {
+ await checkbox.click()
+ }
+ }
+
+ async setSupport (text: string) {
+ const textarea = $('.bulk-update-field-section textarea')
+ await textarea.waitForDisplayed()
+ await textarea.setValue(text)
+ }
+
+ async clickNext () {
+ const btn = await this.getButtonByLabel('Next')
+ await btn.waitForClickable()
+ await btn.click()
+ }
+
+ async clickBack () {
+ const btn = $('input[value="Back"]')
+ await btn.waitForClickable()
+ await btn.click()
+ }
+
+ async clickUpdate () {
+ const btn = await this.getButtonByLabel('Update')
+ await btn.waitForClickable()
+ await btn.click()
+ }
+
+ async waitForConfigureStep () {
+ const nextBtn = await this.getButtonByLabel('Next')
+ await nextBtn.waitForDisplayed()
+ }
+
+ async waitForConfirmStep () {
+ const updateBtn = await this.getButtonByLabel('Update')
+ await updateBtn.waitForDisplayed()
+
+ const backBtn = $('input[value="Back"]')
+ await backBtn.waitForDisplayed()
+ }
+
+ async getConfirmSummaryText () {
+ const modalBody = $('.modal-body')
+ await modalBody.waitForDisplayed()
+
+ return modalBody.getText()
+ }
+
+ async closeModal () {
+ const closeBtn = $('.modal-header .border-0')
+ await closeBtn.waitForClickable()
+ await closeBtn.click()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ private async getButtonByLabel (label: string) {
+ const buttons = await $$('my-button button.action-button').filter(async b => {
+ const text = await b.getText()
+
+ return text.trim() === label
+ })
+
+ return buttons[0]
+ }
+
+ private async getActionItem (label: string) {
+ const items = await $$('span.custom-action.dropdown-item').filter(async i => {
+ const text = await i.getText()
+
+ return text.includes(label)
+ })
+
+ return items[0]
+ }
+}
diff --git a/client/e2e/src/po/my-account.po.ts b/client/e2e/src/po/my-account.po.ts
index b3f0da0923..76b0f8ecdb 100644
--- a/client/e2e/src/po/my-account.po.ts
+++ b/client/e2e/src/po/my-account.po.ts
@@ -2,10 +2,6 @@ import { NSFWPolicyType } from '@peertube/peertube-models'
import { getCheckbox, go, selectCustomSelect } from '../utils'
export class MyAccountPage {
- navigateToMyVideos () {
- return $('a[href="/my-library/videos"]').click()
- }
-
navigateToMyPlaylists () {
return $('a[href="/my-library/video-playlists"]').click()
}
@@ -81,54 +77,6 @@ export class MyAccountPage {
await submit.click()
}
- // ---------------------------------------------------------------------------
- // My account videos
- // ---------------------------------------------------------------------------
-
- async removeVideo (name: string) {
- const container = await this.getVideoRow(name)
-
- await container.$('my-action-dropdown .dropdown-toggle').click()
-
- const deleteItem = () => {
- return $$('.dropdown-menu .dropdown-item').find<WebdriverIO.Element>(async v => {
- const text = await v.getText()
-
- return text.includes('Delete')
- })
- }
-
- await (await deleteItem()).waitForClickable()
-
- return (await deleteItem()).click()
- }
-
- validRemove () {
- return $('input[type=submit]').click()
- }
-
- async countVideos (names: string[]) {
- const elements = await $$('.video-cell-name .name').filter(async e => {
- const t = await e.getText()
-
- return names.some(n => t.includes(n))
- })
-
- return elements.length
- }
-
- async getVideoRow (name: string) {
- let el = $('.name*=' + name)
-
- await el.waitForDisplayed()
-
- while (await el.getTagName() !== 'tr') {
- el = el.parentElement()
- }
-
- return el
- }
-
// ---------------------------------------------------------------------------
// My account playlists
// ---------------------------------------------------------------------------
diff --git a/client/e2e/src/po/my-videos.po.ts b/client/e2e/src/po/my-videos.po.ts
new file mode 100644
index 0000000000..53d8c40f1e
--- /dev/null
+++ b/client/e2e/src/po/my-videos.po.ts
@@ -0,0 +1,76 @@
+export class MyVideosPage {
+ navigateToMyVideos () {
+ return $('a[href="/my-library/videos"]').click()
+ }
+
+ async selectVideoRow (videoName: string) {
+ const row = await this.getVideoRow(videoName)
+
+ const checkbox = row.$('.checkbox-cell')
+ await checkbox.waitForClickable()
+ await checkbox.click()
+ }
+
+ async selectAllVideos () {
+ const headerCheckbox = $('p-tableHeaderCheckbox')
+ await headerCheckbox.waitForClickable()
+ await headerCheckbox.click()
+ }
+
+ async removeVideo (name: string) {
+ const container = await this.getVideoRow(name)
+
+ await container.$('my-action-dropdown .dropdown-toggle').click()
+
+ const deleteItem = () => {
+ return $$('.dropdown-menu .dropdown-item').find<WebdriverIO.Element>(async v => {
+ const text = await v.getText()
+
+ return text.includes('Delete')
+ })
+ }
+
+ await (await deleteItem()).waitForClickable()
+
+ return (await deleteItem()).click()
+ }
+
+ validRemove () {
+ return $('input[type=submit]').click()
+ }
+
+ async countVideos (names: string[]) {
+ const elements = await $$('.video-cell-name .name').filter(async e => {
+ const t = await e.getText()
+
+ return names.some(n => t.includes(n))
+ })
+
+ return elements.length
+ }
+
+ async getVideoRow (name: string) {
+ let el = $('.name*=' + name)
+
+ await el.waitForDisplayed()
+
+ while (await el.getTagName() !== 'tr') {
+ el = el.parentElement()
+ }
+
+ return el
+ }
+
+ async clickOnManage (videoName: string) {
+ const row = await this.getVideoRow(videoName)
+
+ const manageButtons = await row.$$('my-button a').filter(async a => {
+ const text = await a.getText()
+ return text.trim() === 'Manage'
+ })
+
+ const manageButton = manageButtons[0]
+ await manageButton.waitForClickable()
+ await manageButton.click()
+ }
+}
diff --git a/client/e2e/src/po/video-manage.ts b/client/e2e/src/po/video-manage.ts
index 9b981b029e..33957f258b 100644
--- a/client/e2e/src/po/video-manage.ts
+++ b/client/e2e/src/po/video-manage.ts
@@ -111,6 +111,15 @@ export abstract class VideoManage {
// ---------------------------------------------------------------------------
+ async getSupportValue () {
+ const supportInput = $('#support')
+ await supportInput.waitForDisplayed()
+
+ return supportInput.getValue()
+ }
+
+ // ---------------------------------------------------------------------------
+
async refresh (videoName: string) {
await browser.refresh()
await browser.waitUntil(async () => {
diff --git a/client/e2e/src/suites-all/videos.e2e-spec.ts b/client/e2e/src/suites-all/videos.e2e-spec.ts
index 3cbc6b5f22..c7cedb365e 100644
--- a/client/e2e/src/suites-all/videos.e2e-spec.ts
+++ b/client/e2e/src/suites-all/videos.e2e-spec.ts
@@ -1,5 +1,6 @@
import { LoginPage } from '../po/login.po'
import { MyAccountPage } from '../po/my-account.po'
+import { MyVideosPage } from '../po/my-videos.po'
import { PlayerPage } from '../po/player.po'
import { VideoListPage } from '../po/video-list.po'
import { VideoPublishPage } from '../po/video-publish.po'
@@ -22,6 +23,7 @@ describe('Videos all workflow', () => {
let videoPublishPage: VideoPublishPage
let videoUpdatePage: VideoUpdatePage
let myAccountPage: MyAccountPage
+ let myVideosPage: MyVideosPage
let loginPage: LoginPage
let playerPage: PlayerPage
@@ -52,6 +54,7 @@ describe('Videos all workflow', () => {
loginPage = new LoginPage(isMobileDevice())
playerPage = new PlayerPage()
videoListPage = new VideoListPage(isMobileDevice(), isSafari())
+ myVideosPage = new MyVideosPage()
await prepareWebBrowser()
})
@@ -212,13 +215,13 @@ describe('Videos all workflow', () => {
// Go to the dev website
await go(videoWatchUrl)
- await myAccountPage.navigateToMyVideos()
+ await myVideosPage.navigateToMyVideos()
- await myAccountPage.removeVideo(video2Name)
- await myAccountPage.validRemove()
+ await myVideosPage.removeVideo(video2Name)
+ await myVideosPage.validRemove()
await browser.waitUntil(async () => {
- const count = await myAccountPage.countVideos([ videoName, video2Name ])
+ const count = await myVideosPage.countVideos([ videoName, video2Name ])
return count === 1
})
@@ -227,7 +230,7 @@ describe('Videos all workflow', () => {
it('Should delete the first video', async () => {
if (isUploadUnsupported()) return
- await myAccountPage.removeVideo(videoName)
- await myAccountPage.validRemove()
+ await myVideosPage.removeVideo(videoName)
+ await myVideosPage.validRemove()
})
})
diff --git a/client/e2e/src/suites-local/bulk-update.e2e-spec.ts b/client/e2e/src/suites-local/bulk-update.e2e-spec.ts
new file mode 100644
index 0000000000..d628b9b853
--- /dev/null
+++ b/client/e2e/src/suites-local/bulk-update.e2e-spec.ts
@@ -0,0 +1,95 @@
+import { BulkUpdatePage } from '../po/bulk-update.po'
+import { LoginPage } from '../po/login.po'
+import { MyVideosPage } from '../po/my-videos.po'
+import { VideoPublishPage } from '../po/video-publish.po'
+import { VideoUpdatePage } from '../po/video-update.po'
+import { isMobileDevice, prepareWebBrowser, waitServerUp } from '../utils'
+
+describe('Bulk update videos', () => {
+ let loginPage: LoginPage
+ let videoPublishPage: VideoPublishPage
+ let bulkUpdatePage: BulkUpdatePage
+ let myVideosPage: MyVideosPage
+ let videoUpdatePage: VideoUpdatePage
+
+ const seed = Math.random().toString().slice(2, 8)
+
+ before(async () => {
+ await waitServerUp()
+
+ loginPage = new LoginPage(isMobileDevice())
+ videoPublishPage = new VideoPublishPage()
+ bulkUpdatePage = new BulkUpdatePage()
+ myVideosPage = new MyVideosPage()
+ videoUpdatePage = new VideoUpdatePage()
+
+ await prepareWebBrowser()
+ await loginPage.loginAsRootUser()
+
+ // Upload two test videos so we have something to bulk update
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video.mp4')
+ await videoPublishPage.validSecondStep(`bulk-test-1-${seed}`)
+
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video2.mp4')
+ await videoPublishPage.validSecondStep(`bulk-test-2-${seed}`)
+ })
+
+ it('Should select videos and open the bulk update modal', async function () {
+ await myVideosPage.navigateToMyVideos()
+
+ await myVideosPage.selectVideoRow(`bulk-test-1-${seed}`)
+ await myVideosPage.selectVideoRow(`bulk-test-2-${seed}`)
+
+ await bulkUpdatePage.openBulkUpdate()
+ await bulkUpdatePage.waitForConfigureStep()
+ })
+
+ it('Should add fields and show them in the confirm step', async function () {
+ // Add "support" field (textarea) and set a value
+ await bulkUpdatePage.addField('support')
+ await bulkUpdatePage.setSupport('Updated support text')
+
+ // Add "downloadEnabled" field (checkbox) and disable it
+ await bulkUpdatePage.addField('downloadEnabled')
+ await bulkUpdatePage.setDownloadEnabled(false)
+
+ // Advance to the confirm step
+ await bulkUpdatePage.clickNext()
+ await bulkUpdatePage.waitForConfirmStep()
+
+ const summary = await bulkUpdatePage.getConfirmSummaryText()
+ expect(summary).toContain('Updated support text')
+ expect(summary).toContain('No')
+ })
+
+ it('Should go back, modify values, and re-confirm', async function () {
+ await bulkUpdatePage.clickBack()
+ await bulkUpdatePage.waitForConfigureStep()
+
+ // Re-enable downloads
+ await bulkUpdatePage.setDownloadEnabled(true)
+
+ await bulkUpdatePage.clickNext()
+ await bulkUpdatePage.waitForConfirmStep()
+
+ const summary = await bulkUpdatePage.getConfirmSummaryText()
+ expect(summary).toContain('Updated support text')
+ expect(summary).toContain('Yes')
+ })
+
+ it('Should execute the bulk update and persist changes', async function () {
+ await bulkUpdatePage.clickUpdate()
+
+ await $('.modal-header').waitForDisplayed({ reverse: true })
+
+ // Navigate to the manage page for the first video to verify support was updated
+ await myVideosPage.clickOnManage(`bulk-test-1-${seed}`)
+
+ await $('my-video-manage-container').waitForDisplayed()
+
+ const value = await videoUpdatePage.getSupportValue()
+ expect(value).toContain('Updated support text')
+ })
+})