graphdb-workbench-tests 2.8.4 → 3.0.0-NEW-JENKINS-1
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/fixtures/graph/rdf.txt +130 -0
- package/fixtures/graphdb-import/ontology-and-shapes.ttl +562 -0
- package/fixtures/graphdb-import/swapi-dataset.ttl +4393 -0
- package/fixtures/graphql/endpoints/graphql-endpoints-info.json +49 -0
- package/fixtures/graphql/endpoints/no-graphql-endpoints-info.json +3 -0
- package/fixtures/graphql/soml/big-swapi-schema-broken.yaml +83167 -0
- package/fixtures/graphql/soml/swapi-schema-broken.yaml +880 -0
- package/fixtures/graphql/soml/swapi-schema-broken.zip +0 -0
- package/fixtures/graphql/soml/swapi-schema-film-restricted.yaml +335 -0
- package/fixtures/graphql/soml/swapi-schema-planets.yaml +51 -0
- package/fixtures/graphql/soml/swapi-schema-species.yaml +66 -0
- package/fixtures/graphql/soml/swapi-schema.yaml +857 -0
- package/fixtures/graphql/soml/swapi-schemas.zip +0 -0
- package/fixtures/locale-en.json +666 -37
- package/fixtures/ttyg/agent/get-agent-list-autocomplete-query.json +23 -0
- package/fixtures/ttyg/autocomplete-response.json +154 -0
- package/integration/explore/class.hierarchy.spec.js +131 -184
- package/integration/explore/graphs.overview.spec.js +18 -10
- package/integration/explore/visual-graph/graphs-config.spec.js +17 -1
- package/integration/explore/visual-graph/visual-graph-node-labels.spec.js +68 -0
- package/integration/graphql/activate-deactivate-graphql-endpoint.spec.js +40 -0
- package/integration/graphql/create-graphql-endpoint.spec.js +281 -0
- package/integration/graphql/delete-graphql-endpoint.spec.js +46 -0
- package/integration/graphql/edit-graphql-enpoint.spec.js +160 -0
- package/integration/graphql/export-graphql-endpoint-definition.spec.js +35 -0
- package/integration/graphql/filter-graphql-endpoints-on-management-view.spec.js +66 -0
- package/integration/graphql/graphql-endpoint-management-view.spec.js +142 -0
- package/integration/graphql/graphql-playground.spec.js +110 -0
- package/integration/graphql/import-graphql-endpoint-definitions.spec.js +269 -0
- package/integration/graphql/set-default-graphql-endpoint.spec.js +42 -0
- package/integration/import/import-server-files-batch-operations.spec.js +4 -3
- package/integration/import/import-server-files.spec.js +29 -7
- package/integration/import/import-user-data-url.spec.js +33 -0
- package/integration/import/import-view.spec.js +2 -1
- package/integration/repository/repositories.spec.js +9 -4
- package/integration/setup/user-and-access.spec.js +695 -117
- package/integration/sparql-editor/actions/show-saved-queries.spec.js +1 -1
- package/integration/sparql-editor/saved-query/readonly-query.spec.js +66 -0
- package/integration/ttyg/edit-agent.spec.js +45 -0
- package/integration-flaky/setup/users-and-access/security-and-free-access.spec.js +54 -0
- package/{integration → integration-flaky}/ttyg/ttyg-permission.spec.js +4 -3
- package/npm-shrinkwrap.json +931 -305
- package/package.json +3 -3
- package/steps/class-views-steps.js +139 -0
- package/steps/explore/graphs-overview-steps.js +12 -0
- package/steps/graphql/create-graphql-endpoint-steps.js +277 -0
- package/steps/graphql/edit-graphql-endpoint-steps.js +124 -0
- package/steps/graphql/generation-report-modal-steps.js +34 -0
- package/steps/graphql/graphiql-editor-tools-steps.js +10 -0
- package/steps/graphql/graphiql-playground-steps.js +6 -0
- package/steps/graphql/graphql-endpoint-management-steps.js +147 -0
- package/steps/graphql/graphql-playground-steps.js +90 -0
- package/steps/graphql/import-endpoint-definition-modal-steps.js +80 -0
- package/steps/home-steps.js +1 -1
- package/steps/import/import-settings-dialog-steps.js +12 -0
- package/steps/import/import-steps.js +9 -4
- package/steps/import/import-test-constants.js +1 -0
- package/steps/import/import-user-data-steps.js +8 -0
- package/steps/login-steps.js +20 -0
- package/steps/modal-dialog-steps.js +8 -0
- package/steps/repository-steps.js +4 -0
- package/steps/setup/user-and-access-steps.js +165 -11
- package/steps/ttyg/ttyg-agent-settings-modal.steps.js +44 -0
- package/steps/visual-graph-steps.js +14 -0
- package/steps/yasgui/saved-queries-dialog.js +19 -3
- package/stubs/global-operations-statuses-stub.js +2 -2
- package/stubs/graphql/graphql-stubs.js +146 -0
- package/stubs/repositories/repositories-stubs.js +4 -0
- package/stubs/ttyg/ttyg-stubs.js +7 -0
- package/stubs/yasgui/query-stubs.js +2 -2
- package/support/import-commands.js +28 -0
- package/support/repository-commands.js +10 -3
- package/support/security-command.js +49 -8
- package/support/user-commands.js +10 -2
- package/utils/html-util.js +21 -0
- /package/fixtures/{graphql-editor → queries}/default-query-response.json +0 -0
|
@@ -19,6 +19,12 @@ export class VisualGraphSteps {
|
|
|
19
19
|
cy.visit('/graphs-visualizations?uri=http:%2F%2Fwww.w3.org%2FTR%2F2003%2FPR-owl-guide-20031209%2Fwine%23Dry');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
static openNodeLabelGraph() {
|
|
23
|
+
cy.visit('/graphs-visualizations?uri=http:%2F%2Fexample.com%2Fnode1');
|
|
24
|
+
// Wait for at least one predicate to be displayed, to ensure that the visual graph is open and ready for testing.
|
|
25
|
+
VisualGraphSteps.getPredicates().should('contain', 'connectedTo');
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
static verifyUrl() {
|
|
23
29
|
cy.url().should('include', `${Cypress.config('baseUrl')}${VIEW_URL}`);
|
|
24
30
|
}
|
|
@@ -116,6 +122,14 @@ export class VisualGraphSteps {
|
|
|
116
122
|
return cy.get('.node-wrapper').should('be.visible');
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
static getNode(nodeId) {
|
|
126
|
+
return cy.get(`.node-wrapper[id="${nodeId}"]`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static getNodeLabel(nodeId) {
|
|
130
|
+
return this.getNode(nodeId).find('.node-label-body div');
|
|
131
|
+
}
|
|
132
|
+
|
|
119
133
|
static getPredicates() {
|
|
120
134
|
return cy.get('.predicate');
|
|
121
135
|
}
|
|
@@ -14,16 +14,32 @@ export class SavedQueriesDialog {
|
|
|
14
14
|
static selectSavedQueryByName(name) {
|
|
15
15
|
this.getSavedQueries().contains(name).click();
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
static getQueryByName(name) {
|
|
19
|
+
return this.getSavedQueries().contains(name).realHover();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getEditQueryButtonByName(name) {
|
|
23
|
+
return this.getQueryByName(name).closest('.saved-query').find('.edit-saved-query');
|
|
24
|
+
}
|
|
17
25
|
|
|
18
26
|
static editQueryByName(name) {
|
|
19
|
-
this.
|
|
27
|
+
this.getEditQueryButtonByName(name).click();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static getDeleteQueryButtonByName(name) {
|
|
31
|
+
return this.getQueryByName(name).closest('.saved-query').find('.delete-saved-query');
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
static deleteQueryByName(name) {
|
|
23
|
-
this.
|
|
35
|
+
this.getDeleteQueryButtonByName(name).click();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static getShareQueryButtonByName(name) {
|
|
39
|
+
return this.getQueryByName(name).closest('.saved-query').find('.share-saved-query');
|
|
24
40
|
}
|
|
25
41
|
|
|
26
42
|
static shareQueryByName(name) {
|
|
27
|
-
this.
|
|
43
|
+
this.getShareQueryButtonByName(name).click();
|
|
28
44
|
}
|
|
29
45
|
}
|
|
@@ -2,12 +2,12 @@ import {Stubs} from "./stubs";
|
|
|
2
2
|
|
|
3
3
|
export class GlobalOperationsStatusesStub extends Stubs {
|
|
4
4
|
static stubGlobalOperationsStatusesResponse(repositoryId, withDelay = 0) {
|
|
5
|
-
GlobalOperationsStatusesStub.stubQueryResponse(`/rest/monitor/${repositoryId}/operations`, '/monitoring/global-operation-statuses.json', 'backup-and-restore-response', withDelay);
|
|
5
|
+
GlobalOperationsStatusesStub.stubQueryResponse(`/rest/monitor/repository/${repositoryId}/operations`, '/monitoring/global-operation-statuses.json', 'backup-and-restore-response', withDelay);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
static stubNoOperationsResponse(repositoryId, withDelay = 0) {
|
|
9
9
|
GlobalOperationsStatusesStub.stubQueryResponse(
|
|
10
|
-
`/rest/monitor/${repositoryId}/operations`,
|
|
10
|
+
`/rest/monitor/repository/${repositoryId}/operations`,
|
|
11
11
|
'/monitoring/no-operations.json',
|
|
12
12
|
'backup-and-restore-response', withDelay);
|
|
13
13
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
export class GraphqlStubs {
|
|
2
|
+
static spyExportEndpointDefinition(repositoryId, endpointId) {
|
|
3
|
+
cy.intercept('GET', `/rest/repositories/${repositoryId}/graphql/manage/endpoints/${endpointId}/export`)
|
|
4
|
+
.as('export-endpoint-definition');
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
static stubGetEndpointsInfo(repositoryId, fixture = 'graphql-endpoints-info.json', delay = 0) {
|
|
8
|
+
cy.intercept('GET', `/rest/repositories/${repositoryId}/manage/graphql/endpoints`, {
|
|
9
|
+
fixture: `/graphql/endpoints/${fixture}`,
|
|
10
|
+
statusCode: 200,
|
|
11
|
+
delay: delay
|
|
12
|
+
}).as('get-endpoints-info');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static stubGetEndpointsInfoError(repositoryId) {
|
|
16
|
+
cy.intercept('GET', `/rest/repositories/${repositoryId}/graphql/manage/list`, {
|
|
17
|
+
statusCode: 500,
|
|
18
|
+
response: {
|
|
19
|
+
error: "Required request parameter 'query' for method parameter type String is not present"
|
|
20
|
+
}
|
|
21
|
+
}).as('get-endpoints-info-error');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static spySaveEndpointConfiguration(repositoryId, endpoint) {
|
|
25
|
+
cy.intercept('POST', `/rest/repositories/${repositoryId}/graphql/manage/endpoints/${endpoint}`).as('save-endpoint-configuration');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static stubSaveEndpointConfiguration(repositoryId, endpoint, delay = 0, shouldFail = false) {
|
|
29
|
+
cy.intercept('POST', `/rest/repositories/${repositoryId}/graphql/manage/endpoints/${endpoint}`, {
|
|
30
|
+
statusCode: shouldFail ? 400 : 200,
|
|
31
|
+
delay: delay
|
|
32
|
+
}).as('save-endpoint-configuration-failed');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const defaultHeaders = {
|
|
37
|
+
'api-timestamp': '123456789'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Utility to match a GraphQL mutation or query based on the operation name.
|
|
42
|
+
*
|
|
43
|
+
* @param {any} req - The request object.
|
|
44
|
+
* @param {string} operationName - The name of the GraphQL operation to match.
|
|
45
|
+
* @return {boolean} True if the request's operation name matches the provided name, otherwise false.
|
|
46
|
+
*/
|
|
47
|
+
const hasOperationName = (req, operationName) => {
|
|
48
|
+
const {body} = req;
|
|
49
|
+
return (
|
|
50
|
+
body.hasOwnProperty('operationName') && body.operationName === operationName
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Utility to check if a GraphQL request contains the specified variables.
|
|
56
|
+
*
|
|
57
|
+
* @param {any} req - The request object.
|
|
58
|
+
* @param {object} variables - The variables to match in the request.
|
|
59
|
+
* @return {boolean} True if the request contains the specified variables, otherwise false.
|
|
60
|
+
*/
|
|
61
|
+
const hasVariables = (req, variables) => {
|
|
62
|
+
const {body} = req;
|
|
63
|
+
if (body.hasOwnProperty('variables')) {
|
|
64
|
+
let sameVars = false;
|
|
65
|
+
Object.keys(variables).forEach((name) => {
|
|
66
|
+
if (Array.isArray(variables[name])) {
|
|
67
|
+
sameVars = body.variables[name] !== undefined && variables[name].toString() === body.variables[name].toString();
|
|
68
|
+
} else {
|
|
69
|
+
sameVars = body.variables[name] !== undefined && body.variables[name] === variables[name];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return sameVars;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Aliases a query request if its operation name matches the provided name.
|
|
79
|
+
*
|
|
80
|
+
* @param {any} req - The request object.
|
|
81
|
+
* @param {string} operationName - The name of the GraphQL query to alias.
|
|
82
|
+
*/
|
|
83
|
+
const aliasQuery = (req, operationName) => {
|
|
84
|
+
if (hasOperationName(req, operationName)) {
|
|
85
|
+
req.alias = operationName;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Stubs a GraphQL query request with a specified fixture, status code, and optional headers and delay.
|
|
91
|
+
*
|
|
92
|
+
* @param {any} req - The request object.
|
|
93
|
+
* @param {string} operationName - The name of the GraphQL query to stub.
|
|
94
|
+
* @param {any} fixture - The fixture to return as a response.
|
|
95
|
+
* @param {number} [statusCode=200] - The HTTP status code for the response.
|
|
96
|
+
* @param {number} [delay=0] - The delay in milliseconds before sending the response.
|
|
97
|
+
* @param {object} [headers={}] - Optional headers to include in the response.
|
|
98
|
+
*/
|
|
99
|
+
const stubQuery = (req, operationName, fixture, statusCode = 200, delay = 0, headers = {}) => {
|
|
100
|
+
if (hasOperationName(req, operationName)) {
|
|
101
|
+
const requestHeaders = Object.assign({}, defaultHeaders, headers);
|
|
102
|
+
req.alias = operationName;
|
|
103
|
+
req.reply({
|
|
104
|
+
statusCode,
|
|
105
|
+
body: fixture,
|
|
106
|
+
headers: requestHeaders,
|
|
107
|
+
delay
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Stubs a GraphQL query request with specific variables, using a fixture, delay, and optional headers.
|
|
114
|
+
*
|
|
115
|
+
* @param {any} req - The request object.
|
|
116
|
+
* @param {string} operationName - The name of the GraphQL query to stub.
|
|
117
|
+
* @param {object} variables - The variables to match in the request.
|
|
118
|
+
* @param {any} fixture - The fixture to return as a response.
|
|
119
|
+
* @param {number} [delay=0] - The delay in milliseconds before sending the response.
|
|
120
|
+
* @param {object} [headers={}] - Optional headers to include in the response.
|
|
121
|
+
*/
|
|
122
|
+
const stubQueryWithVariable = (req, operationName, variables, fixture, delay = 0, headers = {}) => {
|
|
123
|
+
if (hasOperationName(req, operationName) && hasVariables(req, variables)) {
|
|
124
|
+
const requestHeaders = Object.assign({}, defaultHeaders, headers);
|
|
125
|
+
req.alias = operationName;
|
|
126
|
+
const replyConfig = {
|
|
127
|
+
statusCode: 200, // default
|
|
128
|
+
fixture,
|
|
129
|
+
headers: requestHeaders,
|
|
130
|
+
delay
|
|
131
|
+
};
|
|
132
|
+
req.reply(replyConfig);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Aliases a mutation request if its operation name matches the provided name.
|
|
138
|
+
*
|
|
139
|
+
* @param {any} req - The request object.
|
|
140
|
+
* @param {string} operationName - The name of the GraphQL mutation to alias.
|
|
141
|
+
*/
|
|
142
|
+
const aliasMutation = (req, operationName) => {
|
|
143
|
+
if (hasOperationName(req, operationName)) {
|
|
144
|
+
req.alias = operationName;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
@@ -7,6 +7,10 @@ export class RepositoriesStubs extends Stubs {
|
|
|
7
7
|
RepositoriesStubs.stubGetQueryResponse('/rest/repositories/all', fixture, 'get-all-repositories', withDelay);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
static spyGetRepositories() {
|
|
11
|
+
cy.intercept('GET', '/rest/repositories/all').as('getRepositories');
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
static stubLocations(withDelay = 0) {
|
|
11
15
|
RepositoriesStubs.stubQueryResponse('/rest/locations', '/repositories/get-locations.json', 'get-locations', withDelay);
|
|
12
16
|
}
|
package/stubs/ttyg/ttyg-stubs.js
CHANGED
|
@@ -163,4 +163,11 @@ export class TTYGStubs extends Stubs {
|
|
|
163
163
|
statusCode: 200
|
|
164
164
|
}).as('explain-response');
|
|
165
165
|
}
|
|
166
|
+
|
|
167
|
+
static stubAutocompleteResponse(fixture = '/ttyg/autocomplete-response.json') {
|
|
168
|
+
cy.intercept('GET', '/rest/autocomplete/query?*', {
|
|
169
|
+
fixture,
|
|
170
|
+
statusCode: 200,
|
|
171
|
+
}).as('autocomplete-suggestions');
|
|
172
|
+
}
|
|
166
173
|
}
|
|
@@ -11,11 +11,11 @@ export class QueryStubs {
|
|
|
11
11
|
cy.intercept('GET', '/rest/monitor/query/count', {body: 0});
|
|
12
12
|
}
|
|
13
13
|
static stubDefaultQueryResponse(repositoryId, withDelay = 0) {
|
|
14
|
-
QueryStubs.stubQueryResponse(repositoryId, '/
|
|
14
|
+
QueryStubs.stubQueryResponse(repositoryId, '/queries/default-query-response.json', withDelay);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
static stubLongRunningQuery(repositoryId, delay = 3000) {
|
|
18
|
-
QueryStubs.stubQueryResponse(repositoryId, '/
|
|
18
|
+
QueryStubs.stubQueryResponse(repositoryId, '/queries/default-query-response.json', delay);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
static stubEmptyQueryResponse(repositoryId, withDelay = 0) {
|
|
@@ -5,6 +5,34 @@ const UPLOAD_URL = '/import/upload/';
|
|
|
5
5
|
const SERVER_URL = '/import/server/';
|
|
6
6
|
const POLL_INTERVAL = 200;
|
|
7
7
|
|
|
8
|
+
// Imports a graphql schema to the repository
|
|
9
|
+
Cypress.Commands.add('uploadGraphqlSchema', (repositoryId, schemaPath, schemaId ) => {
|
|
10
|
+
cy.fixture(schemaPath).then((schema) => {
|
|
11
|
+
cy.request({
|
|
12
|
+
method: 'POST',
|
|
13
|
+
url: `${REPOSITORIES_URL}${repositoryId}/graphql/manage/endpoints/import`,
|
|
14
|
+
headers: {'Content-type': 'text/yaml'},
|
|
15
|
+
body: schema
|
|
16
|
+
}).should((response) => expect(response.status).to.equal(200));
|
|
17
|
+
waitForGraphqlSchema(repositoryId, schemaId);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Waits for the schema import to finish
|
|
22
|
+
function waitForGraphqlSchema(repositoryId, schemaId) {
|
|
23
|
+
cy.request({
|
|
24
|
+
method: 'GET',
|
|
25
|
+
url: `${REPOSITORIES_URL}${repositoryId}/graphql/manage/endpoints/${schemaId}`
|
|
26
|
+
}).then((response) => {
|
|
27
|
+
// const importStatus = Cypress._.find(response.body, (importStatus) => importStatus.name === fileName);
|
|
28
|
+
if (response.status === 200 && response.body && response.body.id === schemaId) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
cy.wait(POLL_INTERVAL);
|
|
32
|
+
waitForGraphqlSchema(repositoryId, schemaId);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
8
36
|
Cypress.Commands.add('importRDFTextSnippet', (repositoryId, rdf, importSettings = {}) => {
|
|
9
37
|
const importData = Cypress._.defaultsDeep(importSettings, snippetImportTemplate);
|
|
10
38
|
importData.data = rdf;
|
|
@@ -18,7 +18,7 @@ Cypress.Commands.add('createRepository', (options = {}) => {
|
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
Cypress.Commands.add('deleteRepository', (id) => {
|
|
21
|
+
Cypress.Commands.add('deleteRepository', (id, secured = false) => {
|
|
22
22
|
// Note: Going through /rest/repositories because it would not fail if the repo is missing
|
|
23
23
|
const url = REPOSITORIES_URL + id;
|
|
24
24
|
|
|
@@ -26,10 +26,17 @@ Cypress.Commands.add('deleteRepository', (id) => {
|
|
|
26
26
|
// if a test completes too fast and the tested view was about to load something
|
|
27
27
|
// that needs the just deleted repo.
|
|
28
28
|
cy.visit('/', {failOnStatusCode: false});
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
let headers = {'Content-Type': 'application/json'};
|
|
30
|
+
if (secured) {
|
|
31
|
+
const authHeader = Cypress.env('adminToken');
|
|
32
|
+
headers = {...headers,
|
|
33
|
+
'Authorization': authHeader
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return cy.request({
|
|
31
37
|
method: 'DELETE',
|
|
32
38
|
url: url,
|
|
39
|
+
headers,
|
|
33
40
|
// Prevent Cypress from failing the test on non-2xx status codes
|
|
34
41
|
failOnStatusCode: false
|
|
35
42
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Cypress.Commands.add('switchOnSecurity', () => {
|
|
2
|
-
cy.request({
|
|
2
|
+
return cy.request({
|
|
3
3
|
method: 'POST',
|
|
4
4
|
url: `/rest/security`,
|
|
5
5
|
body: 'true',
|
|
@@ -11,15 +11,56 @@ Cypress.Commands.add('switchOnSecurity', () => {
|
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
Cypress.Commands.add('
|
|
15
|
-
cy.request({
|
|
14
|
+
Cypress.Commands.add('loginAsAdmin', () => {
|
|
15
|
+
return cy.request({
|
|
16
16
|
method: 'POST',
|
|
17
|
-
url:
|
|
18
|
-
body:
|
|
17
|
+
url: '/rest/login',
|
|
18
|
+
body: {
|
|
19
|
+
username: 'admin',
|
|
20
|
+
password: 'root',
|
|
21
|
+
},
|
|
19
22
|
headers: {
|
|
20
|
-
'Content-Type': 'application/json'
|
|
23
|
+
'Content-Type': 'application/json',
|
|
21
24
|
},
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
failOnStatusCode: true,
|
|
26
|
+
}).then((response) => {
|
|
27
|
+
const authHeader = response.headers['authorization'];
|
|
28
|
+
Cypress.env('adminToken', authHeader);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
Cypress.Commands.add('switchOffSecurity', (secured = false) => {
|
|
33
|
+
let headers = {'Content-Type': 'application/json'};
|
|
34
|
+
if (secured) {
|
|
35
|
+
const authHeader = Cypress.env('adminToken');
|
|
36
|
+
headers = {...headers,
|
|
37
|
+
'Authorization': authHeader
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return cy.request({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
url: '/rest/security',
|
|
43
|
+
body: 'false',
|
|
44
|
+
headers,
|
|
45
|
+
failOnStatusCode: true,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
Cypress.Commands.add('switchOffFreeAccess', (secured = false) => {
|
|
50
|
+
let headers = {'Content-Type': 'application/json'};
|
|
51
|
+
if (secured) {
|
|
52
|
+
const authHeader = Cypress.env('adminToken');
|
|
53
|
+
headers = {...headers,
|
|
54
|
+
'Authorization': authHeader
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return cy.request({
|
|
58
|
+
method: 'POST',
|
|
59
|
+
url: '/rest/security/free-access',
|
|
60
|
+
body: {
|
|
61
|
+
'enabled': false
|
|
62
|
+
},
|
|
63
|
+
headers,
|
|
64
|
+
failOnStatusCode: true,
|
|
24
65
|
});
|
|
25
66
|
});
|
package/support/user-commands.js
CHANGED
|
@@ -21,10 +21,18 @@ Cypress.Commands.add('createUser', (options = {}) => {
|
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
Cypress.Commands.add('deleteUser', (username = {}) => {
|
|
25
|
-
|
|
24
|
+
Cypress.Commands.add('deleteUser', (username = {}, secured = false) => {
|
|
25
|
+
let headers = {'Content-Type': 'application/json'};
|
|
26
|
+
if (secured) {
|
|
27
|
+
const authHeader = Cypress.env('adminToken');
|
|
28
|
+
headers = {...headers,
|
|
29
|
+
'Authorization': authHeader
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return cy.request({
|
|
26
33
|
method: 'DELETE',
|
|
27
34
|
url: `/rest/security/users/${username}`,
|
|
35
|
+
headers,
|
|
28
36
|
// Prevent Cypress from failing the test on non-2xx status codes
|
|
29
37
|
failOnStatusCode: false
|
|
30
38
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class HtmlUtil {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Verifies that an element's content is truncated with an ellipsis by checking that
|
|
5
|
+
* the scroll width of the element is greater than its offset width.
|
|
6
|
+
* This is used to assert that the element's text is overflowing and is being clipped with ellipsis.
|
|
7
|
+
*
|
|
8
|
+
* @param {Cypress.Chainable<JQuery<HTMLElement>>} element - The Cypress chainable element to check.
|
|
9
|
+
* @throws {AssertionError} If the element's content is not truncated with ellipsis.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Example usage in a test
|
|
13
|
+
* HtmlUtil.verifyEllipsis(cy.get('.node-wrapper'));
|
|
14
|
+
*/
|
|
15
|
+
static verifyEllipsis(element) {
|
|
16
|
+
element.should(($el) => {
|
|
17
|
+
const el = $el[0];
|
|
18
|
+
expect(el.scrollWidth).to.be.greaterThan(el.offsetWidth);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
File without changes
|