graphdb-workbench-tests 3.3.2 → 3.3.3-RC1

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.
@@ -46,6 +46,7 @@ describe('Edit TTYG agent guide', () => {
46
46
  TTYGStubs.stubAgentDefaultsGet();
47
47
  TTYGStubs.stubChatGet();
48
48
  TTYGStubs.stubAgentEdit();
49
+ RepositoriesStubs.stubRepositoryModel(repositoryId);
49
50
 
50
51
  GuideDialogSteps.assertDialogWithTitleIsVisible('Edit an agent — 1/18');
51
52
  GuideDialogSteps.assertDialogWithContentIsVisible('Click on the Lab menu.');
@@ -3,6 +3,8 @@ import {TTYGStubs} from "../../stubs/ttyg/ttyg-stubs";
3
3
  import {TTYGViewSteps} from "../../steps/ttyg/ttyg-view-steps";
4
4
  import {ChatPanelSteps} from "../../steps/ttyg/chat-panel-steps";
5
5
  import {ApplicationSteps} from "../../steps/application-steps";
6
+ import {TtygAgentSettingsModalSteps} from '../../steps/ttyg/ttyg-agent-settings-modal.steps.js';
7
+ import {SparqlStubs} from '../../stubs/sparql-stubs.js';
6
8
 
7
9
  describe('Ttyg ChatPanel', () => {
8
10
 
@@ -147,6 +149,13 @@ describe('Ttyg ChatPanel', () => {
147
149
  TTYGViewSteps.clickOnExplainResponse(0);
148
150
  // Then I expect the hint message to not exist (it should only exist for the last 'Explain' response).
149
151
  TTYGViewSteps.getHowDeliverAnswerButton().should('not.exist');
152
+ // When I click on the open in sparql editor button for the explain response
153
+ SparqlStubs.spyAddKnownPrefixes();
154
+ TtygAgentSettingsModalSteps.clickOpenQueryInSparqlEditor(0);
155
+ // Then I expect a request for appending prefixes to be sent with the correct query.
156
+ cy.wait('@addKnownPrefixes').its('request.body').then((body) => {
157
+ expect(body).to.contain('SELECT ?name ?height WHERE {\n ?character voc:height ?height;\n rdfs:label ?name.\n FILTER(?name = "Luke Skywalker" || ?name = "Leia Organa")\n}');
158
+ });
150
159
 
151
160
  // Then when I click on explain response button on the second answer
152
161
  TTYGStubs.stubExplainResponse('/ttyg/chats/explain-response-2.json');
@@ -17,6 +17,7 @@ describe('TTYG clone an agent', () => {
17
17
  TTYGStubs.stubAgentListGet();
18
18
  TTYGStubs.stubChatsListGet();
19
19
  TTYGStubs.stubChatGet();
20
+ RepositoriesStubs.stubRepositoryModel(repositoryId);
20
21
  // Given I have opened the ttyg page
21
22
  TTYGViewSteps.visit();
22
23
  cy.wait('@get-all-repositories');
@@ -45,6 +46,7 @@ describe('TTYG clone an agent', () => {
45
46
  TTYGStubs.stubAgentCreate();
46
47
  TtygAgentSettingsModalSteps.saveAgent();
47
48
  cy.wait('@create-agent').then((interception) => {
49
+ // eslint-disable-next-line no-undef
48
50
  assert.deepEqual(interception.request.body, {
49
51
  "id": "asst_gAPcrHQQ9ZIxD5eXWH2BNFfo",
50
52
  "name": "agent-11",
@@ -72,4 +74,24 @@ describe('TTYG clone an agent', () => {
72
74
  });
73
75
  });
74
76
  });
77
+
78
+ it('should not be able to clone an agent if an extraction method is selected but the precondition has failed', () => {
79
+ TTYGStubs.stubAgentListGet();
80
+ TTYGStubs.stubChatsListGet();
81
+ TTYGStubs.stubChatGet();
82
+ RepositoriesStubs.stubFtsSearchDisabled(repositoryId);
83
+
84
+ // GIVEN: I have opened the TTYG page
85
+ TTYGViewSteps.visit();
86
+ cy.wait('@get-all-repositories');
87
+ cy.wait('@get-agent-list');
88
+ cy.wait('@get-chat');
89
+
90
+ // WHEN: I try to clone an agent that has the FTS extraction method enabled, but FTS is disabled in the repository
91
+ TTYGViewSteps.expandAgentsSidebar();
92
+ TTYGViewSteps.triggerCloneAgentActionMenu(0);
93
+
94
+ // THEN: The Save Agent button should be disabled
95
+ TtygAgentSettingsModalSteps.getSaveAgentButton().should('be.disabled');
96
+ });
75
97
  });
@@ -12,6 +12,7 @@ describe('TTYG edit an agent', () => {
12
12
  beforeEach(() => {
13
13
  RepositoriesStubs.stubRepositories(0, '/repositories/get-ttyg-repositories.json');
14
14
  RepositoriesStubs.stubBaseEndpoints(repositoryId);
15
+ RepositoriesStubs.stubRepositoryModel(repositoryId);
15
16
  cy.presetRepository(repositoryId);
16
17
  TTYGStubs.stubAgentDefaultsGet();
17
18
  });
@@ -49,6 +50,22 @@ describe('TTYG edit an agent', () => {
49
50
  ToasterSteps.verifySuccess('The agent \'agent-1\' was saved successfully.');
50
51
  });
51
52
 
53
+ it('should not be able to edit an agent if an extraction method is selected but the precondition has failed', () => {
54
+ TTYGStubs.stubChatsListGet();
55
+ TTYGStubs.stubAgentListGet();
56
+ TTYGStubs.stubChatGet();
57
+ RepositoriesStubs.stubFtsSearchDisabled(repositoryId);
58
+ // GIVEN: I have opened the TTYG page
59
+ TTYGViewSteps.visit();
60
+ cy.wait('@get-chat-list');
61
+ cy.wait('@get-agent-list');
62
+ cy.wait('@get-chat');
63
+ // WHEN: I try to edit an agent that has the FTS extraction method enabled, but FTS is disabled in the repository
64
+ TTYGViewSteps.openAgentSettingsModalForAgent(0);
65
+
66
+ // THEN: The Save Agent button should be disabled
67
+ TtygAgentSettingsModalSteps.getSaveAgentButton().should('be.disabled');
68
+ });
52
69
 
53
70
  it('should be able to edit Autocomplete extraction method option', {
54
71
  retries: {
@@ -4,54 +4,8 @@
4
4
  "queryMethods": [
5
5
  {
6
6
  "name": "sparql_query",
7
- "rawQuery": "SELECT ?character ?name ?height WHERE {\n ?character a voc:Character;\n rdfs:label ?name;\n voc:height ?height.\n FILTER(?name = \"Luke Skywalker\" || ?name = \"Leia Organa\")\n}",
8
- "query": "SELECT ?character ?name ?height WHERE {\n ?character a voc:Character;\n rdfs:label ?name;\n voc:height ?height.\n FILTER(?name = \"Luke Skywalker\" || ?name = \"Leia Organa\")\n}",
9
- "queryType": "sparql",
10
- "errorOutput": "Error: org.eclipse.rdf4j.query.MalformedQueryException: org.eclipse.rdf4j.query.parser.sparql.ast.VisitorException: QName 'voc:Character' uses an undefined prefix"
11
- }, {
12
- "name": "retrieval_search",
13
- "rawQuery": "{\"queries\":[{\"query\":\"pilots that work with Luke Skywalker\",\"filter\":{\"document_id\":\"https://swapi.co/resource/human/1\"},\"top_k\":3}]}",
14
- "query": "{\n \"queries\" : [ {\n \"query\" : \"pilots that work with Luke Skywalker\",\n \"filter\" : {\n \"document_id\" : \"https://swapi.co/resource/human/1\"\n },\n \"top_k\" : 3\n } ]\n}",
15
- "queryType": "json",
16
- "errorOutput": null
17
- },
18
- {
19
- "name": "iri_discovery",
20
- "rawQuery": "Luke Skywalker",
21
- "query": "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\nPREFIX onto: <http://www.ontotext.com/>\nSELECT ?label ?iri {\n ?label onto:fts ('''Luke~ Skywalker~''' '*') .\n ?iri rdfs:label|skos:prefLabel ?label .\n}",
22
- "queryType": "sparql",
23
- "errorOutput": null
24
- },
25
- {
26
- "name": "sparql_query",
27
- "rawQuery": "SELECT ?height WHERE {\n <https://swapi.co/resource/human/1> voc:height ?height.\n}",
28
- "query": "SELECT ?height WHERE {\n <https://swapi.co/resource/human/1> voc:height ?height.\n}",
29
- "queryType": "sparql",
30
- "errorOutput": "Error: org.eclipse.rdf4j.query.MalformedQueryException: org.eclipse.rdf4j.query.parser.sparql.ast.VisitorException: QName 'voc:height' uses an undefined prefix"
31
- },
32
- {
33
- "name": "sparql_query",
34
- "rawQuery": "PREFIX voc: <https://swapi.co/vocabulary/>\nSELECT ?name ?height WHERE {\n ?character voc:height ?height;\n rdfs:label ?name.\n FILTER(?name = \"Luke Skywalker\" || ?name = \"Leia Organa\")\n}",
35
- "query": "PREFIX voc: <https://swapi.co/vocabulary/>\nSELECT ?name ?height WHERE {\n ?character voc:height ?height;\n rdfs:label ?name.\n FILTER(?name = \"Luke Skywalker\" || ?name = \"Leia Organa\")\n}",
36
- "queryType": "sparql",
37
- "errorOutput": null
38
- },
39
- {
40
- "name": "fts_search",
41
- "rawQuery": "Second Luke",
42
- "query": "PREFIX onto: <http://www.ontotext.com/>\nDESCRIBE ?iri {\n\t?x onto:fts \\'\\'\\'Second Luke\\'\\'\\' .\n\t{\n\t\t?x ?p ?iri .\n\t} union {\n\t\t?iri ?p ?x .\n\t}\n}",
43
- "queryType": "sparql",
44
- "errorOutput": null
45
- }, {
46
- "name": "similarity_search",
47
- "rawQuery": "Second Luke",
48
- "query": "PREFIX onto: <http://www.ontotext.com/>\nDESCRIBE ?iri {\n\t?x onto:fts \\'\\'\\'Second Luke\\'\\'\\' .\n\t{\n\t\t?x ?p ?iri .\n\t} union {\n\t\t?iri ?p ?x .\n\t}\n}",
49
- "queryType": "sparql",
50
- "errorOutput": null
51
- }, {
52
- "name": "iri_discovery",
53
- "rawQuery": "Luke Skywalker",
54
- "query": "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\nPREFIX onto: <http://www.ontotext.com/>\nSELECT ?label ?iri {\n ?label onto:fts ('''Luke~ Skywalker~''' '*') .\n ?iri rdfs:label|skos:prefLabel ?label .\n}",
7
+ "rawQuery": "SELECT ?name ?height WHERE {\n ?character voc:height ?height;\n rdfs:label ?name.\n FILTER(?name = \"Luke Skywalker\" || ?name = \"Leia Organa\")\n}",
8
+ "query": "SELECT ?name ?height WHERE {\n ?character voc:height ?height;\n rdfs:label ?name.\n FILTER(?name = \"Luke Skywalker\" || ?name = \"Leia Organa\")\n}",
55
9
  "queryType": "sparql",
56
10
  "errorOutput": null
57
11
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "3.3.2",
3
+ "version": "3.3.3-RC1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "graphdb-workbench-tests",
9
- "version": "3.3.2",
9
+ "version": "3.3.3-RC1",
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
12
  "@bahmutov/cypress-code-coverage": "^2.7.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "3.3.2",
3
+ "version": "3.3.3-RC1",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,7 @@
1
1
  import {Stubs} from '../stubs';
2
2
  import {REPOSITORIES_URL} from '../../support/repository-commands';
3
3
  import {GlobalOperationsStatusesStub} from '../global-operations-statuses-stub.js';
4
+ import repoTemplate from "../../fixtures/repo-template.json";
4
5
 
5
6
  export class RepositoriesStubs extends Stubs {
6
7
  static stubRepositories(withDelay = 0, fixture = '/repositories/get-repositories.json') {
@@ -225,4 +226,25 @@ export class RepositoriesStubs extends Stubs {
225
226
  RepositoriesStubs.stubAutocomplete();
226
227
  GlobalOperationsStatusesStub.stubNoOperationsResponse('starwars');
227
228
  }
229
+
230
+ static stubRepositoryModel(repositoryId, options = {}) {
231
+ const body = Cypress._.defaultsDeep(
232
+ { id: repositoryId, ...options },
233
+ repoTemplate
234
+ );
235
+ cy.intercept('GET', `/rest/repositories/${repositoryId}`, {
236
+ statusCode: 200,
237
+ body
238
+ }).as('repository-model');
239
+ }
240
+
241
+ static stubFtsSearchDisabled(repositoryId) {
242
+ RepositoriesStubs.stubRepositoryModel(repositoryId, {
243
+ params: {
244
+ enableFtsIndex: {
245
+ value: 'false'
246
+ }
247
+ }
248
+ });
249
+ }
228
250
  }
@@ -0,0 +1,10 @@
1
+ import {Stubs} from './stubs.js';
2
+
3
+ export class SparqlStubs extends Stubs {
4
+ static spyAddKnownPrefixes() {
5
+ cy.intercept('/rest/sparql/add-known-prefixes', {
6
+ method: 'POST',
7
+ body: 'PREFIX voc: <https://swapi.co/vocabulary/> SELECT ?name ?height WHERE { ?character voc:height ?height; rdfs:label ?name. FILTER(?name = "Luke Skywalker" || ?name = "Leia Organa") }'
8
+ }).as('addKnownPrefixes')
9
+ }
10
+ }