Skip to content

Commit

Permalink
Merge branch 'main' into feature/dev-3277-image-regions-are-not-highl…
Browse files Browse the repository at this point in the history
…ighted-in-chrome-after-clicking

* main:
  test: e2e data model tests (DEV-2379, DEV-2341, DEV-2339, DEV-2338) (#1475)
  fix: removed absolute image size restriction, added sample image (DEV-3304) (#1484)
  refactor: remove unused code in ontology component (#1472)
  fix: image region  comment field  validation removed(DEV-3315) (#1487)
  chore(main): release 11.6.5 (#1486)
  fix: submit button on upload resource does not load indefinitely  (#1485)
  chore(main): release 11.6.4 (#1482)
  fix: ontology initialisation (DEV-3317) (#1483)
  fix: new list node field error is not displayed (#1481)
  chore(main): release 11.6.3 (#1470)
  chore: update dsp-js to v.9.1.12 (#1478)
  fix: highlits section by clicked region in image viewer (DEV-3277) (#1468)
  • Loading branch information
irmastnt committed Feb 28, 2024
2 parents 6e728fa + 728fc01 commit 24998a4
Show file tree
Hide file tree
Showing 45 changed files with 761 additions and 496 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## [11.6.5](https://github.com/dasch-swiss/dsp-das/compare/v11.6.4...v11.6.5) (2024-02-27)


### Bug Fixes

* submit button on upload resource does not load indefinitely ([#1485](https://github.com/dasch-swiss/dsp-das/issues/1485)) ([e1a51b5](https://github.com/dasch-swiss/dsp-das/commit/e1a51b5a224bf532f3a3f0ff8e6b4a49c9b42bd2))

## [11.6.4](https://github.com/dasch-swiss/dsp-das/compare/v11.6.3...v11.6.4) (2024-02-23)


### Bug Fixes

* new list node field error is not displayed ([#1481](https://github.com/dasch-swiss/dsp-das/issues/1481)) ([1ef0823](https://github.com/dasch-swiss/dsp-das/commit/1ef082364c13ead5a537bc32a734372744f1cbda))
* ontology initialisation (DEV-3317) ([#1483](https://github.com/dasch-swiss/dsp-das/issues/1483)) ([be6ec9a](https://github.com/dasch-swiss/dsp-das/commit/be6ec9a5f4b16f4992b79ee69754da74f8b71178))

## [11.6.3](https://github.com/dasch-swiss/dsp-das/compare/v11.6.2...v11.6.3) (2024-02-23)


### Bug Fixes

* highlits section by clicked region in image viewer (DEV-3277) ([#1468](https://github.com/dasch-swiss/dsp-das/issues/1468)) ([50a5db5](https://github.com/dasch-swiss/dsp-das/commit/50a5db556f544f3beaf8b23a26caabd0d7328a85))
* initiates new search when user is logged in sucessfully (DEV-3293) ([#1469](https://github.com/dasch-swiss/dsp-das/issues/1469)) ([70f7f25](https://github.com/dasch-swiss/dsp-das/commit/70f7f25f373e0e054c7cd4240ce969c07450efb0))


### Maintenance

* update dsp-js to v.9.1.12 ([#1478](https://github.com/dasch-swiss/dsp-das/issues/1478)) ([a99cfeb](https://github.com/dasch-swiss/dsp-das/commit/a99cfebbec6aeea49277a32ec6bc52486a564de5))

## [11.6.2](https://github.com/dasch-swiss/dsp-das/compare/v11.6.1...v11.6.2) (2024-02-14)


Expand Down
3 changes: 3 additions & 0 deletions apps/dsp-app/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export default defineConfig({
e2e: {
specPattern: 'cypress/**/**/**/*.cy.ts',
excludeSpecPattern: ['*.spec.js', '*.spec.ts'],
viewportHeight: 768,
viewportWidth: 1024,
supportFile: 'cypress/support/e2e.ts',
baseUrl: 'http://localhost:4200',
env: {
apiUrl: 'http://0.0.0.0:3333',
Expand Down
1 change: 1 addition & 0 deletions apps/dsp-app/cypress/e2e/logged-out-user/auth.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Authentication', () => {
cy.get(po.submitButton).click();

cy.get(po.loginButton).should('not.be.visible');
cy.get('[data-cy=user-button]').should('be.visible');
});
});

Expand Down
146 changes: 146 additions & 0 deletions apps/dsp-app/cypress/e2e/system-admin/data-model-class.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import { ResourceClassDefinitionWithAllLanguages } from '@dasch-swiss/dsp-js';
import { faker } from '@faker-js/faker';
import { ClassType, PropertyType } from '../../support/helpers/constants';
import { DataModelClassProperty } from '../../support/helpers/interfaces';
import ProjectPage from '../../support/pages/project-page';

describe('Data Model Class', () => {
const projectPage = new ProjectPage();

beforeEach(() => {
projectPage.requestProject();
});

it('should create new data model class', () => {
const textClass: ResourceClassDefinitionWithAllLanguages = {
id: faker.lorem.word(),
subClassOf: [],
propertiesList: [],
canBeInstantiated: true,
label: faker.lorem.words(5),
comment: faker.lorem.words(10),
comments: [],
labels: [],
};

const resourceClass: ResourceClassDefinitionWithAllLanguages = {
id: faker.lorem.word(),
subClassOf: [],
propertiesList: [],
canBeInstantiated: true,
label: faker.lorem.words(5),
comment: faker.lorem.words(10),
comments: [],
labels: [],
};

cy.intercept('POST', '/v2/ontologies/classes').as('createRequest');

cy.createOntology(projectPage);

cy.get('[data-cy=create-class-button]').scrollIntoView().should('be.visible').click();
cy.get(`[data-cy=${ClassType.TextRepresentation}]`).scrollIntoView().should('be.visible').click({ force: true });
cy.get('[data-cy=name-input]').clear().type(textClass.id);
cy.get('[data-cy=label-input]').clear().type(textClass.label);
cy.get('[data-cy=comment-textarea]').type(textClass.comment);
cy.get('[data-cy=submit-button]').click();

cy.wait('@createRequest');
cy.get('[data-cy=class-card]').should('be.visible').get('mat-card-title').contains(textClass.label.split(' ')[0]);
cy.get('[data-cy=create-class-button]').scrollIntoView().should('be.visible').click();
cy.get(`[data-cy=${ClassType.Resource}]`).scrollIntoView().should('be.visible').click({ force: true });
cy.get('[data-cy=name-input]').clear().type(resourceClass.id);
cy.get('[data-cy=label-input]').clear().type(resourceClass.label);
cy.get('[data-cy=comment-textarea]').type(resourceClass.comment);
cy.get('[data-cy=submit-button]').click();

cy.wait('@createRequest');
cy.get('[data-cy=class-card]')
.should('be.visible')
.get('mat-card-title')
.contains(resourceClass.label.split(' ')[0]);
});

it('should cancel to create data model class', () => {
cy.createOntology(projectPage);

cy.get('[data-cy=create-class-button]').scrollIntoView().should('be.visible').click();
cy.get(`[data-cy=${ClassType.TextRepresentation}]`).scrollIntoView().should('be.visible').click({ force: true });
cy.get('.mat-mdc-dialog-container').should('be.visible');
cy.get('[data-cy=cancel-button]').scrollIntoView().should('be.visible').click();
cy.get('.mat-mdc-dialog-container').should('not.exist');

cy.get('[data-cy=create-class-button]').scrollIntoView().should('be.visible').click();
cy.get(`[data-cy=${ClassType.TextRepresentation}]`).scrollIntoView().click({ force: true });
cy.get('.mat-mdc-dialog-container').should('be.visible');
cy.get('.cdk-overlay-backdrop').click(-50, -50, { force: true });
cy.get('.mat-mdc-dialog-container').should('not.exist');
});

it('should create properties', () => {
const textProperty = <DataModelClassProperty>{
name: faker.lorem.word(),
label: faker.lorem.words(5),
comment: faker.lorem.words(10),
};

const pageNumberProperty = <DataModelClassProperty>{
name: faker.lorem.word(),
label: faker.lorem.words(5),
comment: faker.lorem.words(10),
};

cy.intercept('POST', '/v2/ontologies/properties').as('createPropertyRequest');
cy.createOntology(projectPage);

cy.get('[data-cy=properties-button]').should('be.visible').click({ force: true });

cy.get('[data-cy=create-property-button]').should('be.visible').click({ force: true });
cy.get(`[data-cy=${PropertyType.Text}]`).should('be.visible').click();
cy.get(`[data-cy=${PropertyType.Short}]`).should('be.visible').click();
cy.get('[data-cy=name-input]').clear().type(textProperty.name);
cy.get('[data-cy=property-label] input').clear().type(textProperty.label);
cy.get('[data-cy=property-comment] textarea').type(textProperty.comment);
cy.get('[data-cy=submit-button]').click();

cy.wait('@createPropertyRequest');
cy.get('[data-cy=property-label]').should('be.visible').should('include.text', textProperty.label);

cy.get('[data-cy=create-property-button]').should('be.visible').click({ force: true });
cy.get(`[data-cy=${PropertyType.Number}]`).should('be.visible').click();
cy.get(`[data-cy="${PropertyType.PageNumber}"]`).should('be.visible').click();
cy.get('[data-cy=name-input]').clear().type(pageNumberProperty.name);
cy.get('[data-cy=property-label] input').clear().type(pageNumberProperty.label);
cy.get('[data-cy=property-comment] textarea').type(pageNumberProperty.comment);
cy.get('[data-cy=submit-button]').click();

cy.wait('@createPropertyRequest');
cy.get('[data-cy=property-label]').should('be.visible').should('include.text', pageNumberProperty.label);
});

it('should add property to a data model class', () => {
const textProperty = <DataModelClassProperty>{
name: faker.lorem.word(),
label: faker.lorem.words(5),
comment: faker.lorem.words(10),
};

cy.intercept('POST', '/v2/ontologies/properties').as('createPropertyRequest');
cy.createDataModelClass(projectPage);

cy.get('[data-cy=class-card]').should('be.visible');
cy.get('[data-cy=resource-class-properties-empty-list]').should('be.visible');
cy.get('[data-cy=add-property-button]').should('be.visible').click();
cy.get('[data-cy=create-new-property-from-type-button]').should('be.visible').click({ force: true });
cy.get(`[data-cy=${PropertyType.Text}]`).should('be.visible').click();
cy.get(`[data-cy=${PropertyType.Short}]`).should('be.visible').click();

cy.get('[data-cy=name-input]').clear().type(textProperty.name);
cy.get('[data-cy=property-label] input').clear().type(textProperty.label);
cy.get('[data-cy=property-comment] textarea').type(textProperty.comment);
cy.get('[data-cy=submit-button]').click();

cy.wait('@createPropertyRequest');
cy.get('[data-cy=property-label]').should('be.visible').should('include.text', textProperty.label);
});
});
62 changes: 62 additions & 0 deletions apps/dsp-app/cypress/e2e/system-admin/ontology.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { CreateOntology } from '@dasch-swiss/dsp-js';
import { faker } from '@faker-js/faker';
import ProjectPage from '../../support/pages/project-page';

describe('Ontology', () => {
const projectPage = new ProjectPage();

beforeEach(() => {
projectPage.requestProject();
});

it('should create new ontology', () => {
const data = {
name: faker.string.alpha({ length: { min: 3, max: 16 } }),
label: faker.lorem.words(5),
comment: faker.lorem.words(10),
};

cy.intercept('POST', '/v2/ontologies').as('submitRequest');
cy.visit(`/project/${projectPage.projectUuid}/data-models`);
cy.url().should('include', `project\/${projectPage.projectUuid}\/data-models`);

cy.get('[data-cy=data-models-container]')
.find('[data-cy=create-button]')
.scrollIntoView()
.should('be.visible')
.click();

cy.get('[data-cy=name-input]').type(data.name);
cy.get('[data-cy=label-input]').clear().type(data.label);
cy.get('[data-cy=comment-textarea]').type(data.comment);
cy.get('[data-cy=submit-button]').click();

cy.wait('@submitRequest');
cy.url().should('include', `project/${projectPage.projectUuid}/ontology/${data.name}/editor/classes`);
cy.get('[data-cy=ontology-label]').contains(data.label).should('be.visible');
});

it('should update ontology', () => {
const data = <CreateOntology>{
name: faker.string.alpha({ length: { min: 3, max: 16 } }),
label: faker.lorem.words(5),
comment: faker.lorem.words(10),
};

cy.intercept('PUT', '/v2/ontologies/metadata').as('updateRequest');

cy.createOntology(projectPage).then(ontology => {
cy.get('[data-cy=edit-ontology-button]').scrollIntoView().should('be.visible').click();
cy.get('[data-cy=label-input]').clear().type(data.label);
cy.get('[data-cy=comment-textarea]').type(data.comment);
cy.get('[data-cy=submit-button]').click();

cy.wait('@updateRequest');
cy.url().should(
'include',
`project/${projectPage.projectUuid}/ontology/${ontology.ontology.name}/editor/classes`
);
cy.get('[data-cy=ontology-label]').contains(data.label).should('be.visible');
});
});
});
62 changes: 29 additions & 33 deletions apps/dsp-app/cypress/e2e/system-admin/projects.cy.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
import { faker } from '@faker-js/faker';
import { ProjectOperationResponseADM } from '../../../../../libs/vre/open-api/src';
import { customShortcode } from '../../support/helpers/custom-shortcode';
import { generateKeyword } from '../../support/helpers/custom-word';
import { randomNumber } from '../../support/helpers/random-number';
import ProjectPage from '../../support/pages/project-page';

describe('Projects', () => {
let projectIri: string;

const payload = {
shortname: 'shortname',
shortcode: 'A0A0',
longname: 'Longname',
description: [{ language: 'de', value: 'description' }],
keywords: ['keyword'],
status: true,
selfjoin: true,
};
const projectPage = new ProjectPage();

beforeEach(() => {
cy.request<ProjectOperationResponseADM>('POST', `${Cypress.env('apiUrl')}/admin/projects`, payload).then(
response => {
projectIri = response.body.project.id;
}
);
projectPage.requestProject();
});

it('admin can create a project', () => {
const data = {
shortcode: customShortcode(),
shortname: faker.internet.userName(),
shortname: faker.lorem.word(),
longname: faker.company.name(),
description: faker.lorem.sentence(),
keywords: Array.from({ length: randomNumber(3, 6) }, () => generateKeyword(4)),
Expand Down Expand Up @@ -59,12 +45,15 @@ describe('Projects', () => {
};
cy.intercept('PUT', '/admin/projects/iri/*').as('submitRequest');

cy.visit(`/project/${projectIri.match(/\/([^\/]+)$/)[1]}/settings/edit`);
cy.get('[data-cy=shortcode-input] input').should('have.value', payload.shortcode);
cy.get('[data-cy=shortname-input] input').should('have.value', payload.shortname);
cy.get('[data-cy=longname-input] input').should('have.value', payload.longname).clear().type(data.longname);
cy.visit(`/project/${projectPage.projectIri.match(/\/([^\/]+)$/)[1]}/settings/edit`);
cy.get('[data-cy=shortcode-input] input').should('have.value', projectPage.project.shortcode);
cy.get('[data-cy=shortname-input] input').should('have.value', projectPage.project.shortname);
cy.get('[data-cy=longname-input] input')
.should('have.value', projectPage.project.longname)
.clear()
.type(data.longname);
cy.get('[data-cy=description-input] textarea')
.should('have.value', payload.description[0].value)
.should('have.value', projectPage.project.description[0].value)
.clear()
.type(data.description);
cy.get('[data-cy=keywords-input] input')
Expand All @@ -74,35 +63,40 @@ describe('Projects', () => {

cy.wait('@submitRequest');
cy.url().should('match', /\/project\/(.+)/);
cy.contains(payload.shortcode).should('be.visible');
cy.contains(projectPage.project.shortcode).should('be.visible');
cy.contains(data.description).should('be.visible');
data.keywords.forEach(keyword => cy.contains(keyword).should('be.visible'));
});

it('admin can deactivate a project', () => {
cy.intercept('DELETE', `/admin/projects/iri/${encodeURIComponent(projectIri)}`).as('deactivateRequest');
cy.intercept('DELETE', `/admin/projects/iri/${encodeURIComponent(projectPage.projectIri)}`).as('deactivateRequest');

cy.visit('/system/projects');
cy.get('[data-cy=active-projects-section]')
.contains('[data-cy=project-row]', payload.shortcode)
.contains('[data-cy=project-row]', projectPage.project.shortcode)
.find('[data-cy=more-button]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-cy=deactivate-button]').click();
cy.get('[data-cy=deactivate-button]').scrollIntoView().click({ force: true });
cy.get('[data-cy=confirmation-button]').click();
cy.wait('@deactivateRequest');

cy.get('[data-cy=inactive-projects-section]').contains('[data-cy=project-row]', payload.shortcode).should('exist');
cy.get('[data-cy=inactive-projects-section]')
.contains('[data-cy=project-row]', projectPage.project.shortcode)
.should('exist');
});

it.only('admin can reactivate a project', () => {
cy.intercept('PUT', `/admin/projects/iri/${encodeURIComponent(projectIri)}`).as('updateRequest');
it('admin can reactivate a project', () => {
cy.intercept('PUT', `/admin/projects/iri/${encodeURIComponent(projectPage.projectIri)}`).as('updateRequest');

cy.request('DELETE', `${Cypress.env('apiUrl')}/admin/projects/iri/${encodeURIComponent(projectIri)}`).then(() => {
cy.request(
'DELETE',
`${Cypress.env('apiUrl')}/admin/projects/iri/${encodeURIComponent(projectPage.projectIri)}`
).then(() => {
cy.visit('/system/projects');
cy.get('[data-cy=inactive-projects-section]')
.contains('[data-cy=project-row]', payload.shortcode)
.contains('[data-cy=project-row]', projectPage.project.shortcode)
.find('[data-cy=more-button]')
.scrollIntoView()
.should('be.visible')
Expand All @@ -111,7 +105,9 @@ describe('Projects', () => {
cy.get('[data-cy=confirmation-button]').click();
cy.wait('@updateRequest');

cy.get('[data-cy=active-projects-section]').contains('[data-cy=project-row]', payload.shortcode).should('exist');
cy.get('[data-cy=active-projects-section]')
.contains('[data-cy=project-row]', projectPage.project.shortcode)
.should('exist');
});
});
});
Loading

0 comments on commit 24998a4

Please sign in to comment.