Fix local E2E tests

pull/6266/head
Chocobozzz 2024-03-06 10:36:40 +01:00
parent 15b8f96b75
commit 2fc3b90cb7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
11 changed files with 131 additions and 108 deletions

View File

@ -56,7 +56,7 @@ export class MyAccountPage {
async removeVideo (name: string) { async removeVideo (name: string) {
const container = await this.getVideoElement(name) const container = await this.getVideoElement(name)
await container.$('.dropdown-toggle').click() await container.$('my-action-dropdown .dropdown-toggle').click()
const deleteItem = () => { const deleteItem = () => {
return $$('.dropdown-menu .dropdown-item').find<WebdriverIO.Element>(async v => { return $$('.dropdown-menu .dropdown-item').find<WebdriverIO.Element>(async v => {
@ -120,9 +120,7 @@ export class MyAccountPage {
async updatePlaylistPrivacy (playlistUUID: string, privacy: 'Public' | 'Private' | 'Unlisted') { async updatePlaylistPrivacy (playlistUUID: string, privacy: 'Public' | 'Private' | 'Unlisted') {
go('/my-library/video-playlists/update/' + playlistUUID) go('/my-library/video-playlists/update/' + playlistUUID)
await browser.waitUntil(async () => { await $('a[href*="/my-library/video-playlists/update/"]').waitForDisplayed()
return (await $('form .video-playlist-title').getText() === 'PLAYLIST')
})
await selectCustomSelect('videoChannelId', 'Main root channel') await selectCustomSelect('videoChannelId', 'Main root channel')
await selectCustomSelect('privacy', privacy) await selectCustomSelect('privacy', privacy)

View File

@ -67,7 +67,7 @@ export class VideoListPage {
async getVideosListName () { async getVideosListName () {
const elems = await $$('.videos .video-miniature .video-miniature-name') const elems = await $$('.videos .video-miniature .video-miniature-name')
const texts = await Promise.all(elems.map(e => e.getText())) const texts = await elems.map(e => e.getText())
return texts.map(t => t.trim()) return texts.map(t => t.trim())
} }

View File

@ -13,8 +13,11 @@ export class VideoWatchPage {
const index = this.isMobileDevice ? 0 : 1 const index = this.isMobileDevice ? 0 : 1
return browser.waitUntil(async () => { return browser.waitUntil(async () => {
return await $('.video-info .video-info-name').isExisting() && if (!await $('.video-info .video-info-name').isExisting()) return false
(await $$('.video-info .video-info-name')[index].getText()).includes(videoName)
const elem = await $$('.video-info .video-info-name')[index]
return (await elem.getText()).includes(videoName) && elem.isDisplayed()
}) })
} }
@ -31,9 +34,13 @@ export class VideoWatchPage {
} }
async isDownloadEnabled () { async isDownloadEnabled () {
await this.clickOnMoreDropdownIcon() try {
await this.clickOnMoreDropdownIcon()
return $('.dropdown-item .icon-download').isExisting() return await $('.dropdown-item .icon-download').isExisting()
} catch {
return $('.action-button-download').isDisplayed()
}
} }
areCommentsEnabled () { areCommentsEnabled () {

View File

@ -176,7 +176,7 @@ describe('Videos all workflow', () => {
await videoWatchPage.waitUntilVideoName(video2Name, 40 * 1000) await videoWatchPage.waitUntilVideoName(video2Name, 40 * 1000)
}) })
it('Should watch the WEB VIDEO playlist in the embed', async () => { it('Should watch the Web Video playlist in the embed', async () => {
if (isUploadUnsupported()) return if (isUploadUnsupported()) return
const accessToken = await browser.execute(`return window.localStorage.getItem('access_token');`) const accessToken = await browser.execute(`return window.localStorage.getItem('access_token');`)

View File

@ -30,14 +30,21 @@ describe('Custom server defaults', () => {
await videoWatchPage.waitWatchVideoName('video') await videoWatchPage.waitWatchVideoName('video')
expect(await videoWatchPage.getPrivacy()).toBe('Internal') const videoUrl = await browser.getUrl()
expect(await videoWatchPage.getLicence()).toBe('Attribution - Non Commercial')
expect(await videoWatchPage.isDownloadEnabled()).toBeFalsy()
expect(await videoWatchPage.areCommentsEnabled()).toBeFalsy()
})
after(async function () { expect(await videoWatchPage.getPrivacy()).toBe('Unlisted')
expect(await videoWatchPage.getLicence()).toBe('Attribution - Non Commercial')
expect(await videoWatchPage.areCommentsEnabled()).toBeFalsy()
// Owners can download their videos
expect(await videoWatchPage.isDownloadEnabled()).toBeTruthy()
// Logout to see if the download enabled is correct for anonymous users
await loginPage.logout() await loginPage.logout()
await browser.url(videoUrl)
await videoWatchPage.waitWatchVideoName('video')
expect(await videoWatchPage.isDownloadEnabled()).toBeFalsy()
}) })
}) })

View File

@ -130,10 +130,12 @@ describe('Password protected videos', () => {
it('Should update the playlist to public', async () => { it('Should update the playlist to public', async () => {
const url = await browser.getUrl() const url = await browser.getUrl()
const regex = /\/([a-f0-9-]+)$/i const regex = /\/my-library\/video-playlists\/([^/]+)/i
const match = url.match(regex) const match = url.match(regex)
const uuid = match ? match[1] : null const uuid = match ? match[1] : null
expect(uuid).not.toBeNull()
await myAccountPage.updatePlaylistPrivacy(uuid, 'Public') await myAccountPage.updatePlaylistPrivacy(uuid, 'Public')
}) })

View File

@ -66,7 +66,7 @@ function buildConfig (suiteFile: string = undefined) {
publish: { publish: {
download_enabled: false, download_enabled: false,
comments_enabled: false, comments_enabled: false,
privacy: 4, privacy: 2,
licence: 4 licence: 4
}, },
p2p: { p2p: {

View File

@ -1,12 +1,14 @@
import { Routes } from '@angular/router' import { Routes } from '@angular/router'
import { AbuseService } from '@app/shared/shared-moderation/abuse.service'
import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service'
import { BulkService } from '@app/shared/shared-moderation/bulk.service'
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service'
import { UserAdminService } from '@app/shared/shared-users/user-admin.service'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
import { AccountVideoChannelsComponent } from './account-video-channels/account-video-channels.component' import { AccountVideoChannelsComponent } from './account-video-channels/account-video-channels.component'
import { AccountVideosComponent } from './account-videos/account-videos.component' import { AccountVideosComponent } from './account-videos/account-videos.component'
import { AccountsComponent } from './accounts.component' import { AccountsComponent } from './accounts.component'
import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service'
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
import { AbuseService } from '@app/shared/shared-moderation/abuse.service'
export default [ export default [
{ {
@ -21,7 +23,9 @@ export default [
BlocklistService, BlocklistService,
VideoPlaylistService, VideoPlaylistService,
VideoBlockService, VideoBlockService,
AbuseService AbuseService,
UserAdminService,
BulkService
], ],
children: [ children: [
{ {

View File

@ -1,85 +1,84 @@
<div *ngIf="error" class="alert alert-danger">{{ error }}</div> <div *ngIf="error" class="alert alert-danger">{{ error }}</div>
<div class="pt-two-cols"> <!-- playlist grid --> <div class="pt-two-cols"> <!-- playlist grid -->
<div class="title-col"> <div class="title-col">
<nav aria-label="breadcrumb"> <nav aria-label="breadcrumb">
<ol class="pt-breadcrumb"> <ol class="pt-breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a routerLink="/my-library/video-playlists" i18n>My Playlists</a> <a routerLink="/my-library/video-playlists" i18n>My Playlists</a>
</li>
@if (isCreation()) {
<li class="breadcrumb-item active" i18n>Create</li>
} @else {
<li class="breadcrumb-item active" i18n>Edit</li>
<li class="breadcrumb-item active" aria-current="page">
<a *ngIf="videoPlaylistToUpdate" [routerLink]="[ '/my-library/video-playlists/update', videoPlaylistToUpdate?.shortUUID]">
{{ videoPlaylistToUpdate?.displayName }}
</a>
</li> </li>
}
</ol>
</nav>
@if (isCreation()) { @if (isCreation()) {
<li class="breadcrumb-item active" i18n>Create</li> <h2 class="visually-hidden" i18n>NEW PLAYLIST</h2>
} @else { } @else {
<li class="breadcrumb-item active" i18n>Edit</li> <h2 class="visually-hidden" i18n>UPDATE PLAYLIST</h2>
}
<li class="breadcrumb-item active" aria-current="page">
<a *ngIf="videoPlaylistToUpdate" [routerLink]="[ '/my-library/video-playlists/update', videoPlaylistToUpdate?.shortUUID]">
{{ videoPlaylistToUpdate?.displayName }}
</a>
</li>
}
</ol>
</nav>
@if (isCreation()) {
<h2 class="visually-hidden" i18n>NEW PLAYLIST</h2>
} @else {
<h2 class="visually-hidden" i18n>UPDATE PLAYLIST</h2>
}
</div>
<div class="content-col">
<form role="form" (ngSubmit)="formValidated()" [formGroup]="form">
<div class="form-group">
<label for="thumbnailfile" i18n>Playlist thumbnail</label>
<my-preview-upload
i18n-inputLabel inputLabel="Edit" inputName="thumbnailfile" formControlName="thumbnailfile"
previewWidth="223px" previewHeight="122px"
></my-preview-upload>
</div>
<div class="form-group">
<label i18n for="displayName">Display name</label>
<input
type="text" id="displayName" class="form-control"
formControlName="displayName" [ngClass]="{ 'input-error': formErrors['displayName'] }"
>
<div *ngIf="formErrors['displayName']" class="form-error" role="alert">
{{ formErrors['displayName'] }}
</div>
</div>
<div class="form-group">
<label i18n for="description">Description</label><my-help helpType="markdownText"></my-help>
<my-markdown-textarea id="description" formControlName="description" [formError]="formErrors['description']"></my-markdown-textarea>
</div>
<div class="form-group">
<label i18n for="privacy">Privacy</label>
<div class="peertube-select-container">
<my-select-options
labelForId="privacy" [items]="videoPlaylistPrivacies" formControlName="privacy" [clearable]="false"
></my-select-options>
</div>
<div *ngIf="formErrors.privacy" class="form-error" role="alert">{{ formErrors.privacy }}</div>
</div>
<div class="form-group">
<label for="videoChannelIdl" i18n>Channel</label>
<my-select-channel
labelForId="videoChannelId" [items]="userVideoChannels" formControlName="videoChannelId"
></my-select-channel>
<div *ngIf="formErrors['videoChannelId']" class="form-error" role="alert">{{ formErrors['videoChannelId'] }}</div>
</div>
<input type="submit" class="peertube-button orange-button" value="{{ getFormButtonTitle() }}" [disabled]="!form.valid">
</form>
</div>
</div> </div>
<div class="content-col">
<form role="form" (ngSubmit)="formValidated()" [formGroup]="form">
<div class="form-group">
<label for="thumbnailfile" i18n>Playlist thumbnail</label>
<my-preview-upload
i18n-inputLabel inputLabel="Edit" inputName="thumbnailfile" formControlName="thumbnailfile"
previewWidth="223px" previewHeight="122px"
></my-preview-upload>
</div>
<div class="form-group">
<label i18n for="displayName">Display name</label>
<input
type="text" id="displayName" class="form-control"
formControlName="displayName" [ngClass]="{ 'input-error': formErrors['displayName'] }"
>
<div *ngIf="formErrors['displayName']" class="form-error" role="alert">
{{ formErrors['displayName'] }}
</div>
</div>
<div class="form-group">
<label i18n for="description">Description</label><my-help helpType="markdownText"></my-help>
<my-markdown-textarea id="description" formControlName="description" [formError]="formErrors['description']"></my-markdown-textarea>
</div>
<div class="form-group">
<label i18n for="privacy">Privacy</label>
<div class="peertube-select-container">
<my-select-options
labelForId="privacy" [items]="videoPlaylistPrivacies" formControlName="privacy" [clearable]="false"
></my-select-options>
</div>
<div *ngIf="formErrors.privacy" class="form-error" role="alert">{{ formErrors.privacy }}</div>
</div>
<div class="form-group">
<label for="videoChannelIdl" i18n>Channel</label>
<my-select-channel
labelForId="videoChannelId" [items]="userVideoChannels" formControlName="videoChannelId"
></my-select-channel>
<div *ngIf="formErrors['videoChannelId']" class="form-error" role="alert">{{ formErrors['videoChannelId'] }}</div>
</div>
<input type="submit" class="peertube-button orange-button" value="{{ getFormButtonTitle() }}" [disabled]="!form.valid">
</form>
</div>
</div>

View File

@ -1,15 +1,17 @@
import { Routes } from '@angular/router' import { Routes } from '@angular/router'
import { VideoWatchComponent } from './video-watch.component' import { AbuseService } from '@app/shared/shared-moderation/abuse.service'
import { OverviewService } from '../video-list'
import { RecentVideosRecommendationService, RecommendedVideosStore } from './shared'
import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service' import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service'
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service' import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
import { SearchService } from '@app/shared/shared-search/search.service' import { SearchService } from '@app/shared/shared-search/search.service'
import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service' import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service'
import { UserAdminService } from '@app/shared/shared-users/user-admin.service'
import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service' import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service'
import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service' import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service' import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
import { AbuseService } from '@app/shared/shared-moderation/abuse.service' import { OverviewService } from '../video-list'
import { RecentVideosRecommendationService, RecommendedVideosStore } from './shared'
import { VideoWatchComponent } from './video-watch.component'
import { BulkService } from '@app/shared/shared-moderation/bulk.service'
export default [ export default [
{ {
@ -25,7 +27,9 @@ export default [
RecentVideosRecommendationService, RecentVideosRecommendationService,
RecommendedVideosStore, RecommendedVideosStore,
SearchService, SearchService,
AbuseService AbuseService,
UserAdminService,
BulkService
], ],
children: [ children: [
{ {

View File

@ -398,6 +398,8 @@ class PeerTubePlugin extends Plugin {
private updatePlayerSizeClasses () { private updatePlayerSizeClasses () {
requestAnimationFrame(() => { requestAnimationFrame(() => {
if (!this.player) return
debugLogger('Updating player size classes') debugLogger('Updating player size classes')
const width = this.player.currentWidth() const width = this.player.currentWidth()