-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1475) Co-authored-by: Julien Schneider <[email protected]>
- Loading branch information
1 parent
00021a8
commit 728fc01
Showing
27 changed files
with
534 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
apps/dsp-app/cypress/e2e/system-admin/data-model-class.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// <reference types="cypress" /> | ||
|
||
import { CreateOntology } from '@dasch-swiss/dsp-js'; | ||
import { CreateResourceClassPayload } from '@dasch-swiss/dsp-js/src/models/v2/ontologies/create/create-resource-class'; | ||
import ProjectPage from './pages/project-page'; | ||
|
||
declare global { | ||
namespace Cypress { | ||
interface Chainable<Subject = any> { | ||
createOntology(project: ProjectPage, ontology?: CreateOntology): Chainable<any>; | ||
createDataModelClass( | ||
project: ProjectPage, | ||
resourceClass?: CreateResourceClassPayload | ||
): Chainable<CreateResourceClassPayload>; | ||
} | ||
} | ||
} |
Oops, something went wrong.