@jahia/cypress 1.0.6 → 1.0.10
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.
- package/.graphqlconfig +16 -0
- package/README.md +2 -0
- package/dist/page-object/baseComponent.d.ts +2 -0
- package/dist/page-object/baseComponent.js +14 -0
- package/dist/page-object/moonstone/menu.js +5 -1
- package/dist/plugins/env.js +14 -4
- package/dist/support/fixture.js +6 -2
- package/dist/support/index.d.ts +1 -0
- package/dist/support/index.js +1 -0
- package/dist/support/provisioning/runProvisioningScript.js +17 -21
- package/dist/support/registerSupport.js +2 -0
- package/dist/support/reloadUntil.d.ts +15 -0
- package/dist/support/reloadUntil.js +50 -0
- package/dist/support/repeatUntil.d.ts +15 -0
- package/dist/support/repeatUntil.js +52 -0
- package/dist/support/waitUntil.d.ts +15 -0
- package/dist/support/waitUntil.js +44 -0
- package/fixtures/graphql/jcr/addNode.graphql +16 -0
- package/fixtures/graphql/jcr/deleteNode.graphql +5 -0
- package/fixtures/graphql/jcr/mutateNode.graphql +13 -0
- package/fixtures/groovy/admin/createSite.groovy +14 -0
- package/fixtures/groovy/admin/deleteSite.groovy +6 -0
- package/package.json +1 -1
- package/schema.graphql +2874 -0
- package/src/page-object/baseComponent.ts +5 -0
- package/src/page-object/moonstone/menu.ts +5 -1
- package/src/plugins/env.ts +13 -4
- package/src/support/fixture.ts +5 -2
- package/src/support/index.ts +1 -0
- package/src/support/provisioning/runProvisioningScript.ts +15 -19
- package/src/support/registerSupport.ts +2 -0
- package/src/support/repeatUntil.md +40 -0
- package/src/support/repeatUntil.ts +59 -0
- package/fixtures/test.json +0 -0
|
@@ -3,6 +3,7 @@ import Chainable = Cypress.Chainable;
|
|
|
3
3
|
export type ComponentType<Component> = { new(p: Chainable<JQuery>, assertion?: (s: JQuery) => void): Component, defaultSelector: string };
|
|
4
4
|
|
|
5
5
|
export class BaseComponent {
|
|
6
|
+
static defaultSelector = ''
|
|
6
7
|
static count = 0
|
|
7
8
|
|
|
8
9
|
element: Chainable<JQuery>
|
|
@@ -22,4 +23,8 @@ export class BaseComponent {
|
|
|
22
23
|
|
|
23
24
|
return cy.get('@component' + this.id, {log: false})
|
|
24
25
|
}
|
|
26
|
+
|
|
27
|
+
should(arg, ...others) {
|
|
28
|
+
return cy.get('@component' + this.id, {log: false}).should(arg, ...others)
|
|
29
|
+
}
|
|
25
30
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import {BaseComponent} from "../baseComponent"
|
|
2
2
|
|
|
3
3
|
export class Menu extends BaseComponent {
|
|
4
|
-
static defaultSelector = '.moonstone-menu'
|
|
4
|
+
static defaultSelector = '.moonstone-menu:visible'
|
|
5
5
|
|
|
6
6
|
select(item: string): Menu {
|
|
7
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
8
|
+
cy.wait(500)
|
|
7
9
|
this.get().find(`.moonstone-menuItem`).should("contain", item).contains(item).trigger('click')
|
|
8
10
|
return this
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
selectByRole(item: string): Menu {
|
|
14
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
15
|
+
cy.wait(500)
|
|
12
16
|
this.get().find(`.moonstone-menuItem[data-sel-role="${item}"]`).trigger('click')
|
|
13
17
|
return this
|
|
14
18
|
}
|
package/src/plugins/env.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
const env = (on:Cypress.PluginEvents, config: Cypress.PluginConfigOptions):Cypress.PluginConfigOptions => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
if (!process.env.JAHIA_URL && !process.env.SUPER_USER_PASSWORD) {
|
|
3
|
+
console.warn('No environment set, will use default values')
|
|
4
|
+
config.baseUrl = 'http://localhost:8080'
|
|
5
|
+
config.env.JAHIA_URL = 'http://localhost:8080'
|
|
6
|
+
config.env.SUPER_USER_PASSWORD = 'root1234'
|
|
7
|
+
} else {
|
|
8
|
+
console.log('Setting environment');
|
|
9
|
+
config.baseUrl = process.env.JAHIA_URL
|
|
10
|
+
config.env.JAHIA_URL = process.env.JAHIA_URL
|
|
11
|
+
config.env.SUPER_USER_PASSWORD = process.env.SUPER_USER_PASSWORD
|
|
12
|
+
}
|
|
13
|
+
console.log('JAHIA_URL =', config.env.JAHIA_URL)
|
|
14
|
+
console.log('SUPER_USER_PASSWORD =', config.env.SUPER_USER_PASSWORD)
|
|
6
15
|
|
|
7
16
|
return config
|
|
8
17
|
}
|
package/src/support/fixture.ts
CHANGED
|
@@ -6,7 +6,6 @@ export const fixture = function(originalCommand: ((...args: any[]) => any), fixt
|
|
|
6
6
|
return originalCommand(fixture, ...args).then(f => {
|
|
7
7
|
return f
|
|
8
8
|
}).catch((err) => {
|
|
9
|
-
console.log(err)
|
|
10
9
|
return null;
|
|
11
10
|
});
|
|
12
11
|
}).then(file => {
|
|
@@ -16,7 +15,11 @@ export const fixture = function(originalCommand: ((...args: any[]) => any), fixt
|
|
|
16
15
|
encoding = args[0]
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
try {
|
|
19
|
+
cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixture, encoding, {log: false, timeout: 0})
|
|
20
|
+
} catch (e) {
|
|
21
|
+
console.log(e)
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
})
|
|
22
25
|
};
|
package/src/support/index.ts
CHANGED
|
@@ -31,32 +31,28 @@ function processContent(formFile: FormFile) {
|
|
|
31
31
|
return Cypress.Blob.binaryStringToBlob(content, formFile.type);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
})
|
|
34
|
+
function append(formFile: FormFile, formData: FormData, key: string) {
|
|
35
|
+
if (formFile.fileContent) {
|
|
36
|
+
formData.append(key, processContent(formFile), formFile.fileName);
|
|
37
|
+
} else {
|
|
38
|
+
cy.fixture(formFile.fileName, (formFile.encoding ? formFile.encoding : 'binary')).then(content => {
|
|
39
|
+
if (typeof content === 'object') {
|
|
40
|
+
formFile.fileContent = JSON.stringify(content);
|
|
41
|
+
} else {
|
|
42
|
+
formFile.fileContent = content;
|
|
43
|
+
}
|
|
44
|
+
formData.append(key, processContent(formFile), formFile.fileName);
|
|
45
|
+
})
|
|
46
|
+
}
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
export const runProvisioningScript = (script: FormFile, files?: FormFile[], options: Cypress.Loggable = {log:true}): void => {
|
|
52
50
|
const formData = new FormData()
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
append(script, formData, "script")
|
|
55
53
|
if (files) {
|
|
56
54
|
files.forEach((f) => {
|
|
57
|
-
|
|
58
|
-
formData.append("file", blob, f.fileName)
|
|
59
|
-
})
|
|
55
|
+
append(f, formData, "file")
|
|
60
56
|
})
|
|
61
57
|
}
|
|
62
58
|
|
|
@@ -4,6 +4,7 @@ import {login} from "./login"
|
|
|
4
4
|
import {logout} from "./logout"
|
|
5
5
|
import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector'
|
|
6
6
|
import {fixture} from "./fixture";
|
|
7
|
+
import {repeatUntil} from "./repeatUntil";
|
|
7
8
|
|
|
8
9
|
export const registerSupport = (): void => {
|
|
9
10
|
Cypress.Commands.add('apolloClient', apolloClient)
|
|
@@ -14,6 +15,7 @@ export const registerSupport = (): void => {
|
|
|
14
15
|
|
|
15
16
|
Cypress.Commands.add('login', login)
|
|
16
17
|
Cypress.Commands.add('logout', logout)
|
|
18
|
+
Cypress.Commands.add('repeatUntil', repeatUntil)
|
|
17
19
|
|
|
18
20
|
Cypress.Commands.overwrite('fixture', fixture)
|
|
19
21
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# repeatUntil
|
|
2
|
+
|
|
3
|
+
This commands reload or repeat a function until an item is visible in the page
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
### Usage
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
cy.repeatUntil('div:contains("some text")')
|
|
11
|
+
cy.repeatUntil('div:contains("some text")', {attempts: 10, reloadCallback: () => { cy.reload() }, delay: 1000})
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Arguments
|
|
15
|
+
|
|
16
|
+
#### > selector (`string`)
|
|
17
|
+
|
|
18
|
+
The selector that is being searched in the page
|
|
19
|
+
|
|
20
|
+
#### > options (`RepeatUntilOptions`)
|
|
21
|
+
|
|
22
|
+
- `attempts`: max number of attempts
|
|
23
|
+
- `callback`: the callback to execute if the item is not found. By default, do a `cy.reload()`
|
|
24
|
+
- `delay`: time to wait between each attemps (ms)
|
|
25
|
+
|
|
26
|
+
### Yields
|
|
27
|
+
|
|
28
|
+
The found element
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
### Requirements
|
|
33
|
+
|
|
34
|
+
- `cy.repeatUntil()` requires being chained off of `cy`.
|
|
35
|
+
|
|
36
|
+
### Assertions
|
|
37
|
+
|
|
38
|
+
### Timeouts
|
|
39
|
+
|
|
40
|
+
## Command Log
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
|
|
2
|
+
|
|
3
|
+
// Load type definitions that come with Cypress module
|
|
4
|
+
/// <reference types="cypress" />
|
|
5
|
+
|
|
6
|
+
type RepeatUntilOptions = {
|
|
7
|
+
attempts: number,
|
|
8
|
+
callback: () => void,
|
|
9
|
+
delay: number,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const defaultOptions: RepeatUntilOptions = {
|
|
13
|
+
attempts: 10,
|
|
14
|
+
callback: () => cy.reload({log:false}),
|
|
15
|
+
delay: 1000
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
namespace Cypress {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
interface Chainable<Subject> {
|
|
22
|
+
repeatUntil(selector: string, options?: Partial<RepeatUntilOptions>): Chainable<JQuery>
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const repeatUntil = (selector: string, options: Partial<RepeatUntilOptions> = {}): void => {
|
|
28
|
+
options = { ...defaultOptions, ...options }
|
|
29
|
+
|
|
30
|
+
const log = Cypress.log({
|
|
31
|
+
name: 'repeatUntil',
|
|
32
|
+
message: `Reload until ${selector}, remaining attempts : ${options.attempts}`,
|
|
33
|
+
consoleProps: () => {
|
|
34
|
+
return {
|
|
35
|
+
attempts: options.attempts,
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const items = Cypress.$(selector)
|
|
41
|
+
if (items.length) {
|
|
42
|
+
log.set({ $el: items })
|
|
43
|
+
cy.wrap(items, {log: false})
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (options.attempts > 1) {
|
|
48
|
+
log.end()
|
|
49
|
+
options.callback()
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
52
|
+
cy.wait(options.delay)
|
|
53
|
+
cy.repeatUntil(selector, {...options, attempts: options.attempts - 1})
|
|
54
|
+
} else {
|
|
55
|
+
const err = Error('Items not found.')
|
|
56
|
+
log.error(err)
|
|
57
|
+
throw err
|
|
58
|
+
}
|
|
59
|
+
}
|
package/fixtures/test.json
DELETED
|
File without changes
|