You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by ki...@apache.org on 2023/04/07 11:10:22 UTC

[jena] branch main updated (7dc6f97fda -> dc8d04b1ae)

This is an automated email from the ASF dual-hosted git repository.

kinow pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git


    from 7dc6f97fda Merge pull request #1831 from afs/fuseki-templates
     new 17c9205835 GH-1679: edit not working on non root g-sp
     new dc8d04b1ae Fix e2e test command and code (got out of date with a recent change, plus cypress...)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 jena-fuseki2/jena-fuseki-ui/cypress.config.js      | 16 ++++--
 jena-fuseki2/jena-fuseki-ui/package.json           |  6 +-
 .../jena-fuseki-ui/src/services/fuseki.service.js  | 40 +++++++++++--
 .../src/services/mock/json-server.js               | 17 ++++--
 .../jena-fuseki-ui/src/views/dataset/Edit.vue      | 12 +++-
 .../jena-fuseki-ui/tests/e2e/specs/datasets.cy.js  | 65 +++++++++++++---------
 .../jena-fuseki-ui/tests/e2e/specs/query.cy.js     |  4 +-
 .../tests/unit/services/fuseki.service.spec.js     |  9 ++-
 jena-fuseki2/jena-fuseki-ui/vite.config.js         |  8 ++-
 9 files changed, 124 insertions(+), 53 deletions(-)


[jena] 02/02: Fix e2e test command and code (got out of date with a recent change, plus cypress...)

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git

commit dc8d04b1ae5e1ac94e2d4456ea89de2b1d3e418e
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Sun Mar 26 12:32:06 2023 +0200

    Fix e2e test command and code (got out of date with a recent change, plus cypress...)
---
 jena-fuseki2/jena-fuseki-ui/cypress.config.js      | 16 ++++--
 jena-fuseki2/jena-fuseki-ui/package.json           |  6 +-
 .../src/services/mock/json-server.js               | 17 ++++--
 .../jena-fuseki-ui/tests/e2e/specs/datasets.cy.js  | 65 +++++++++++++---------
 .../jena-fuseki-ui/tests/e2e/specs/query.cy.js     |  4 +-
 jena-fuseki2/jena-fuseki-ui/vite.config.js         |  8 ++-
 6 files changed, 72 insertions(+), 44 deletions(-)

