Skip to content

Commit

Permalink
Test stability fixes
Browse files Browse the repository at this point in the history
## What
- Test improvements

## Why
- Tests are flaky in various environments

## How
- More cypressish approach
- Changed one <div> to <label> in import view - no visual changes

## Other changes
- Less clutter in what's printed on console when running on Jenkins
- Include ttyg tests in test:core
  • Loading branch information
Pavel Mihaylov authored and svilenvelikov committed Oct 21, 2024
1 parent ab89e79 commit c267db2
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 19 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
-Dgraphdb.workbench.importDirectory=/opt/home/import-data/
-Dgraphdb.jsonld.whitelist=https://w3c.github.io/json-ld-api/tests/*
-Dgraphdb.stats.default=disabled
-Dgraphdb.foreground=
-Dgraphdb.logger.root.level=ERROR
expose:
- 7200
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker-rootfs/usr/local/bin/start-workbench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ mv /etc/nginx/conf.d/default.conf.tmp /etc/nginx/conf.d/default.conf
# Tests & prints the whole configuration (easy to debug issues)
nginx -T

nginx -g "daemon off;"
nginx -g "daemon off;" > /dev/null
6 changes: 4 additions & 2 deletions src/pages/import.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ <h1>
ngf-max-size="maxUploadFileSizeMB + 'MB'">
<div class="grid-container">
<em class="icon-upload icon-lg"></em>
<div class="text">
<!-- Keep this a label, it points to the input element created by ngFileUpload
and makes cypress happy -->
<label for="ngf-wb-import-uploadFile" class="text m-0">
<div>{{'upload.rdf.files.label' | translate}}</div>
<small
class="text-muted">{{'all.rdf.formats.label' | translate}}{{'up.to' | translate}}
{{maxUploadFileSizeMB | number}} MB
</small>
</div>
</label>
</div>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,22 @@ describe('Import user data: File upload', () => {
ImportUserDataSteps.getResourcesTable().should('be.hidden');
// When I upload a file
ImportUserDataSteps.selectFile(ImportUserDataSteps.createFile(testFiles[0], bnodes));
// Then the import settings dialog should open automatically
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
// Then I should see the uploaded file
ImportUserDataSteps.checkImportedResource(0, 'bnodes.ttl');
// When I upload another file
ImportUserDataSteps.selectFile(ImportUserDataSteps.createFile(testFiles[1], jsonld));
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
// Then I should see the uploaded file - it becomes first in the list
ImportUserDataSteps.checkImportedResource(0, 'jsonld.jsonld');
ImportUserDataSteps.checkImportedResource(1, 'bnodes.ttl');
// When I override the first file
ImportUserDataSteps.selectFile(ImportUserDataSteps.createFile(testFiles[0], bnodes));
FileOverwriteDialogSteps.overwrite();
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
// Then I should see the uploaded file - it becomes first in the list
// TODO: timestamps currently seems to not be changed on reimport
Expand All @@ -119,6 +123,7 @@ describe('Import user data: File upload', () => {
// When I override the second file
ImportUserDataSteps.selectFile(ImportUserDataSteps.createFile(testFiles[1], jsonld));
FileOverwriteDialogSteps.overwrite();
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
// Then I should see the uploaded file - it becomes first in the list
ImportUserDataSteps.checkImportedResource(0, 'jsonld.jsonld');
Expand All @@ -131,6 +136,7 @@ describe('Import user data: File upload', () => {
// When I start to upload a file
ImportUserDataSteps.selectFile(ImportUserDataSteps.createFile(testFiles[0], bnodes));
// Then the import settings dialog should open automatically
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.uploadOnly();
// Then I should see the uploaded file
ImportUserDataSteps.getResources().should('have.length', 1);
Expand All @@ -149,6 +155,7 @@ describe('Import user data: File upload', () => {
const file2 = ImportUserDataSteps.createFile(testFiles[1], jsonld);
ImportUserDataSteps.selectFile([file1, file2]);
// Then the import settings dialog should open automatically
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
// Then I should see the uploaded file
ImportUserDataSteps.getResources().should('have.length', 2);
Expand All @@ -165,6 +172,8 @@ describe('Import user data: File upload', () => {
ImportUserDataSteps.getResourcesTable().should('be.hidden');
const file1 = ImportUserDataSteps.createFile(testFiles[0], bnodes);
ImportUserDataSteps.selectFile(file1);
// Then the import settings dialog should open automatically
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
ImportUserDataSteps.getResources().should('have.length', 1);
ImportUserDataSteps.checkImportedResource(0, 'bnodes.ttl');
Expand All @@ -186,6 +195,8 @@ describe('Import user data: File upload', () => {
ImportUserDataSteps.getResourcesTable().should('be.hidden');
const file1 = ImportUserDataSteps.createFile(testFiles[0], bnodes);
ImportUserDataSteps.selectFile(file1);
// Then the import settings dialog should open automatically
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
ImportUserDataSteps.getResources().should('have.length', 1);
ImportUserDataSteps.checkImportedResource(0, 'bnodes.ttl');
Expand Down Expand Up @@ -220,6 +231,8 @@ describe('Import user data: File upload', () => {
// When I upload a file with invalid format
const file1 = ImportUserDataSteps.createFile(testFiles[2], jsonld);
ImportUserDataSteps.selectFile(file1);
// Then the import settings dialog should open automatically
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
// Then I should see an error message
ImportUserDataSteps.getResources().should('have.length', 1);
Expand Down
6 changes: 5 additions & 1 deletion test-cypress/integration/import/import-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe('Import view', () => {
// Given I have opened the user data tab and uploaded a single file
ImportUserDataSteps.getResourcesTable().should('be.hidden');
ImportUserDataSteps.selectFile(ImportUserDataSteps.createFile(testFiles[0], bnodes));
// Then the import settings dialog should open automatically
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
ImportUserDataSteps.getResources().should('have.length', 1);
ImportUserDataSteps.getResourceByName('bnodes.ttl').should('be.visible');
Expand All @@ -43,6 +45,7 @@ describe('Import view', () => {
// Then I should see the uploaded file
ImportUserDataSteps.getResources().should('have.length', 1);
ImportUserDataSteps.getResourceByName('bnodes.ttl').should('be.visible');
ImportUserDataSteps.checkImportedResource(0, 'bnodes.ttl');
});

it('Should display/hide help message depends on resource result', () => {
Expand Down Expand Up @@ -99,8 +102,9 @@ describe('Import view', () => {
// When I go to user tab and upload a file
ImportSteps.openUserDataTab();
// And I wait for tab data to load
cy.wait(100);
ImportUserDataSteps.selectFile(ImportUserDataSteps.createFile(testFiles[0], bnodes));
// Then the import settings dialog should open automatically
ImportSettingsDialogSteps.getDialog().should('be.visible');
ImportSettingsDialogSteps.import();
ImportUserDataSteps.getResources().should('have.length', 1);
ImportUserDataSteps.checkImportedResource(0, 'bnodes.ttl');
Expand Down
8 changes: 1 addition & 7 deletions test-cypress/integration/repository/repositories.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,7 @@ describe('Repositories', () => {
HomeSteps.visitAndWaitLoader();
cy.visit('/repository');

// Verify that the repositories are loaded
// and only afterwards continue with the check
cy.get('#wb-repositories-repositoryInGetRepositories .repository')
.should('have.length.greaterThan', 0)
.then(() => {
RepositorySteps.assertRepositoryStatus(repositoryId, "RUNNING");
});
RepositorySteps.assertRepositoryStatus(repositoryId, "RUNNING");

//Restart the repository
RepositorySteps.restartRepository(repositoryId);
Expand Down
2 changes: 1 addition & 1 deletion test-cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "cypress run",
"test:flaky": "cypress run --config-file cypress-flaky.config.js",
"test:partial": "cypress run --spec \"integration/repository/**\"",
"test:core": "cypress run --spec integration/repository/**,integration/import/**,integration/sparql-editor/**,integration/monitor/**,integration/cluster/**"
"test:core": "cypress run --spec integration/repository/**,integration/import/**,integration/sparql-editor/**,integration/monitor/**,integration/cluster/**,integration/ttyg/**"
},
"author": {
"name": "\"Sirma AI\" JSC, trading as Ontotext",
Expand Down
2 changes: 1 addition & 1 deletion test-cypress/steps/import/import-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class ImportSteps {
}

static selectFile(files) {
cy.get('input[type=file]').selectFile(files, {force: true});
cy.get('#wb-import-uploadFile label').selectFile(files);
}

static uploadFile(filePath) {
Expand Down
9 changes: 3 additions & 6 deletions test-cypress/steps/repository-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,8 @@ export class RepositorySteps {
}

static assertRepositoryStatus(repositoryId, status) {
cy.waitUntil(() =>
RepositorySteps.getRepositoryFromList(repositoryId)
.should('be.visible')
.find('.repository-status .text-secondary')
.then(($el) => $el)
.then(($el) => $el && $el.text() === status));
RepositorySteps.getRepositoryFromList(repositoryId).as('repo');
cy.get('@repo').should('be.visible');
cy.get('@repo').find('.repository-status .text-secondary').contains(status);
}
}

0 comments on commit c267db2

Please sign in to comment.