@open-xchange/appsuite-codeceptjs 0.6.15 → 0.6.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(find:*)",
5
+ "Bash(grep:*)",
6
+ "Bash(npm view:*)"
7
+ ]
8
+ }
9
+ }
@@ -1 +1 @@
1
- FROM registry.gitlab.com/openxchange/appsuite/web-foundation/base-images/playwright:v1.57.0-noble
1
+ FROM registry.gitlab.com/openxchange/appsuite/web-foundation/base-images/playwright:v1.58.2-noble
package/index.js CHANGED
@@ -36,6 +36,7 @@ requiredEnvVars.forEach(function notdefined (key) {
36
36
  module.exports = {
37
37
  util: require('./src/util'),
38
38
  event: require('./src/event'),
39
+ actor: require('./src/actor'),
39
40
  codeceptEvents,
40
41
  recorder,
41
42
  config: {
@@ -117,8 +118,8 @@ module.exports = {
117
118
  await ctx.remove().catch(e => console.error(e.message))
118
119
  }
119
120
  },
120
- reporter: 'mocha-multi',
121
121
  mocha: {
122
+ reporter: 'mocha-multi',
122
123
  reporterOptions: {
123
124
  'codeceptjs-cli-reporter': {
124
125
  stdout: '-'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/appsuite-codeceptjs",
3
- "version": "0.6.15",
3
+ "version": "0.6.17",
4
4
  "description": "OX App Suite CodeceptJS Configuration and Helpers",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -18,12 +18,12 @@
18
18
  "@codeceptjs/helper": "^2.0.4",
19
19
  "@influxdata/influxdb-client": "^1.35.0",
20
20
  "@open-xchange/appsuite-codeceptjs-pageobjects": "^1.1.0",
21
- "@playwright/test": "1.57.0",
21
+ "@playwright/test": "1.58.2",
22
22
  "allure-codeceptjs": "2.15.1",
23
23
  "chai": "^6.2.1",
24
24
  "chalk": "^4.1.2",
25
25
  "chalk-table": "^1.0.2",
26
- "codeceptjs": "3.7.5",
26
+ "codeceptjs": "3.7.6",
27
27
  "dotenv": "^17.2.3",
28
28
  "mocha": "^11.7.5",
29
29
  "mocha-junit-reporter": "^2.2.1",
@@ -31,10 +31,10 @@
31
31
  "moment": "^2.30.1",
32
32
  "moment-timezone": "^0.6.0",
33
33
  "p-retry": "^7.1.1",
34
- "playwright-core": "1.57.0",
34
+ "playwright-core": "1.58.2",
35
35
  "short-uuid": "^6.0.3",
36
36
  "@open-xchange/codecept-horizontal-scaler": "0.1.14",
37
- "@open-xchange/soap-client": "0.0.9"
37
+ "@open-xchange/soap-client": "0.0.10"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^24.10.3",
package/src/actor.js CHANGED
@@ -23,9 +23,9 @@ const { expect } = require('@playwright/test')
23
23
  const util = require('./util')
24
24
  const codecept = require('codeceptjs')
25
25
 
26
- const baseURL = util.getURLRoot()
26
+ module.exports = function (customSteps) {
27
+ const baseURL = util.getURLRoot()
27
28
 
28
- module.exports = function () {
29
29
  return actor({
30
30
 
31
31
  amOnLoginPage () {
@@ -74,9 +74,7 @@ module.exports = function () {
74
74
  }
75
75
  urlParams = [].concat(urlParams || [])
76
76
  options = Object.assign({ wait: true }, options)
77
- let user = options.user || require('codeceptjs').container.support('users')[0]
78
-
79
- if (typeof user === 'undefined') user = {}
77
+ let user = util.resolveUser(options.user)
80
78
  if (user.toJSON) user = user.toJSON()
81
79
  const loginName = process.env.PROVISIONING_API === 'reseller' ? user.name : `${user.name}${user.context.id ? '@' + user.context.id : ''}`
82
80
  await this.makeApiRequest('POST', `${baseURL}/api/login`, {
@@ -169,6 +167,8 @@ module.exports = function () {
169
167
  selectLine () {
170
168
  const shortcut = platform === 'darwin' ? ['Shift', 'CommandOrControl', 'ArrowLeft'] : ['Shift', 'Home']
171
169
  this.pressKey(shortcut)
172
- }
170
+ },
171
+
172
+ ...customSteps
173
173
  })
174
174
  }
@@ -20,6 +20,7 @@
20
20
 
21
21
  const codecept = require('codeceptjs')
22
22
  const querystring = require('node:querystring')
23
+ const util = require('./util')
23
24
 
24
25
  const pRetry = import('p-retry').then(module => module.default)
25
26
 
@@ -58,8 +59,7 @@ async function fetchWithRetry (url, options) {
58
59
  }
59
60
 
60
61
  function createHttpClient (options) {
61
- options = options || {}
62
- let user = options.user || codecept.container.support('users')[0]
62
+ let user = util.resolveUser(options?.user)
63
63
  if (user.toJSON) user = user.toJSON()
64
64
 
65
65
  async function request (url, options = {}) {
package/src/chai.js CHANGED
@@ -18,38 +18,38 @@
18
18
  * Any use of the work other than as authorized under this license or copyright law is prohibited.
19
19
  */
20
20
 
21
- import('chai').then(chai => {
22
- chai.util.addProperty(chai.Assertion.prototype, 'accessible', function () {
23
- const problems = ['\n', 'Accessibility Violations (' + this._obj.violations.length + ')', '---']
24
- const pad = '\n '
25
- if (this._obj.violations.length) {
26
- for (const violation of this._obj.violations) {
27
- problems.push(pad + '[' + violation.impact.toUpperCase() + '] ' + violation.help + ' (ID: ' + violation.id + ')\n')
28
- for (const node of violation.nodes) {
29
- problems.push(node.failureSummary.split('\n').join(pad))
30
- problems.push(' ' + node.target + ' => ' + node.html)
31
- const relatedNodes = []
32
- for (const combinedNodes of [node.all, node.any, node.none]) {
33
- if (combinedNodes.length > 0) {
34
- for (const any of combinedNodes) {
35
- for (const relatedNode of any.relatedNodes) {
36
- relatedNodes.push(' ' + relatedNode.target + ' => ' + relatedNode.html)
37
- }
21
+ const chai = require('chai')
22
+
23
+ chai.util.addProperty(chai.Assertion.prototype, 'accessible', function () {
24
+ const problems = ['\n', 'Accessibility Violations (' + this._obj.violations.length + ')', '---']
25
+ const pad = '\n '
26
+ if (this._obj.violations.length) {
27
+ for (const violation of this._obj.violations) {
28
+ problems.push(pad + '[' + violation.impact.toUpperCase() + '] ' + violation.help + ' (ID: ' + violation.id + ')\n')
29
+ for (const node of violation.nodes) {
30
+ problems.push(node.failureSummary.split('\n').join(pad))
31
+ problems.push(' ' + node.target + ' => ' + node.html)
32
+ const relatedNodes = []
33
+ for (const combinedNodes of [node.all, node.any, node.none]) {
34
+ if (combinedNodes.length > 0) {
35
+ for (const any of combinedNodes) {
36
+ for (const relatedNode of any.relatedNodes) {
37
+ relatedNodes.push(' ' + relatedNode.target + ' => ' + relatedNode.html)
38
38
  }
39
39
  }
40
40
  }
41
- if (relatedNodes.length > 0) problems.push(relatedNodes.join(pad))
42
41
  }
43
- problems.push(pad + '---\n')
42
+ if (relatedNodes.length > 0) problems.push(relatedNodes.join(pad))
44
43
  }
44
+ problems.push(pad + '---\n')
45
45
  }
46
- this.assert(
47
- this._obj.violations.length === 0,
48
- `expected to have no violations:\n ${problems.join(pad)}`,
49
- 'expected to have violations'
50
- )
51
- })
52
-
53
- globalThis.expect = chai.expect
54
- globalThis.assert = chai.assert
46
+ }
47
+ this.assert(
48
+ this._obj.violations.length === 0,
49
+ `expected to have no violations:\n ${problems.join(pad)}`,
50
+ 'expected to have violations'
51
+ )
55
52
  })
53
+
54
+ globalThis.expect = chai.expect
55
+ globalThis.assert = chai.assert
@@ -26,12 +26,6 @@ const { contextService, getFilestorageId } = require('@open-xchange/soap-client/
26
26
  const crypto = require('node:crypto')
27
27
  const codecept = require('codeceptjs')
28
28
 
29
- let defaultContext
30
- ;(async () => {
31
- console.log('Fetching default context')
32
- defaultContext = await contextService.getDefault()
33
- })()
34
-
35
29
  class Context {
36
30
  constructor ({ ctxdata, admin, auth }) {
37
31
  this.id = ctxdata.id
@@ -47,8 +41,12 @@ class Context {
47
41
  }
48
42
 
49
43
  async remove () {
50
- // do not remove default context
51
- if (defaultContext !== undefined && this.ctxdata.id === defaultContext.id) throw new Error('Cannot remove default context')
44
+ // Only allow deletion of e2e-created contexts
45
+ const loginMappings = [].concat(this.ctxdata.loginMappings || [])
46
+ const isE2eContext = loginMappings.some(m => m.startsWith('e2e-context-'))
47
+ if (!isE2eContext) {
48
+ throw new Error(`Refusing to delete context ${this.id}: not an e2e-created context (missing e2e-context- prefix in loginMappings)`)
49
+ }
52
50
  try {
53
51
  await contextService.remove(this.ctxdata.id)
54
52
  } catch (e) {
package/src/helper.js CHANGED
@@ -34,6 +34,14 @@ const javascriptRoot = util.getJavascriptRoot()
34
34
 
35
35
  const output = require('codeceptjs/lib/output')
36
36
 
37
+ /**
38
+ * @typedef UserOptions
39
+ * Optional parameters to specify a target user account.
40
+ * @property {object} [user]
41
+ * The user account to be used. If omitted, the first created user (`users[0]`)
42
+ * will be used.
43
+ */
44
+
37
45
  function delay (ms) { return new Promise(resolve => setTimeout(resolve, ms)) }
38
46
 
39
47
  async function retryPromise (fn, timeout = 5, retryDelay = 300) {
@@ -295,6 +303,97 @@ class AppSuiteHelper extends Helper {
295
303
  await devTools.send('Network.emulateNetworkConditions', presets[networkConfig.toUpperCase()] || networkConfig)
296
304
  }
297
305
 
306
+ /**
307
+ * Changes a configuration item of a user account during a test.
308
+ *
309
+ * Use this method inside test scenarios instead of calling `await
310
+ * user.hasConfig()` directly to make this call part of the recorder queue,
311
+ * instead of executing it immediately during test step registration.
312
+ *
313
+ * @param {string} key
314
+ * The configuration key.
315
+ *
316
+ * @param {unknown} value
317
+ * The new configuration value.
318
+ *
319
+ * @param {UserOptions} [options]
320
+ * Optional parameters.
321
+ */
322
+ async haveConfig (key, value, options) {
323
+ await util.resolveUser(options?.user).hasConfig(key, value)
324
+ }
325
+
326
+ /**
327
+ * Adds a capability to a user account during a test.
328
+ *
329
+ * Use this method inside test scenarios instead of calling `await
330
+ * user.hasCapability()` directly to make this call part of the recorder
331
+ * queue, instead of executing it immediately during test step registration.
332
+ *
333
+ * @param {string} capability
334
+ * The capability to be added to the user account.
335
+ *
336
+ * @param {UserOptions} [options]
337
+ * Optional parameters.
338
+ */
339
+ async haveCapability (capability, options) {
340
+ await util.resolveUser(options?.user).hasCapability(capability)
341
+ }
342
+
343
+ /**
344
+ * Removes a capability from a user account during a test.
345
+ *
346
+ * Use this method inside test scenarios instead of calling `await
347
+ * user.doesntHaveCapability()` directly to make this call part of the
348
+ * recorder queue, instead of executing it immediately during test step
349
+ * registration.
350
+ *
351
+ * @param {string} capability
352
+ * The capability to be removed from the user account.
353
+ *
354
+ * @param {UserOptions} [options]
355
+ * Optional parameters.
356
+ */
357
+ async dontHaveCapability (capability, options) {
358
+ await util.resolveUser(options?.user).doesntHaveCapability(capability)
359
+ }
360
+
361
+ /**
362
+ * Changes the access combination of a user account during a test.
363
+ *
364
+ * Use this method inside test scenarios instead of calling `await
365
+ * user.hasAccessCombination()` directly to make this call part of the
366
+ * recorder queue, instead of executing it immediately during test step
367
+ * registration.
368
+ *
369
+ * @param {string} accessCombination
370
+ * The access combination to be set at the user account.
371
+ *
372
+ * @param {UserOptions} [options]
373
+ * Optional parameters.
374
+ */
375
+ async haveAccessCombination (accessCombination, options) {
376
+ await util.resolveUser(options?.user).hasAccessCombination(accessCombination)
377
+ }
378
+
379
+ /**
380
+ * Changes the module access flags of a user account during a test.
381
+ *
382
+ * Use this method inside test scenarios instead of calling `await
383
+ * user.hasAccessCombination()` directly to make this call part of the
384
+ * recorder queue, instead of executing it immediately during test step
385
+ * registration.
386
+ *
387
+ * @param {Record<string, boolean>} moduleAccess
388
+ * The module access flags to be set at the user account.
389
+ *
390
+ * @param {UserOptions} [options]
391
+ * Optional parameters.
392
+ */
393
+ async haveModuleAccess (moduleAccess, options) {
394
+ await util.resolveUser(options?.user).hasModuleAccess(moduleAccess)
395
+ }
396
+
298
397
  async haveSetting (obj, options) {
299
398
  if (typeof obj === 'string') {
300
399
  const input = obj.split('//')
@@ -393,10 +492,38 @@ class AppSuiteHelper extends Helper {
393
492
  for (const mail of iterable) await this.haveMail(mail, options)
394
493
  }
395
494
 
396
- async haveAnAlias (alias, options = {}) {
397
- console.warn('This method is deprecated, use `user.hasAlias` instead')
398
- const user = options.user || codecept.container.support('users')[0]
399
- return user.hasAlias(alias)
495
+ /**
496
+ * Adds an alias email address to a user account during a test.
497
+ *
498
+ * Use this method inside test scenarios instead of calling `await
499
+ * user.hasAlias()` directly to make this call part of the recorder queue,
500
+ * instead of executing it immediately during test step registration.
501
+ *
502
+ * @param {string} alias
503
+ * The alias email address to be added to the user account.
504
+ *
505
+ * @param {UserOptions} [options]
506
+ * Optional parameters.
507
+ */
508
+ async haveAnAlias (alias, options) {
509
+ await util.resolveUser(options?.user).hasAlias(alias)
510
+ }
511
+
512
+ /**
513
+ * Removes an alias email address from a user account during a test.
514
+ *
515
+ * Use this method inside test scenarios instead of calling `await
516
+ * user.doesntHaveAlias()` directly to make this call part of the recorder
517
+ * queue, instead of executing it immediately during test step registration.
518
+ *
519
+ * @param {string} alias
520
+ * The alias email address to be removed from the user account.
521
+ *
522
+ * @param {UserOptions} [options]
523
+ * Optional parameters.
524
+ */
525
+ async dontHaveAlias (alias, options) {
526
+ await util.resolveUser(options?.user).doesntHaveAlias(alias)
400
527
  }
401
528
 
402
529
  async haveMailFilterRule (rule, options) {
@@ -20,14 +20,13 @@
20
20
 
21
21
  'use strict'
22
22
 
23
- const { recorder } = require('codeceptjs')
23
+ const { recorder, container } = require('codeceptjs')
24
24
  const event = require('../../event')
25
- const Helper = require('../../helper')
26
25
 
27
26
  module.exports = function () {
28
27
  event.dispatcher.on(event.provisioning.user.created, (user) => {
29
28
  recorder.startUnlessRunning()
30
- const helper = new Helper()
29
+ const helper = container.helpers('AppSuite')
31
30
  recorder.add('inject starting in contacts folder setting', async () => {
32
31
  await helper.haveSetting({ 'io.ox/contacts': { startInGlobalAddressbook: false } }, { user })
33
32
  })
package/src/util.js CHANGED
@@ -99,6 +99,21 @@ module.exports = {
99
99
  addJitter (id) {
100
100
  const [JITTER_MIN, JITTER_MAX] = [1000, 5000]
101
101
  return Math.trunc(id) + Math.floor(Math.random() * (JITTER_MAX - JITTER_MIN + 1) + JITTER_MIN)
102
- }
102
+ },
103
103
 
104
+ /**
105
+ * Resolves the effective user account to be used.
106
+ *
107
+ * @param {object} [user]
108
+ * The user account to be used. Default is the first created user.
109
+ *
110
+ * @returns {object}
111
+ * The passed user account if existing, otherwise the first created user
112
+ * account.
113
+ */
114
+ resolveUser (user) {
115
+ user ??= codecept.container.support('users')[0]
116
+ if (!user) throw new Error('no users created')
117
+ return user
118
+ },
104
119
  }
package/eslint.config.mjs DELETED
@@ -1,73 +0,0 @@
1
- /**
2
- * @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
3
- * @license AGPL-3.0
4
- *
5
- * This code is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU Affero General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU Affero General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU Affero General Public License
16
- * along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
17
- *
18
- * Any use of the work other than as authorized under this license or copyright law is prohibited.
19
- */
20
- import config from '@open-xchange/lint'
21
- import mocha from 'eslint-plugin-mocha'
22
- import { FlatCompat } from '@eslint/eslintrc'
23
-
24
- import path from 'node:path'
25
- import url from 'node:url'
26
-
27
- const __filename = url.fileURLToPath(import.meta.url)
28
- const __dirname = path.dirname(__filename)
29
-
30
- const codeceptjs = new FlatCompat({
31
- baseDirectory: __dirname
32
- }).extends('plugin:codeceptjs/recommended')
33
-
34
- export default [
35
- ...config,
36
- {
37
- files: ['**/*.js'],
38
- plugins: {
39
- ...codeceptjs[1].plugins
40
- },
41
- rules: {
42
- ...codeceptjs[1].rules,
43
- 'no-unused-expressions': 0,
44
- 'import/no-absolute-path': 0,
45
- 'codeceptjs/no-skipped-tests': 'off',
46
- 'codeceptjs/no-pause-in-scenario': 'off'
47
- },
48
- languageOptions: {
49
- globals: {
50
- ...codeceptjs[0].languageOptions.globals,
51
- ...mocha.configs.recommended.languageOptions.globals,
52
- Feature: true,
53
- Scenario: true,
54
- Before: true,
55
- After: true,
56
- within: true,
57
- assert: true,
58
- locate: true,
59
- session: true,
60
- inject: true,
61
- codecept_dir: true,
62
- output_dir: true,
63
- DataTable: true,
64
- Data: true,
65
- BeforeSuite: true,
66
- AfterSuite: true,
67
- actor: true,
68
- expect: true,
69
- require: true
70
- }
71
- }
72
- }
73
- ]