Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dockerized Skosmos for Cypress tests #1509

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
with:
fetch-depth: 0

- name: Start up Fuseki
run: cd tests; ./init_fuseki.sh
- name: Start up containers
run: cd tests; ./init_containers.sh

- name: Cache Composer dependencies
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = defineConfig({
projectRoot: "tests",
e2e: {
// You also can run like this: npx cypress run --config "baseUrl=http://localhost/Skosmos"
baseUrl: 'http://localhost/Skosmos',
baseUrl: 'http://localhost:9090/',
setupNodeEvents(on, config) {
on('task', {
log(message) {
Expand Down
5 changes: 4 additions & 1 deletion tests/GlobalConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ class GlobalConfigTest extends PHPUnit\Framework\TestCase
private $config;
/** @var GlobalConfig */
private $configWithDefaults;
/** @var GlobalConfig */
private $configWithBaseHref;

protected function setUp(): void
{
$this->config = new GlobalConfig('/../../tests/testconfig.ttl');
$this->assertNotNull($this->config->getCache());
$this->assertNotNull($this->config->getGraph());
$this->configWithDefaults = new GlobalConfig('/../../tests/testconfig-fordefaults.ttl');
$this->configWithBaseHref = new GlobalConfig('/../../tests/testconfig-basehref.ttl');
}

// --- tests for values that are overriding default values
Expand Down Expand Up @@ -53,7 +56,7 @@ public function testGetServiceName()

public function testGetBaseHref()
{
$this->assertEquals("http://tests.localhost/Skosmos/", $this->config->getBaseHref());
$this->assertEquals("http://tests.localhost/Skosmos/", $this->configWithBaseHref->getBaseHref());
}

public function testGetLanguages()
Expand Down
2 changes: 1 addition & 1 deletion tests/RestControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ public function testVocabularyStatistics()
},
"count": "void:entities",
"@language": "en",
"@base": "http://tests.localhost/Skosmos/rest/v1/test/"
"@base": "http://:/rest/v1/test/"
},
"uri": "",
"id": "test",
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/template/error.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ describe('Error page', () => {
// go to a non-existing page
cy.visit('/404', {failOnStatusCode: false})
// check that the page contains 404 error code
cy.get('.alert h3').invoke('text').should('contain', '404 Error')
cy.get('.alert span').invoke('text').should('contain', '404 Error')
})
})
19 changes: 19 additions & 0 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.7'

services:
fuseki:
extends:
file: ../dockerfiles/docker-compose.yml
service: fuseki
fuseki-cache:
extends:
file: ../dockerfiles/docker-compose.yml
service: fuseki-cache
skosmos:
extends:
file: ../dockerfiles/docker-compose.yml
service: skosmos
volumes:
- type: bind
source: testconfig.ttl
target: /var/www/html/config.ttl
1 change: 0 additions & 1 deletion tests/init_fuseki.sh → tests/init_containers.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

# Build and start up containers (skosmos, skosmos-cache, fuseki)
cd ../dockerfiles
docker compose up -d --build

echo "Waiting for Fuseki to get ready"
Expand Down
52 changes: 52 additions & 0 deletions tests/testconfig-basehref.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@prefix void: <http://rdfs.org/ns/void#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix wv: <http://vocab.org/waiver/terms/norms> .
@prefix sd: <http://www.w3.org/ns/sparql-service-description#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skosmos: <http://purl.org/net/skosmos#> .
@prefix isothes: <http://purl.org/iso25964/skos-thes#> .
@prefix mdrtype: <http://publications.europa.eu/resource/authority/dataset-type/> .
@prefix : <http://base/#> .

# Skosmos main configuration

:config a skosmos:Configuration ;
# customize the base element. Set this if the automatic base url detection doesn't work. For example setups behind a proxy.
skosmos:baseHref "http://tests.localhost/Skosmos/" ;
skosmos:templateCache "/tmp/skosmos-template-cache-tests" .

:test a skosmos:Vocabulary, void:Dataset ;
dc:title "Test ontology"@en ;
dc:subject :cat_science ;
dc:type mdrtype:ONTOLOGY ;
void:dataDump <http://skosmos.skos/dump/test/> ;
void:sparqlEndpoint <http://localhost:13030/skosmos-test/sparql> ;
void:uriSpace "http://www.skosmos.skos/test/";
skos:prefLabel "Test ontology"@en ;
skosmos:arrayClass isothes:ThesaurusArray ;
skosmos:defaultLanguage "en";
skosmos:feedbackRecipient "developer@vocabulary.org";
skosmos:groupClass skos:Collection;
skosmos:language "en";
skosmos:showTopConcepts "true";
skosmos:shortName "Test short",
"Testi lyhyt"@fi;
skosmos:sparqlGraph <http://www.skosmos.skos/test/> .

:cat_science a skos:Concept ;
skos:topConceptOf :categories ;
skos:inScheme :categories ;
skos:prefLabel "Luonnontieteet ja lääketiede"@fi,
"Naturvetenskap och medicin"@sv,
"Science and medicine"@en .

mdrtype:THESAURUS a skos:Concept ;
skos:prefLabel "Тезаурус"@bg, "Tezaurus"@cs, "Tesaurus"@da, "Thesaurus"@de, "Θησαυρός"@el, "Thesaurus"@en, "Tesaurus"@et, "Tesaurus"@fi, "Thésaurus"@fr, "Pojmovnik"@hr, "Tezaurusz"@hu, "Tesauro"@it, "Tēzaurs"@lv, "Tezauras"@lt, "Teżawru"@mt, "Thesaurus"@nl, "Tesaurus"@no, "Tezaurus"@pl, "Tesauro"@pt, "Tezaur"@ro, "Synonymický slovník"@sk, "Tezaver"@sl, "Tesauro"@es, "Tesaurus"@sv .

mdrtype:ONTOLOGY a skos:Concept ;
skos:prefLabel "Онтология"@bg, "Ontologie"@cs, "Ontologi"@da, "Ontologie"@de, "Οντολογία"@el, "Ontology"@en, "Ontoloogia"@et, "Ontologia"@fi, "Ontologie"@fr, "Ontologija"@hr, "Ontológia"@hu, "Ontologia"@it, "Ontoloģija"@lv, "Ontologija"@lt, "Ontoloġija"@mt, "Ontologie"@nl, "Ontologi"@no, "Struktura pojęciowa"@pl, "Ontologia"@pt, "Ontologie"@ro, "Ontológia"@sk, "Ontologija"@sl, "Ontología"@es, "Ontologi"@sv .
2 changes: 1 addition & 1 deletion tests/testconfig.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# customize the service name
skosmos:serviceName "Skosmos being tested" ;
# customize the base element. Set this if the automatic base url detection doesn't work. For example setups behind a proxy.
skosmos:baseHref "http://tests.localhost/Skosmos/" ;
#skosmos:baseHref "http://localhost/Skosmos/" ;
# interface languages available, and the corresponding system locales
skosmos:languages ( [ rdfs:label "en" ; rdf:value "en_GB.utf8" ]
[ rdfs:label "fi" ; rdf:value "fi_FI.utf8" ]
Expand Down