-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathAssistant.spec.js
More file actions
116 lines (92 loc) 路 2.69 KB
/
Copy pathAssistant.spec.js
File metadata and controls
116 lines (92 loc) 路 2.69 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { initUserAndFiles, randUser } from '../utils/index.js'
const currentUser = randUser()
const fileName = 'empty.md'
describe('Assistant', () => {
before(() => {
initUserAndFiles(currentUser, fileName)
})
beforeEach(() => {
cy.login(currentUser)
cy.visit('/apps/files')
})
it('See assistant button', () => {
cy.isolateTest({
sourceFile: fileName,
})
cy.openFile(fileName, { force: true })
cy.getContent()
.click({ force: true })
cy.get('[data-cy="assistantMenu"]')
.should('be.visible')
cy.get('[data-cy="assistantMenu"]')
.click()
cy.get('.action-item__popper ul').children().should(($children) => {
const entries = $children.find('button').map((i, el) => el.innerText).get()
expect(entries.length).to.be.greaterThan(0)
expect('Free text to text prompt').to.be.oneOf(entries)
expect('Translate').to.be.oneOf(entries)
expect('Show assistant results').to.be.oneOf(entries)
})
})
it('Send free prompt request', () => {
cy.isolateTest({
sourceFile: fileName,
})
cy.openFile(fileName, { force: true })
cy.getContent()
.click({ force: true })
cy.get('[data-cy="assistantMenu"]')
.click()
cy.get('.action-item__popper li')
.contains('Free text to text prompt')
.click()
cy.get('.assistant-modal--content #input-input')
.should('be.visible')
cy.get('.assistant-modal--content #input-input')
.type('Hello World')
cy.get('.assistant-modal--content .submit-button')
.click()
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000)
cy.get('.assistant-modal--content button')
.contains('Get notified')
.click()
cy.get('.assistant-modal--content button .bell-ring-outline-icon')
.should('be.visible')
cy.get('.assistant-modal--content .close-button')
.click()
cy.get('[data-cy="assistantMenu"]')
.click()
cy.get('.action-item__popper ul li').last()
.click()
cy.get('.modal-container__content .task-list')
.should('be.visible')
.should('contain', 'Hello World')
})
it('Open translate dialog', () => {
cy.isolateTest({
sourceFile: fileName,
})
cy.openFile(fileName, { force: true })
cy.getContent()
.click({ force: true })
cy.get('[data-cy="assistantMenu"]')
.click()
cy.get('[data-cy="open-translate"]')
.should('be.visible')
.click()
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000)
cy.get('[data-cy="translate-input"]')
.should('be.visible')
.focus()
cy.get('[data-cy="translate-input"]')
.should('be.focused')
cy.get('[data-cy="translate-input"]')
.type('Hello World')
})
})