@jahia/cypress 3.20.1 → 3.21.0
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/dist/support/apollo/apolloClient.d.ts +5 -3
- package/dist/support/apollo/apolloClient.js +22 -10
- package/dist/support/login.d.ts +1 -1
- package/dist/support/login.js +4 -3
- package/dist/utils/SiteHelper.d.ts +5 -4
- package/dist/utils/SiteHelper.js +10 -8
- package/package.json +1 -1
- package/src/support/apollo/apolloClient.md +3 -2
- package/src/support/apollo/apolloClient.ts +21 -11
- package/src/support/login.ts +3 -3
- package/src/utils/SiteHelper.ts +11 -8
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
2
|
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
|
|
3
|
-
interface
|
|
3
|
+
interface HostConfig {
|
|
4
4
|
token?: string;
|
|
5
5
|
username?: string;
|
|
6
6
|
password?: string;
|
|
7
|
+
url?: string;
|
|
7
8
|
}
|
|
8
9
|
declare global {
|
|
9
10
|
namespace Cypress {
|
|
10
11
|
interface Chainable<Subject> {
|
|
11
|
-
apolloClient(
|
|
12
|
+
apolloClient(config?: HostConfig): Chainable<ApolloClient<NormalizedCacheObject>>;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
export declare type ApolloClientOptions = Cypress.Loggable & {
|
|
16
17
|
setCurrentApolloClient: boolean;
|
|
17
18
|
};
|
|
18
|
-
export declare const
|
|
19
|
+
export declare const switchApolloClient: (config?: HostConfig, options?: ApolloClientOptions) => void;
|
|
20
|
+
export declare const apolloClient: (config?: HostConfig, options?: ApolloClientOptions) => void;
|
|
19
21
|
export {};
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.apolloClient = void 0;
|
|
3
|
+
exports.apolloClient = exports.switchApolloClient = void 0;
|
|
4
4
|
var core_1 = require("@apollo/client/core");
|
|
5
5
|
var links_1 = require("./links");
|
|
6
|
-
var
|
|
6
|
+
var switchApolloClient = function (config, options) {
|
|
7
|
+
if (config === void 0) { config = { url: Cypress.config().baseUrl }; }
|
|
8
|
+
if (options === void 0) { options = {
|
|
9
|
+
log: true,
|
|
10
|
+
setCurrentApolloClient: true
|
|
11
|
+
}; }
|
|
12
|
+
// Switch context to apollo client
|
|
13
|
+
cy.visit(config.url, { failOnStatusCode: false });
|
|
14
|
+
return exports.apolloClient(config, options);
|
|
15
|
+
};
|
|
16
|
+
exports.switchApolloClient = switchApolloClient;
|
|
17
|
+
var apolloClient = function (config, options) {
|
|
18
|
+
if (config === void 0) { config = { url: Cypress.config().baseUrl }; }
|
|
7
19
|
if (options === void 0) { options = {
|
|
8
20
|
log: true,
|
|
9
21
|
setCurrentApolloClient: true
|
|
10
22
|
}; }
|
|
11
23
|
var headers = {};
|
|
12
|
-
if (
|
|
13
|
-
headers.authorization = "
|
|
24
|
+
if (config.token !== undefined) {
|
|
25
|
+
headers.authorization = "APIToken " + config.token;
|
|
14
26
|
}
|
|
15
|
-
else if (
|
|
16
|
-
headers.authorization = "
|
|
27
|
+
else if (config.username !== undefined && config.password !== undefined) {
|
|
28
|
+
headers.authorization = "Basic " + btoa(config.username + ':' + config.password);
|
|
17
29
|
}
|
|
18
|
-
else
|
|
19
|
-
headers.authorization = "Basic " + btoa(
|
|
30
|
+
else {
|
|
31
|
+
headers.authorization = "Basic " + btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'));
|
|
20
32
|
}
|
|
21
|
-
var links = [links_1.uploadLink, links_1.formDataHttpLink(
|
|
33
|
+
var links = [links_1.uploadLink, links_1.formDataHttpLink(config.url, headers)];
|
|
22
34
|
var client = new core_1.ApolloClient({
|
|
23
35
|
link: core_1.from(links),
|
|
24
36
|
cache: new core_1.InMemoryCache(),
|
|
@@ -35,7 +47,7 @@ var apolloClient = function (authMethod, options) {
|
|
|
35
47
|
message: 'Create new apollo client',
|
|
36
48
|
consoleProps: function () {
|
|
37
49
|
return {
|
|
38
|
-
|
|
50
|
+
Config: config,
|
|
39
51
|
Yielded: client
|
|
40
52
|
};
|
|
41
53
|
}
|
package/dist/support/login.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ declare global {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
export declare const login: (username?: string, password?: string) => void;
|
|
10
|
+
export declare const login: (username?: string, password?: string, url?: string) => void;
|
|
11
11
|
export declare const loginAndStoreSession: (username?: string, password?: string) => void;
|
package/dist/support/login.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.loginAndStoreSession = exports.login = void 0;
|
|
5
5
|
/// <reference types="cypress" />
|
|
6
|
-
var login = function (username, password) {
|
|
6
|
+
var login = function (username, password, url) {
|
|
7
7
|
if (username === void 0) { username = 'root'; }
|
|
8
8
|
if (password === void 0) { password = Cypress.env('SUPER_USER_PASSWORD'); }
|
|
9
|
+
if (url === void 0) { url = '/cms/login'; }
|
|
9
10
|
Cypress.log({
|
|
10
11
|
name: 'login',
|
|
11
12
|
message: "Login with " + username,
|
|
@@ -17,11 +18,11 @@ var login = function (username, password) {
|
|
|
17
18
|
});
|
|
18
19
|
cy.request({
|
|
19
20
|
method: 'POST',
|
|
20
|
-
url: '/cms/login',
|
|
21
21
|
form: true,
|
|
22
22
|
body: { username: username, password: password },
|
|
23
23
|
followRedirect: false,
|
|
24
|
-
log: false
|
|
24
|
+
log: false,
|
|
25
|
+
url: url
|
|
25
26
|
}).then(function (res) {
|
|
26
27
|
expect(res.status, 'Login result').to.eq(302);
|
|
27
28
|
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { JahiaServer } from '../support';
|
|
1
2
|
export declare const createSite: (siteKey: string, config?: {
|
|
2
3
|
languages?: string;
|
|
3
4
|
templateSet: string;
|
|
4
5
|
serverName: string;
|
|
5
6
|
locale: string;
|
|
6
|
-
}) => void;
|
|
7
|
-
export declare const deleteSite: (siteKey: string) => void;
|
|
8
|
-
export declare const enableModule: (moduleName: string, siteKey: string) => void;
|
|
7
|
+
}, jahiaServer?: JahiaServer) => void;
|
|
8
|
+
export declare const deleteSite: (siteKey: string, jahiaServer?: JahiaServer) => void;
|
|
9
|
+
export declare const enableModule: (moduleName: string, siteKey: string, jahiaServer?: JahiaServer) => void;
|
|
9
10
|
export declare const disableModule: (moduleName: string, siteKey: string) => void;
|
|
10
11
|
export declare const editSite: (siteKey: string, config?: {
|
|
11
12
|
serverName: string;
|
|
12
|
-
}) => void;
|
|
13
|
+
}, jahiaServer?: JahiaServer) => void;
|
package/dist/utils/SiteHelper.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.editSite = exports.disableModule = exports.enableModule = exports.deleteSite = exports.createSite = void 0;
|
|
4
|
-
|
|
4
|
+
// eslint-disable-next-line default-param-last
|
|
5
|
+
var createSite = function (siteKey, config, jahiaServer) {
|
|
5
6
|
if (config === void 0) { config = { templateSet: 'dx-base-demo-templates', serverName: 'localhost', locale: 'en' }; }
|
|
6
7
|
cy.executeGroovy('groovy/admin/createSite.groovy', {
|
|
7
8
|
SITEKEY: siteKey,
|
|
@@ -9,20 +10,20 @@ var createSite = function (siteKey, config) {
|
|
|
9
10
|
SERVERNAME: config.serverName,
|
|
10
11
|
LOCALE: config.locale,
|
|
11
12
|
LANGUAGES: config.languages || config.locale
|
|
12
|
-
});
|
|
13
|
+
}, jahiaServer);
|
|
13
14
|
};
|
|
14
15
|
exports.createSite = createSite;
|
|
15
|
-
var deleteSite = function (siteKey) {
|
|
16
|
+
var deleteSite = function (siteKey, jahiaServer) {
|
|
16
17
|
cy.executeGroovy('groovy/admin/deleteSite.groovy', {
|
|
17
18
|
SITEKEY: siteKey
|
|
18
|
-
});
|
|
19
|
+
}, jahiaServer);
|
|
19
20
|
};
|
|
20
21
|
exports.deleteSite = deleteSite;
|
|
21
|
-
var enableModule = function (moduleName, siteKey) {
|
|
22
|
+
var enableModule = function (moduleName, siteKey, jahiaServer) {
|
|
22
23
|
cy.runProvisioningScript({
|
|
23
24
|
fileContent: '- enable: "' + moduleName + '"\n site: "' + siteKey + '"',
|
|
24
25
|
type: 'application/yaml'
|
|
25
|
-
});
|
|
26
|
+
}, undefined, jahiaServer);
|
|
26
27
|
};
|
|
27
28
|
exports.enableModule = enableModule;
|
|
28
29
|
var disableModule = function (moduleName, siteKey) {
|
|
@@ -32,11 +33,12 @@ var disableModule = function (moduleName, siteKey) {
|
|
|
32
33
|
});
|
|
33
34
|
};
|
|
34
35
|
exports.disableModule = disableModule;
|
|
35
|
-
|
|
36
|
+
// eslint-disable-next-line default-param-last
|
|
37
|
+
var editSite = function (siteKey, config, jahiaServer) {
|
|
36
38
|
if (config === void 0) { config = { serverName: 'localhost' }; }
|
|
37
39
|
cy.executeGroovy('groovy/admin/editSite.groovy', {
|
|
38
40
|
SITEKEY: siteKey,
|
|
39
41
|
SERVERNAME: config.serverName
|
|
40
|
-
});
|
|
42
|
+
}, jahiaServer);
|
|
41
43
|
};
|
|
42
44
|
exports.editSite = editSite;
|
package/package.json
CHANGED
|
@@ -13,13 +13,14 @@ cy.apolloClient()
|
|
|
13
13
|
|
|
14
14
|
### Arguments
|
|
15
15
|
|
|
16
|
-
#### >
|
|
16
|
+
#### > config (`HostConfig`)
|
|
17
17
|
|
|
18
|
-
If no authorization is passed, will use root credentials. Otherwise :
|
|
18
|
+
If no authorization is passed, will use root credentials and cypress base url. Otherwise :
|
|
19
19
|
|
|
20
20
|
- token: An API token
|
|
21
21
|
- username
|
|
22
22
|
- password
|
|
23
|
+
- url
|
|
23
24
|
|
|
24
25
|
#### > options (`ApolloClientOptions`)
|
|
25
26
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {ApolloClient, from, InMemoryCache, NormalizedCacheObject} from '@apollo/client/core';
|
|
2
2
|
import {formDataHttpLink, uploadLink} from './links';
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
interface HostConfig {
|
|
5
5
|
token?: string
|
|
6
6
|
username?: string
|
|
7
|
-
password?: string
|
|
7
|
+
password?: string,
|
|
8
|
+
url?: string
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
declare global {
|
|
@@ -12,7 +13,7 @@ declare global {
|
|
|
12
13
|
namespace Cypress {
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
15
|
interface Chainable<Subject> {
|
|
15
|
-
apolloClient(
|
|
16
|
+
apolloClient(config?: HostConfig): Chainable<ApolloClient<NormalizedCacheObject>>
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -21,20 +22,29 @@ export type ApolloClientOptions = Cypress.Loggable & {
|
|
|
21
22
|
setCurrentApolloClient: boolean
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export const
|
|
25
|
+
export const switchApolloClient = function (config: HostConfig = {url: Cypress.config().baseUrl}, options: ApolloClientOptions = {
|
|
26
|
+
log: true,
|
|
27
|
+
setCurrentApolloClient: true
|
|
28
|
+
}): void {
|
|
29
|
+
// Switch context to apollo client
|
|
30
|
+
cy.visit(config.url, {failOnStatusCode: false});
|
|
31
|
+
return apolloClient(config, options);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const apolloClient = function (config: HostConfig = {url: Cypress.config().baseUrl}, options: ApolloClientOptions = {
|
|
25
35
|
log: true,
|
|
26
36
|
setCurrentApolloClient: true
|
|
27
37
|
}): void {
|
|
28
38
|
const headers: { authorization?: string } = {};
|
|
29
|
-
if (
|
|
39
|
+
if (config.token !== undefined) {
|
|
40
|
+
headers.authorization = `APIToken ${config.token}`;
|
|
41
|
+
} else if (config.username !== undefined && config.password !== undefined) {
|
|
42
|
+
headers.authorization = `Basic ${btoa(config.username + ':' + config.password)}`;
|
|
43
|
+
} else {
|
|
30
44
|
headers.authorization = `Basic ${btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'))}`;
|
|
31
|
-
} else if (authMethod.token !== undefined) {
|
|
32
|
-
headers.authorization = `APIToken ${authMethod.token}`;
|
|
33
|
-
} else if (authMethod.username !== undefined && authMethod.password !== undefined) {
|
|
34
|
-
headers.authorization = `Basic ${btoa(authMethod.username + ':' + authMethod.password)}`;
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
const links = [uploadLink, formDataHttpLink(
|
|
47
|
+
const links = [uploadLink, formDataHttpLink(config.url, headers)];
|
|
38
48
|
|
|
39
49
|
const client = new ApolloClient({
|
|
40
50
|
link: from(links),
|
|
@@ -53,7 +63,7 @@ export const apolloClient = function (authMethod?: AuthMethod, options: ApolloCl
|
|
|
53
63
|
message: 'Create new apollo client',
|
|
54
64
|
consoleProps: () => {
|
|
55
65
|
return {
|
|
56
|
-
|
|
66
|
+
Config: config,
|
|
57
67
|
Yielded: client
|
|
58
68
|
};
|
|
59
69
|
}
|
package/src/support/login.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare global {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const login = (username = 'root', password: string = Cypress.env('SUPER_USER_PASSWORD')): void => {
|
|
16
|
+
export const login = (username = 'root', password: string = Cypress.env('SUPER_USER_PASSWORD'), url = '/cms/login'): void => {
|
|
17
17
|
Cypress.log({
|
|
18
18
|
name: 'login',
|
|
19
19
|
message: `Login with ${username}`,
|
|
@@ -26,11 +26,11 @@ export const login = (username = 'root', password: string = Cypress.env('SUPER_U
|
|
|
26
26
|
|
|
27
27
|
cy.request({
|
|
28
28
|
method: 'POST',
|
|
29
|
-
url: '/cms/login',
|
|
30
29
|
form: true,
|
|
31
30
|
body: {username, password},
|
|
32
31
|
followRedirect: false,
|
|
33
|
-
log: false
|
|
32
|
+
log: false,
|
|
33
|
+
url
|
|
34
34
|
}).then(res => {
|
|
35
35
|
expect(res.status, 'Login result').to.eq(302);
|
|
36
36
|
});
|
package/src/utils/SiteHelper.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
+
import {JahiaServer} from '../support';
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
// eslint-disable-next-line default-param-last
|
|
4
|
+
export const createSite = (siteKey: string, config: {languages?: string, templateSet: string, serverName: string, locale: string} = {templateSet: 'dx-base-demo-templates', serverName: 'localhost', locale: 'en'}, jahiaServer?: JahiaServer): void => {
|
|
3
5
|
cy.executeGroovy('groovy/admin/createSite.groovy', {
|
|
4
6
|
SITEKEY: siteKey,
|
|
5
7
|
TEMPLATES_SET: config.templateSet,
|
|
6
8
|
SERVERNAME: config.serverName,
|
|
7
9
|
LOCALE: config.locale,
|
|
8
10
|
LANGUAGES: config.languages || config.locale
|
|
9
|
-
});
|
|
11
|
+
}, jahiaServer);
|
|
10
12
|
};
|
|
11
13
|
|
|
12
|
-
export const deleteSite = (siteKey: string): void => {
|
|
14
|
+
export const deleteSite = (siteKey: string, jahiaServer?: JahiaServer): void => {
|
|
13
15
|
cy.executeGroovy('groovy/admin/deleteSite.groovy', {
|
|
14
16
|
SITEKEY: siteKey
|
|
15
|
-
});
|
|
17
|
+
}, jahiaServer);
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
export const enableModule = (moduleName: string, siteKey: string): void => {
|
|
20
|
+
export const enableModule = (moduleName: string, siteKey: string, jahiaServer?: JahiaServer): void => {
|
|
19
21
|
cy.runProvisioningScript({
|
|
20
22
|
fileContent: '- enable: "' + moduleName + '"\n site: "' + siteKey + '"',
|
|
21
23
|
type: 'application/yaml'
|
|
22
|
-
});
|
|
24
|
+
}, undefined, jahiaServer);
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
export const disableModule = (moduleName: string, siteKey: string): void => {
|
|
@@ -29,9 +31,10 @@ export const disableModule = (moduleName: string, siteKey: string): void => {
|
|
|
29
31
|
});
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
// eslint-disable-next-line default-param-last
|
|
35
|
+
export const editSite = (siteKey: string, config: {serverName: string} = {serverName: 'localhost'}, jahiaServer?: JahiaServer): void => {
|
|
33
36
|
cy.executeGroovy('groovy/admin/editSite.groovy', {
|
|
34
37
|
SITEKEY: siteKey,
|
|
35
38
|
SERVERNAME: config.serverName
|
|
36
|
-
});
|
|
39
|
+
}, jahiaServer);
|
|
37
40
|
};
|