Welcome to mirror list, hosted at ThFree Co, Russian Federation.

links.spec.js « integration « cypress - github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cff108668eb8ed01a922418de38045e20a961c3b (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
import { randHash } from '../utils/'

const randUser = randHash()
const fileName = 'empty.md'

const getEditor = () => cy.get('#viewer #editor .ProseMirror')

const clearContent = () => getEditor()
	.type('{selectall}')
	.type('{enter}')

describe('test link marks', function() {
	before(function() {
		// Init user
		cy.nextcloudCreateUser(randUser, 'password')
		cy.login(randUser, 'password')

		// Upload test files
		cy.uploadFile('test.md', 'text/markdown')
		cy.uploadFile(fileName, 'text/markdown')
	})

	beforeEach(function() {
		cy.login(randUser, 'password', {
			onBeforeLoad(win) {
				cy.stub(win, 'open')
					.as('winOpen')

			},
		})

		cy.openFile(fileName)
	})

	describe('autolink', function() {
		beforeEach(clearContent)
		it('with protocol', () => {
			cy.getFile('test.md')
				.then($el => {
					const id = $el.data('id')

					const link = `${Cypress.env('baseUrl')}/file-name?fileId=${id}`
					getEditor()
						.type(link)

					getEditor()
						.get(`a[href*="${Cypress.env('baseUrl')}`)
						.click({ force: true })

					cy.get('@winOpen')
						.should('have.been.calledOnce')
						.should('have.been.calledWithMatch', new RegExp(`/f/${id}$`))
				})
		})

		it('whithout protocol', () => {
			getEditor()
				.type('google.com')

			getEditor()
				.get('a[href*="google.com"]')
				.click({ force: true })

			cy.get('@winOpen')
				.should('have.been.calledOnce')
				.should('have.been.calledWith', 'http://google.com/')
		})
	})
})