|
2 | 2 | * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors |
3 | 3 | * SPDX-License-Identifier: AGPL-3.0-or-later |
4 | 4 | */ |
5 | | -import { getNc, restoreState, runCommand, runOccCommand, saveState } from "./commands" |
6 | | -import { login, logout } from "./commands/sessions" |
7 | | -import { User, createRandomUser, createUser, deleteUser, modifyUser, listUsers, getUserData, enableUser } from "./commands/users" |
8 | | -import type { Selector } from "./selectors" |
9 | 5 |
|
10 | | -declare global { |
11 | | - namespace Cypress { |
12 | | - interface Chainable { |
13 | | - /** |
14 | | - * Get an element from the Nextcloud selector set. |
15 | | - * @example cy.getNc(FileList) |
16 | | - * cy.getNc(FileRow, { id: fileInfo.id }) |
17 | | - */ |
18 | | - getNc(selector: Selector, args?: Object): Cypress.Chainable<JQuery<HTMLElement>> |
19 | | - |
20 | | - /** |
21 | | - * Login on a Nextcloud instance |
22 | | - */ |
23 | | - login(user: User): void |
24 | | - |
25 | | - /** |
26 | | - * Logout from a Nextcloud instance |
27 | | - */ |
28 | | - logout(): void |
29 | | - |
30 | | - /** |
31 | | - * Create a random user on the Nextcloud instance |
32 | | - * |
33 | | - * **Warning**: Using this function will reset the previous session |
34 | | - */ |
35 | | - createRandomUser(): Cypress.Chainable<User> |
36 | | - |
37 | | - /** |
38 | | - * Create a user on the Nextcloud instance |
39 | | - * |
40 | | - * **Warning**: Using this function will reset the previous session |
41 | | - */ |
42 | | - createUser(user: User): Cypress.Chainable<Cypress.Response<any>> |
43 | | - |
44 | | - /** |
45 | | - * Delete a user on the Nextcloud instance |
46 | | - * |
47 | | - * **Warning**: Using this function will reset the previous session |
48 | | - */ |
49 | | - deleteUser(user: User): Cypress.Chainable<Cypress.Response<any>> |
50 | | - |
51 | | - /** |
52 | | - * Query list of users on the Nextcloud instance |
53 | | - * |
54 | | - * **Warning**: Using this function will reset the previous session |
55 | | - * |
56 | | - * @param details Set to true to fetch users with detailed information (default false) |
57 | | - * @return List of user IDs or list of Users (if details was set to true) |
58 | | - */ |
59 | | - listUsers<b extends boolean>(details?: b): Cypress.Chainable<b extends true ? Record<string, string>[] : string[]> |
60 | | - listUsers(details?: boolean): Cypress.Chainable<Record<string,string>[] | string[]> |
61 | | - |
62 | | - /** |
63 | | - * Modify an attribute of a given user on the Nextcloud instance |
64 | | - * |
65 | | - * @param user User who modifies their metadata |
66 | | - * @param key Attribute name |
67 | | - * @param value New attribute value |
68 | | - */ |
69 | | - modifyUser(user: User, key: string, value: any): Cypress.Chainable<Cypress.Response<any>> |
70 | | - |
71 | | - /** |
72 | | - * Enable or disable a given user |
73 | | - * |
74 | | - * @param user user whom to enable or disable |
75 | | - * @param enable True to enable, false to disable (default is enable) |
76 | | - */ |
77 | | - enableUser(user: User, enable?: boolean): Cypress.Chainable<Cypress.Response<any>> |
78 | | - |
79 | | - /** |
80 | | - * |
81 | | - * Query metadata for, and in behalf, of a given user |
82 | | - * |
83 | | - * @param user User whom metadata to query |
84 | | - */ |
85 | | - getUserData(user: User): Cypress.Chainable<Cypress.Response<any>> |
86 | | - |
87 | | - /** |
88 | | - * Create a snapshot of the current DB and data folder state. |
89 | | - * |
90 | | - * @return string the ID of the snapshot |
91 | | - */ |
92 | | - saveState(): Cypress.Chainable<string> |
93 | | - |
94 | | - /** |
95 | | - * Restore a snapshot of the database |
96 | | - * Default is the post-setup state |
97 | | - * |
98 | | - * @param snapshot string the ID of the snapshot |
99 | | - */ |
100 | | - restoreState(snapshot?: string): Cypress.Chainable<void> |
101 | | - |
102 | | - /** |
103 | | - * Run a command in the docker container |
104 | | - * |
105 | | - */ |
106 | | - runCommand(command: string, options?: Partial<Cypress.ExecOptions>): Cypress.Chainable<Cypress.Exec> |
107 | | - |
108 | | - /** |
109 | | - * Run an occ command |
110 | | - */ |
111 | | - runOccCommand(command: string, options?: Partial<Cypress.ExecOptions>): Cypress.Chainable<Cypress.Exec> |
112 | | - } |
113 | | - } |
114 | | -} |
115 | | - |
116 | | -/** |
117 | | - * Register all existing commands provided by this library |
118 | | - * |
119 | | - * You can also manually register those commands by importing them |
120 | | - * @example import { login } from '@nextcloud/e2e-test-server/commands' |
121 | | - * Cypress.Commands.add('login', login) |
122 | | - */ |
123 | | -export const addCommands = function() { |
124 | | - Cypress.Commands.add('getNc', getNc) |
125 | | - Cypress.Commands.add('login', login) |
126 | | - Cypress.Commands.add('logout', logout) |
127 | | - Cypress.Commands.add('createRandomUser', createRandomUser) |
128 | | - Cypress.Commands.add('createUser', createUser) |
129 | | - Cypress.Commands.add('deleteUser', deleteUser) |
130 | | - Cypress.Commands.add('listUsers', listUsers) |
131 | | - Cypress.Commands.add('modifyUser', modifyUser) |
132 | | - Cypress.Commands.add('enableUser', enableUser) |
133 | | - Cypress.Commands.add('getUserData', getUserData) |
134 | | - Cypress.Commands.add('saveState', saveState) |
135 | | - Cypress.Commands.add('restoreState', restoreState) |
136 | | - Cypress.Commands.add('runCommand', runCommand) |
137 | | - Cypress.Commands.add('runOccCommand', runOccCommand) |
138 | | -} |
139 | | - |
140 | | -export { User } |
| 6 | +export * from "./docker" |
| 7 | +export * from "./User" |
0 commit comments