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:24 UTC
[jena] 02/02: Fix e2e test command and code (got out of date with a recent change, plus cypress...)
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')) ||
(