|
| 1 | +import { test } from '@playwright/test' |
| 2 | +import { config } from '../../../e2e/config.js' |
| 3 | +import { |
| 4 | + ActorsEnvironment, |
| 5 | + UsersEnvironment, |
| 6 | + FilesEnvironment |
| 7 | +} from '../../../e2e/support/environment' |
| 8 | +import { setAccessAndRefreshToken } from '../../helpers/setAccessAndRefreshToken' |
| 9 | +import * as api from '../../steps/api/api' |
| 10 | +import * as ui from '../../steps/ui/index' |
| 11 | + |
| 12 | +test.describe('internal link share', () => { |
| 13 | + let actorsEnvironment |
| 14 | + const usersEnvironment = new UsersEnvironment() |
| 15 | + const filesEnvironment = new FilesEnvironment() |
| 16 | + |
| 17 | + test.beforeEach(async ({ browser }) => { |
| 18 | + actorsEnvironment = new ActorsEnvironment({ |
| 19 | + context: { |
| 20 | + acceptDownloads: config.acceptDownloads, |
| 21 | + reportDir: config.reportDir, |
| 22 | + tracingReportDir: config.tracingReportDir, |
| 23 | + reportHar: config.reportHar, |
| 24 | + reportTracing: config.reportTracing, |
| 25 | + reportVideo: config.reportVideo, |
| 26 | + failOnUncaughtConsoleError: config.failOnUncaughtConsoleError |
| 27 | + }, |
| 28 | + browser: browser |
| 29 | + }) |
| 30 | + |
| 31 | + await setAccessAndRefreshToken(usersEnvironment) |
| 32 | + |
| 33 | + // Given "Admin" creates following user using API |
| 34 | + // | id | |
| 35 | + // | Alice | |
| 36 | + await api.usersHasBeenCreated({ usersEnvironment, stepUser: 'Admin', users: ['Alice'] }) |
| 37 | + |
| 38 | + // And "Alice" logs in |
| 39 | + await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Alice' }) |
| 40 | + |
| 41 | + // And "Alice" opens the "files" app |
| 42 | + await ui.userOpensApplication({ actorsEnvironment, stepUser: 'Alice', name: 'files' }) |
| 43 | + }) |
| 44 | + |
| 45 | + test.afterEach(async () => { |
| 46 | + // clean up users |
| 47 | + await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Alice' }) |
| 48 | + }) |
| 49 | + |
| 50 | + test('Upload files in personal space', { tag: '@predefined-users' }, async () => { |
| 51 | + // Given "Alice" creates the following resources |
| 52 | + // | resource | type | content | |
| 53 | + // | new-lorem-big.txt | txtFile | new lorem big file | |
| 54 | + // | lorem.txt | txtFile | lorem file | |
| 55 | + // | textfile.txt | txtFile | some random content | |
| 56 | + await ui.userCreatesResources({ |
| 57 | + actorsEnvironment, |
| 58 | + stepUser: 'Alice', |
| 59 | + resources: [{ name: 'new-lorem-big.txt', type: 'txtFile', content: 'new lorem big file' }] |
| 60 | + }) |
| 61 | + await ui.userCreatesResources({ |
| 62 | + actorsEnvironment, |
| 63 | + stepUser: 'Alice', |
| 64 | + resources: [{ name: 'lorem.txt', type: 'txtFile', content: 'lorem file' }] |
| 65 | + }) |
| 66 | + await ui.userCreatesResources({ |
| 67 | + actorsEnvironment, |
| 68 | + stepUser: 'Alice', |
| 69 | + resources: [{ name: 'textfile.txt', type: 'txtFile', content: 'some random content' }] |
| 70 | + }) |
| 71 | + // # Coverage for bug: https://github.com/owncloud/ocis/issues/8361 |
| 72 | + // | comma,.txt | txtFile | comma | |
| 73 | + await ui.userCreatesResources({ |
| 74 | + actorsEnvironment, |
| 75 | + stepUser: 'Alice', |
| 76 | + resources: [{ name: 'comma,.txt', type: 'txtFile', content: 'comma' }] |
| 77 | + }) |
| 78 | + // # Coverage for bug: https://github.com/owncloud/web/issues/10810 |
| 79 | + // | test#file.txt | txtFile | some content | |
| 80 | + // | test#folder | folder | | |
| 81 | + await ui.userCreatesResources({ |
| 82 | + actorsEnvironment, |
| 83 | + stepUser: 'Alice', |
| 84 | + resources: [{ name: 'test#file.txt', type: 'txtFile', content: 'some content' }] |
| 85 | + }) |
| 86 | + await ui.userCreatesResources({ |
| 87 | + actorsEnvironment, |
| 88 | + stepUser: 'Alice', |
| 89 | + resources: [{ name: 'test#folder', type: 'folder' }] |
| 90 | + }) |
| 91 | + // When "Alice" uploads the following resources |
| 92 | + // | resource | option | |
| 93 | + // | new-lorem-big.txt | replace | |
| 94 | + // | lorem.txt | skip | |
| 95 | + // | textfile.txt | keep both | |
| 96 | + await ui.uploadResource({ |
| 97 | + actorsEnvironment, |
| 98 | + filesEnvironment, |
| 99 | + stepUser: 'Alice', |
| 100 | + resources: [{ name: 'new-lorem-big.txt', option: 'replace' }] |
| 101 | + }) |
| 102 | + await ui.uploadResource({ |
| 103 | + actorsEnvironment, |
| 104 | + filesEnvironment, |
| 105 | + stepUser: 'Alice', |
| 106 | + resources: [{ name: 'lorem.txt', option: 'skip' }] |
| 107 | + }) |
| 108 | + await ui.uploadResource({ |
| 109 | + actorsEnvironment, |
| 110 | + filesEnvironment, |
| 111 | + stepUser: 'Alice', |
| 112 | + resources: [{ name: 'textfile.txt', option: 'keep both' }] |
| 113 | + }) |
| 114 | + // And "Alice" creates the following resources |
| 115 | + // | resource | type | content | |
| 116 | + // | PARENT/parent.txt | txtFile | some text | |
| 117 | + // | PARENT/example.txt | txtFile | example text | |
| 118 | + await ui.userCreatesResources({ |
| 119 | + actorsEnvironment, |
| 120 | + stepUser: 'Alice', |
| 121 | + resources: [{ name: 'PARENT/parent.txt', type: 'txtFile', content: 'some text' }] |
| 122 | + }) |
| 123 | + await ui.userCreatesResources({ |
| 124 | + actorsEnvironment, |
| 125 | + stepUser: 'Alice', |
| 126 | + resources: [{ name: 'PARENT/example.txt', type: 'txtFile', content: 'example text' }] |
| 127 | + }) |
| 128 | + // And "Alice" uploads the following resources via drag-n-drop |
| 129 | + // | resource | |
| 130 | + // | simple.pdf | |
| 131 | + // | testavatar.jpg | |
| 132 | + await ui.userUploadsResourceViaDragNDrop({ |
| 133 | + actorsEnvironment, |
| 134 | + filesEnvironment, |
| 135 | + stepUser: 'Alice', |
| 136 | + resource: 'simple.pdf' |
| 137 | + }) |
| 138 | + await ui.userUploadsResourceViaDragNDrop({ |
| 139 | + actorsEnvironment, |
| 140 | + filesEnvironment, |
| 141 | + stepUser: 'Alice', |
| 142 | + resource: 'testavatar.jpg' |
| 143 | + }) |
| 144 | + // And "Alice" downloads the following resources using the sidebar panel |
| 145 | + // | resource | type | |
| 146 | + // | PARENT | folder | |
| 147 | + // # Coverage for bug: https://github.com/owncloud/ocis/issues/8361 |
| 148 | + // | comma,.txt | file | |
| 149 | + // # Coverage for bug: https://github.com/owncloud/web/issues/10810 |
| 150 | + // | test#file.txt | file | |
| 151 | + // | test#folder | folder | |
| 152 | + await ui.userDownloadsResource({ |
| 153 | + actorsEnvironment, |
| 154 | + stepUser: 'Alice', |
| 155 | + resourceToDownload: [ |
| 156 | + { resource: 'PARENT', type: 'folder' }, |
| 157 | + { resource: 'comma,.txt', type: 'file' }, |
| 158 | + { resource: 'test#file.txt', type: 'file' }, |
| 159 | + { resource: 'test#folder', type: 'folder' } |
| 160 | + ], |
| 161 | + actionType: 'SIDEBAR_PANEL' |
| 162 | + }) |
| 163 | + // And "Alice" logs out |
| 164 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' }) |
| 165 | + }) |
| 166 | + test('upload multiple small files', { tag: '@predefined-users' }, async () => { |
| 167 | + // When "Alice" uploads 50 small files in personal space |
| 168 | + await ui.userUploadsMultipleFilesInPersonalSpace({ |
| 169 | + actorsEnvironment, |
| 170 | + filesEnvironment, |
| 171 | + stepUser: 'Alice', |
| 172 | + numberOfFiles: 50 |
| 173 | + }) |
| 174 | + // Then "Alice" should see 50 resources in the personal space files view |
| 175 | + await ui.assertToHaveNoOfFiles({ |
| 176 | + actorsEnvironment, |
| 177 | + stepUser: 'Alice', |
| 178 | + expectedNumberOfResources: 50 |
| 179 | + }) |
| 180 | + // And "Alice" logs out |
| 181 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' }) |
| 182 | + }) |
| 183 | + test('upload folder', async () => { |
| 184 | + // When "Alice" uploads the following resources |
| 185 | + // | resource | type | |
| 186 | + // | PARENT | folder | |
| 187 | + await ui.uploadResource({ |
| 188 | + actorsEnvironment, |
| 189 | + filesEnvironment, |
| 190 | + stepUser: 'Alice', |
| 191 | + resources: [{ name: 'PARENT', type: 'folder' }] |
| 192 | + }) |
| 193 | + // check that folder content exist |
| 194 | + // And "Alice" opens folder "PARENT" |
| 195 | + await ui.userOpensResources({ |
| 196 | + actorsEnvironment, |
| 197 | + stepUser: 'Alice', |
| 198 | + resource: 'PARENT' |
| 199 | + }) |
| 200 | + // And "Alice" opens the following file in pdfviewer |
| 201 | + // | resource | |
| 202 | + // | simple.pdf | |
| 203 | + await ui.openResourceInViewer({ |
| 204 | + actorsEnvironment, |
| 205 | + stepUser: 'Alice', |
| 206 | + resource: 'simple.pdf', |
| 207 | + application: 'pdfviewer' |
| 208 | + }) |
| 209 | + // Then "Alice" closes the file viewer |
| 210 | + await ui.userClosesFileViewer({ actorsEnvironment, stepUser: 'Alice' }) |
| 211 | + // upload a folder via drag-n-drop |
| 212 | + // When "Alice" uploads the following resources via drag-n-drop |
| 213 | + // | resource | |
| 214 | + // | Folder,With,Comma | |
| 215 | + await ui.userUploadsResourceViaDragNDrop({ |
| 216 | + actorsEnvironment, |
| 217 | + filesEnvironment, |
| 218 | + stepUser: 'Alice', |
| 219 | + resource: 'Folder,With,Comma' |
| 220 | + }) |
| 221 | + // And "Alice" opens folder "Folder,With,Comma" |
| 222 | + await ui.userOpensResources({ |
| 223 | + actorsEnvironment, |
| 224 | + stepUser: 'Alice', |
| 225 | + resource: 'Folder,With,Comma' |
| 226 | + }) |
| 227 | + // Then following resources should be displayed in the files list for user "Alice" |
| 228 | + // | resource | |
| 229 | + // | sunday,monday.txt | |
| 230 | + await ui.userShouldSeeTheResources({ |
| 231 | + actorsEnvironment, |
| 232 | + listType: 'files list', |
| 233 | + stepUser: 'Alice', |
| 234 | + resources: ['sunday,monday.txt'] |
| 235 | + }) |
| 236 | + // And "Alice" opens the "files" app |
| 237 | + await ui.userOpensApplication({ actorsEnvironment, stepUser: 'Alice', name: 'files' }) |
| 238 | + // upload empty folder |
| 239 | + // When "Alice" uploads the following resources |
| 240 | + // | resource | type | |
| 241 | + // | FOLDER | folder | |
| 242 | + await ui.uploadResource({ |
| 243 | + actorsEnvironment, |
| 244 | + filesEnvironment, |
| 245 | + stepUser: 'Alice', |
| 246 | + resources: [{ name: 'FOLDER', type: 'folder' }] |
| 247 | + }) |
| 248 | + await ui.userShouldSeeTheResources({ |
| 249 | + actorsEnvironment, |
| 250 | + listType: 'files list', |
| 251 | + stepUser: 'Alice', |
| 252 | + resources: ['FOLDER'] |
| 253 | + }) |
| 254 | + // And "Alice" logs out |
| 255 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' }) |
| 256 | + }) |
| 257 | + test('Upload large file when insufficient quota', async () => { |
| 258 | + // Given "Admin" logs in |
| 259 | + await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Admin' }) |
| 260 | + // And "Admin" opens the "admin-settings" app |
| 261 | + await ui.userOpensApplication({ actorsEnvironment, stepUser: 'Admin', name: 'admin-settings' }) |
| 262 | + // And "Admin" navigates to the users management page |
| 263 | + await ui.userNavigatesToUserManagementPage({ actorsEnvironment, stepUser: 'Admin' }) |
| 264 | + // And "Admin" changes the quota of the user "Alice" to "0.00001" using the sidebar panel |
| 265 | + await ui.userChangesUserQuota({ |
| 266 | + actorsEnvironment, |
| 267 | + stepUser: 'Admin', |
| 268 | + key: 'Alice', |
| 269 | + value: '0.00001' |
| 270 | + }) |
| 271 | + // And "Admin" logs out |
| 272 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Admin' }) |
| 273 | + // And "Alice" uploads the following resource |
| 274 | + // | resource | |
| 275 | + // | simple.pdf | |
| 276 | + await ui.uploadResource({ |
| 277 | + actorsEnvironment, |
| 278 | + filesEnvironment, |
| 279 | + stepUser: 'Alice', |
| 280 | + resources: [{ name: 'simple.pdf', to: '' }] |
| 281 | + }) |
| 282 | + // When "Alice" tries to upload the following resource |
| 283 | + // | resource | error | |
| 284 | + // | lorem-big.txt | Insufficient quota | |
| 285 | + await ui.userTriesToUploadResource({ |
| 286 | + actorsEnvironment, |
| 287 | + filesEnvironment, |
| 288 | + stepUser: 'Alice', |
| 289 | + resource: 'lorem-big.txt', |
| 290 | + error: 'Insufficient quota', |
| 291 | + to: '' |
| 292 | + }) |
| 293 | + // And "Alice" logs out |
| 294 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' }) |
| 295 | + }) |
| 296 | +}) |
0 commit comments