aboutsummaryrefslogtreecommitdiffstats
path: root/documentation/advanced/advanced-javascript.asciidoc
Commit message (Collapse)AuthorAgeFilesLines
* Update broken docs syntax in github (#11596)Zhe Sun2019-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add delay to the unstable test * Add delay for unstable tests * Update broken docs syntax in github * Merge branch 'master' into ZheSun88-patch-1 * Update doc reference syntax * Merge branch 'ZheSun88-patch-1' of github.com:vaadin/framework into ZheSun88-patch-1 # Conflicts: # documentation/components/components-overview.asciidoc * Merge branch 'master' into ZheSun88-patch-1 * use .asciidoc * Merge remote-tracking branch 'origin/ZheSun88-patch-1' into ZheSun88-patch-1 * use .asciidoc * Merge branch 'master' into ZheSun88-patch-1
* Fixed a broken commentSimo-Pekka Koskinen2016-08-291-2/+2
| | | | | | Fixed broken comment on 'Calling Javascript' -paragraph. Change-Id: I5098f21006f00eab48ce5cd55e3bb14bee040fbf
* Add documentation to master branchMarkus Koivisto2016-01-221-0/+109
| | | | Change-Id: I2504bb10f1ae73ec0cbc08b7ba5a88925caa1674
* Revert "Merge branch 'documentation'"7.6.0.beta2Ilia Motornyi2015-12-031-109/+0
| | | | | | This reverts commit f6874bde3d945c8b2d1b5c17ab50e2d0f1f8ff00. Change-Id: I67ee1c30ba3e3bcc3c43a1dd2e73a822791514bf
* Framework documentation INelmot2015-09-251-0/+109
Change-Id: I767477c1fc3745f9e1f58075fe30c9ac8da63581
> Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/e2e/files_versions/filesVersionsUtils.ts
blob: 75c76b7e97c2f41a00b165a668d1a05bc2d573e2 (plain)
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
/**
 * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
/* eslint-disable jsdoc/require-jsdoc */
import type { User } from '@nextcloud/cypress'
import { createShare, type ShareSetting } from '../files_sharing/FilesSharingUtils'

export const uploadThreeVersions = (user: User, fileName: string) => {
	// A new version will not be created if the changes occur
	// within less than one second of each other.
	// eslint-disable-next-line cypress/no-unnecessary-waiting
	cy.uploadContent(user, new Blob(['v1'], { type: 'text/plain' }), 'text/plain', `/${fileName}`)
		.wait(1100)
		.uploadContent(user, new Blob(['v2'], { type: 'text/plain' }), 'text/plain', `/${fileName}`)
		.wait(1100)
		.uploadContent(user, new Blob(['v3'], { type: 'text/plain' }), 'text/plain', `/${fileName}`)
	cy.login(user)
}

export function openVersionsPanel(fileName: string) {
	// Detect the versions list fetch
	cy.intercept('PROPFIND', '**/dav/versions/*/versions/**').as('getVersions')

	// Open the versions tab
	cy.window().then(win => {
		win.OCA.Files.Sidebar.setActiveTab('version_vue')
		win.OCA.Files.Sidebar.open(`/${fileName}`)
	})

	// Wait for the versions list to be fetched
	cy.wait('@getVersions')
	cy.get('#tab-version_vue').should('be.visible', { timeout: 10000 })
}

export function toggleVersionMenu(index: number) {
	cy.get('#tab-version_vue [data-files-versions-version]')
		.eq(index)
		.find('button')
		.click()
}

export function triggerVersionAction(index: number, actionName: string) {
	toggleVersionMenu(index)
	cy.get(`[data-cy-files-versions-version-action="${actionName}"]`).filter(':visible').click()
}

export function nameVersion(index: number, name: string) {
	cy.intercept('PROPPATCH', '**/dav/versions/*/versions/**').as('labelVersion')
	triggerVersionAction(index, 'label')
	cy.get(':focused').type(`${name}{enter}`)
	cy.wait('@labelVersion')
}

export function restoreVersion(index: number) {
	cy.intercept('MOVE', '**/dav/versions/*/versions/**').as('restoreVersion')
	triggerVersionAction(index, 'restore')
	cy.wait('@restoreVersion')
}

export function deleteVersion(index: number) {
	cy.intercept('DELETE', '**/dav/versions/*/versions/**').as('deleteVersion')
	triggerVersionAction(index, 'delete')
	cy.wait('@deleteVersion')
}

export function doesNotHaveAction(index: number, actionName: string) {
	toggleVersionMenu(index)
	cy.get(`[data-cy-files-versions-version-action="${actionName}"]`).should('not.exist')
	toggleVersionMenu(index)
}

export function assertVersionContent(index: number, expectedContent: string) {
	cy.intercept({ method: 'GET', times: 1, url: 'remote.php/**' }).as('downloadVersion')
	triggerVersionAction(index, 'download')
	cy.wait('@downloadVersion')
		.then(({ response }) => expect(response?.body).to.equal(expectedContent))
}

export function setupTestSharedFileFromUser(owner: User, randomFileName: string, shareOptions: Partial<ShareSetting>) {
	return cy.createRandomUser()
		.then((recipient) => {
			cy.login(owner)
			cy.visit('/apps/files')
			createShare(randomFileName, recipient.userId, shareOptions)
			cy.login(recipient)
			cy.visit('/apps/files')
			return cy.wrap(recipient)
		})
}