diff --git a/jena-fuseki2/jena-fuseki-ui/cypress.config.js b/jena-fuseki2/jena-fuseki-ui/cypress.config.js
index eea2e95751..82a7e8f6ee 100644
--- a/jena-fuseki2/jena-fuseki-ui/cypress.config.js
+++ b/jena-fuseki2/jena-fuseki-ui/cypress.config.js
@@ -21,11 +21,11 @@ const vitePreprocessor = require('cypress-vite')
 module.exports = defineConfig({
   video: false,
   defaultCommandTimeout: 20000,
-  execTimeout: 15000,
-  taskTimeout: 15000,
-  pageLoadTimeout: 15000,
-  requestTimeout: 7500,
-  responseTimeout: 7500,
+  execTimeout: 30000,
+  taskTimeout: 30000,
+  pageLoadTimeout: 30000,
+  requestTimeout: 10000,
+  responseTimeout: 10000,
 
   e2e: {
     baseUrl: 'http://localhost:' + (process.env.PORT || 8080),
@@ -42,7 +42,11 @@ module.exports = defineConfig({
 
   env: {
     codeCoverage: {
-      exclude: 'cypress/**/*.*',
+      exclude: [
+        'src/services/mock/**/*.*',
+        'cypress/**/*.*',
+        'tests/**/*.*'
+      ],
     },
   },
 })
diff --git a/jena-fuseki2/jena-fuseki-ui/package.json b/jena-fuseki2/jena-fuseki-ui/package.json
index a99891c099..78b82195d2 100644
--- a/jena-fuseki2/jena-fuseki-ui/package.json
+++ b/jena-fuseki2/jena-fuseki-ui/package.json
@@ -10,12 +10,12 @@
     "serve": "vite preview",
     "build": "vite build",
     "test:unit": "vitest run --environment jsdom",
-    "test:e2e": "concurrently --names 'SERVER,CLIENT,TESTS' --prefix-colors 'yellow,blue,green' --success 'first' --kill-others 'yarn run serve:fuseki' 'yarn wait-on http://localhost:${FUSEKI_PORT}/ping && yarn run dev' 'yarn wait-on http-get://localhost:${PORT}/index.html && cypress run ${0}'",
+    "test:e2e": "cross-env FUSEKI_PORT=\"${FUSEKI_PORT:=3030}\" PORT=\"${PORT:=8080}\" concurrently --names 'SERVER,CLIENT,TESTS' --prefix-colors 'yellow,blue,green' --success 'first' --kill-others 'yarn run serve:fuseki' 'yarn wait-on http://localhost:${FUSEKI_PORT}/$/ping && yarn run dev' 'yarn wait-on http-get://localhost:${PORT}/index.html && cypress run $@'",
     "lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
-    "coverage:unit": "yarn run test:unit -- --coverage",
+    "coverage:unit": "yarn run test:unit --coverage",
     "coverage:e2e": "cross-env-shell CYPRESS_COVERAGE=true yarn run test:e2e",
     "serve:fuseki": "nodemon src/services/mock/json-server.js",
-    "serve:offline": "cross-env FUSEKI_PORT=\"${FUSEKI_PORT:=3030}\" PORT=\"${PORT:=8080}\" concurrently --names 'SERVER,CLIENT' --prefix-colors 'yellow,blue' --success 'first' --kill-others 'yarn run serve:fuseki' 'yarn wait-on http://localhost:${FUSEKI_PORT}/ping && yarn run dev'"
+    "serve:offline": "cross-env FUSEKI_PORT=\"${FUSEKI_PORT:=3030}\" PORT=\"${PORT:=8080}\" concurrently --names 'SERVER,CLIENT' --prefix-colors 'yellow,blue' --success 'first' --kill-others 'yarn run serve:fuseki' 'yarn wait-on http://localhost:${FUSEKI_PORT}/$/ping && yarn run dev'"
   },
   "dependencies": {
     "@fortawesome/fontawesome-svg-core": "^6.2.0",
diff --git a/jena-fuseki2/jena-fuseki-ui/src/services/mock/json-server.js b/jena-fuseki2/jena-fuseki-ui/src/services/mock/json-server.js
index 0733a96e8d..1bc021bac7 100644
--- a/jena-fuseki2/jena-fuseki-ui/src/services/mock/json-server.js
+++ b/jena-fuseki2/jena-fuseki-ui/src/services/mock/json-server.js
@@ -37,6 +37,8 @@ const startTime = new Date()
 
 // Add custom routes before JSON Server router
 
+server.get('/index.html', (req, res) => res.jsonp(''))
+
 // GET SERVER INFO
 server.get('/\\$/server', (req, res) => {
   res.jsonp({
@@ -244,16 +246,19 @@ server.get('/:datasetName/sparql', sparqlCallback)
 server.post('/:datasetName/sparql', sparqlCallback)
 
 // GRAPH
-server.get('/:datasetName', (req, res) => {
-  res
-    .status(200)
-    .set('Content-Type', 'text/turtle')
-    .send(`@prefix :      <https://example.org/book/> .
+const dataContent = `@prefix :      <https://example.org/book/> .
 @prefix dc:    <https://purl.org/dc/elements/1.1/> .
 @prefix ns:    <https://example.org/ns#> .
 @prefix vcard: <https://www.w3.org/2001/vcard-rdf/3.0#> .
 
-:book4  dc:title  "Harry Potter and the Goblet of Fire" .`)
+:book4  dc:title  "Harry Potter and the Goblet of Fire" .`
+
+// This gets called when you count the graphs
+server.get('/:datasetName/data', (req, res) => {
+  res
+    .status(200)
+    .set('Content-Type', 'text/turtle')
+    .send(dataContent)
 })
 
 // PING
diff --git a/jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/datasets.cy.js b/jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/datasets.cy.js
index 2d9582c0ee..6009103025 100644
--- a/jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/datasets.cy.js
+++ b/jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/datasets.cy.js
@@ -22,31 +22,41 @@
  * add new datasets. So we also cover parts of the Manage view.
  */
 describe('datasets', () => {
-  it('Visits datasets page, also the application landing-page', () => {
-    cy.visit('/')
-    cy
-      .contains('Loading')
-      .should('not.exist')
-    cy
-      .get('h2.text-center')
-      .contains('Apache Jena Fuseki')
-    cy
-      .get('tr.jena-table-empty')
-      .contains('No datasets created')
-  })
-  it('Filters without any data', () => {
-    cy.visit('/')
-    cy
-      .contains('Loading')
-      .should('not.exist')
-    cy
-      .get('#filterInput')
-      .type('pumpkin')
-    cy
-      .get('tr.jena-table-empty-filtered')
-      .contains('No datasets found')
+  describe('without any datasets', () => {
+    before(() => {
+      // Special endpoint that clears the datasets data.
+      cy.request('/tests/reset')
+    })
+    after(() => {
+      // Special endpoint that clears the datasets data.
+      cy.request('/tests/reset')
+    })
+    it('Visits datasets page, also the application landing-page', () => {
+      cy.visit('/')
+      cy
+        .contains('Loading')
+        .should('not.exist')
+      cy
+        .get('h2.text-center')
+        .contains('Apache Jena Fuseki')
+      cy
+        .get('tr.jena-table-empty')
+        .contains('No datasets created')
+    })
+    it('Filters without any data', () => {
+      cy.visit('/')
+      cy
+        .contains('Loading')
+        .should('not.exist')
+      cy
+        .get('#filterInput')
+        .type('pumpkin')
+      cy
+        .get('tr.jena-table-empty-filtered')
+        .contains('No datasets found')
+    })
   })
-  describe('After creating new datasets', () => {
+  describe('after creating new datasets', () => {
     before(() => {
       // Special endpoint that clears the datasets data.
       cy.request('/tests/reset')
@@ -78,7 +88,10 @@ describe('datasets', () => {
     })
     it('Edits the graph', () => {
       cy.visit('/#/dataset/a/edit')
-      cy.intercept('/a*').as('getGraph')
+      cy.intercept({
+        method: 'GET',
+        url: '/a/data*'
+      }).as('getGraph')
       cy
         .contains('Loading')
         .should('not.exist')
@@ -117,7 +130,7 @@ describe('datasets', () => {
         .eq(0)
         .find('a')
         .first()
-        .click()
+        .click({ force: true })
       cy.wait('@getGraph')
       cy
         .get('.CodeMirror-code')
diff --git a/jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/query.cy.js b/jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/query.cy.js
index a64171b9e3..b73c54569c 100644
--- a/jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/query.cy.js
+++ b/jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/query.cy.js
@@ -19,7 +19,7 @@
  * Tests the Query view and YASGUI & family components.
  */
 describe('Query', () => {
-  before(() => {
+  beforeEach(() => {
     // Special endpoint that clears the datasets data.
     cy.request('/tests/reset')
     // Create a sample dataset.
@@ -41,7 +41,7 @@ describe('Query', () => {
           .should('be.visible')
       })
   })
-  after(() => {
+  afterEach(() => {
     // Special endpoint that clears the datasets data.
     cy.request('/tests/reset')
   })
diff --git a/jena-fuseki2/jena-fuseki-ui/vite.config.js b/jena-fuseki2/jena-fuseki-ui/vite.config.js
index 7e5cb4afee..8e6142bf40 100644
--- a/jena-fuseki2/jena-fuseki-ui/vite.config.js
+++ b/jena-fuseki2/jena-fuseki-ui/vite.config.js
@@ -26,7 +26,12 @@ export default defineConfig({
     vue(),
     istanbul({
       include: "src/*",
-      exclude: ["node_modules"],
+      exclude: [
+        "node_modules",
+        "tests",
+        "coverage",
+        "src/services/mock/*"
+      ],
       extension: [".js", ".jsx", ".ts", ".vue"],
       requireEnv: true,
       cypress: true
@@ -68,6 +73,7 @@ export default defineConfig({
           // or that are requesting /node_modules/ (dev Vite/Vue/JS modules).
           const sendToUI =
             req.method !== 'POST' &&
+            req.url.indexOf('tests/reset') < 0 &&
             (
               (req.hasOwnProperty('originalUrl') && req.originalUrl.includes('node_modules')) ||
               (


[jena] 01/02: GH-1679: edit not working on non root g-sp

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git

commit 17c9205835dd1b94f07ec26dfa26fad7b1d779a8
Author: Simon Bin <sb...@informatik.uni-leipzig.de>
AuthorDate: Fri Dec 16 00:42:49 2022 +0100

    GH-1679: edit not working on non root g-sp
---
 .../jena-fuseki-ui/src/services/fuseki.service.js  | 40 +++++++++++++++++++---
 .../jena-fuseki-ui/src/views/dataset/Edit.vue      | 12 +++++--
 .../tests/unit/services/fuseki.service.spec.js     |  9 +++--
 3 files changed, 52 insertions(+), 9 deletions(-)

diff --git a/jena-fuseki2/jena-fuseki-ui/src/services/fuseki.service.js b/jena-fuseki2/jena-fuseki-ui/src/services/fuseki.service.js
index 4183991deb..a090ec17f4 100644
--- a/jena-fuseki2/jena-fuseki-ui/src/services/fuseki.service.js
+++ b/jena-fuseki2/jena-fuseki-ui/src/services/fuseki.service.js
@@ -181,9 +181,31 @@ class FusekiService {
     return results
   }
 
-  async fetchGraph (datasetName, graphName) {
+  /**
+   * Get the data endpoint out of a list of server endpoints.
+   *
+   * For now we are simply returning the first non-empty, but that
+   * may change at some point.
+   *
+   * @private
+   * @param {string[]} serverEndpoints - list of server endpoints in the dataset (can be an empty list).
+   */
+  getDataEndpoint(serverEndpoints) {
+    return serverEndpoints.find(endpoint => endpoint !== '') || ''
+  }
+
+  /**
+   * Fetch a graph.
+   * @param {string} datasetName - Jena dataset name.
+   * @param {string[]} serverEndpoints - list of server endpoints in the dataset (can be an empty list).
+   * @param {string} graphName - name of the graph being accessed.
+   * @return {Promise<AxiosResponse<any>>}
+   */
+  async fetchGraph (datasetName, serverEndpoints, graphName) {
+    const dataEndpoint = this.getDataEndpoint(serverEndpoints)
+    const urlPart = `${datasetName}/${dataEndpoint}`
     return await axios
-      .get(this.getFusekiUrl(`/${datasetName}`), {
+      .get(this.getFusekiUrl(urlPart), {
         params: {
           graph: graphName
         },
@@ -193,9 +215,19 @@ class FusekiService {
       })
   }
 
-  async saveGraph (datasetName, graphName, code) {
+  /**
+   * Save a graph.
+   * @param {string} datasetName - Jena dataset name.
+   * @param {string[]} serverEndpoints - list of server endpoints in the dataset (can be an empty list).
+   * @param {string} graphName - name of the graph being accessed.
+   * @param {string} code - graph content.
+   * @return {Promise<AxiosResponse<any>>}
+   */
+  async saveGraph (datasetName, serverEndpoints, graphName, code) {
+    const dataEndpoint = this.getDataEndpoint(serverEndpoints)
+    const urlPart = `${datasetName}/${dataEndpoint}`
     return await axios
-      .put(this.getFusekiUrl(`/${datasetName}`), code, {
+      .put(this.getFusekiUrl(urlPart), code, {
         params: {
           graph: graphName
         },
diff --git a/jena-fuseki2/jena-fuseki-ui/src/views/dataset/Edit.vue b/jena-fuseki2/jena-fuseki-ui/src/views/dataset/Edit.vue
index e5458e1515..8dde59f7af 100644
--- a/jena-fuseki2/jena-fuseki-ui/src/views/dataset/Edit.vue
+++ b/jena-fuseki2/jena-fuseki-ui/src/views/dataset/Edit.vue
@@ -261,7 +261,11 @@ export default {
       this.loadingGraph = true
       this.selectedGraph = graphName
       try {
-        const result = await this.$fusekiService.fetchGraph(this.datasetName, graphName)
+        const dataEndpoint = this.services['gsp-rw']['srv.endpoints'].find(endpoint => endpoint !== '') || ''
+        const result = await this.$fusekiService.fetchGraph(
+          this.datasetName,
+          this.services['gsp-rw']['srv.endpoints'],
+          graphName)
         this.code = result.data
       } catch (error) {
         displayError(this, error)
@@ -277,7 +281,11 @@ export default {
       if (!this.saveGraphDisabled) {
         this.loadingGraph = true
         try {
-          await this.$fusekiService.saveGraph(this.datasetName, this.selectedGraph, this.content)
+          await this.$fusekiService.saveGraph(
+            this.datasetName,
+            this.services['gsp-rw']['srv.endpoints'],
+            this.selectedGraph,
+            this.content)
           displayNotification(this, `Graph updated for dataset "${this.datasetName}"`)
         } catch (error) {
           displayError(this, error)
diff --git a/jena-fuseki2/jena-fuseki-ui/tests/unit/services/fuseki.service.spec.js b/jena-fuseki2/jena-fuseki-ui/tests/unit/services/fuseki.service.spec.js
index 87db72cd7c..6c392bd8ab 100644
--- a/jena-fuseki2/jena-fuseki-ui/tests/unit/services/fuseki.service.spec.js
+++ b/jena-fuseki2/jena-fuseki-ui/tests/unit/services/fuseki.service.spec.js
@@ -283,8 +283,11 @@ describe('FusekiService', () => {
     stub.resolves(Promise.resolve({
       data: 42
     }))
-    const graph = await fusekiService.fetchGraph('jena', 'default')
+    const graph = await fusekiService.fetchGraph('jena', ['dataEndpoint'], 'default')
     expect(stub.called).to.equal(true)
+    const getArgs = stub.getCall(0).args
+    // See https://github.com/apache/jena/pull/1679
+    expect(getArgs[0]).to.equal('/jena/dataEndpoint')
     expect(graph).to.deep.equal({ data: 42 })
     stub.restore()
   })
@@ -293,7 +296,7 @@ describe('FusekiService', () => {
     stub.resolves(Promise.resolve({
       data: 42
     }))
-    const graph = await fusekiService.saveGraph('jena', 'default', 'abc')
+    const graph = await fusekiService.saveGraph('jena', [], 'default', 'abc')
     expect(stub.called).to.equal(true)
     expect(graph).to.deep.equal({ data: 42 })
     stub.restore()
@@ -306,7 +309,7 @@ describe('FusekiService', () => {
     }
     stub.resolves(Promise.reject(error))
     try {
-      await fusekiService.saveGraph('jena', 'default', 'abc')
+      await fusekiService.saveGraph('jena', [], 'default', 'abc')
       expect.fail('Not supposed to get here')
     } catch (error) {
       expect(error.message).to.be.equal('42')