Skip to content

Commit f6423ba

Browse files
Merge pull request #208 from Ontotext-AD/GDB-5327-fix-flaky-tests
GDB-5372 Fixed flaky tests
2 parents bbf9815 + 369515d commit f6423ba

File tree

3 files changed

+40
-21
lines changed

3 files changed

+40
-21
lines changed

cypress/steps/mapping-steps.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MappingSteps {
1111
* @param fieldAccessorCb a function which must return a field
1212
*/
1313
static type(value: string, fieldAccessorCb: any) {
14-
return fieldAccessorCb().type(value, {force: true});
14+
return fieldAccessorCb().type(value);
1515
}
1616

1717
static completeTriple(index: number, subject?: string, predicate?: string, object?: string) {
@@ -27,18 +27,27 @@ class MappingSteps {
2727
}
2828

2929
static completeSubject(index: number, value: string) {
30-
this.type(value, () => MappingSteps.getTripleSubjectValue(index));
31-
MappingSteps.getTripleSubjectValue(index).blur();
30+
this.type(value, () => MappingSteps.getTripleSubjectValue(index)).then((component) => {
31+
if (component) {
32+
component.blur();
33+
}
34+
});
3235
}
3336

3437
static completePredicate(index: number, value: string) {
35-
this.type(value, () => MappingSteps.getTriplePredicateValue(index));
36-
MappingSteps.getTriplePredicateValue(index).blur();
38+
this.type(value, () => MappingSteps.getTriplePredicateValue(index)).then((component) => {
39+
if (component) {
40+
component.blur();
41+
}
42+
});
3743
}
3844

3945
static completeObject(index: number, value: string) {
40-
this.type(value, () => MappingSteps.getTripleObjectValue(index));
41-
MappingSteps.getTripleObjectValue(index).blur();
46+
this.type(value, () => MappingSteps.getTripleObjectValue(index)).then((component) => {
47+
if (component) {
48+
component.blur();
49+
}
50+
});
4251
}
4352

4453
static verifyTriple(index: number, subject: string, predicate: string, object: string) {
@@ -92,7 +101,7 @@ class MappingSteps {
92101

93102
static getTripleSubjectValue(index: any) {
94103
// wait for a while to prevent element to be found in detached state
95-
return MappingSteps.getTripleSubject(index).find('[appCypressData="cell-value"]').wait(300);
104+
return MappingSteps.getTripleSubject(index).find('[appCypressData="cell-value"]');
96105
}
97106

98107
static getTripleSubjectValuePreview(index: any) {
@@ -158,7 +167,7 @@ class MappingSteps {
158167

159168
static getTriplePredicateValue(index: any) {
160169
// wait for a while to prevent element to be found in detached state
161-
return MappingSteps.getTriplePredicate(index).find('[appCypressData="cell-value"]').wait(300);
170+
return MappingSteps.getTriplePredicate(index).find('[appCypressData="cell-value"]');
162171
}
163172

164173
static getTriplePredicateValuePreview(index: any) {
@@ -192,7 +201,7 @@ class MappingSteps {
192201

193202
static getTripleObjectValue(index: any) {
194203
// wait for a while to prevent element to be found in detached state
195-
return MappingSteps.getTripleObject(index).find('[appCypressData="cell-value"]').wait(300);
204+
return MappingSteps.getTripleObject(index).find('[appCypressData="cell-value"]');
196205
}
197206

198207
static getTripleObjectValuePreview(index: any) {
@@ -325,7 +334,7 @@ class MappingSteps {
325334
return cy.get('[appCypressData="namespace-error"]');
326335
}
327336

328-
static getSuggestions(index: any) {
337+
static getSuggestions() {
329338
return cy.get(`[appCypressData="cell-option"]`);
330339
}
331340

cypress/test/autocomplete.spec.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ describe('Autocomplete mapping', () => {
2020
MappingSteps.getTriples().should('have.length', 1);
2121
MappingSteps.completeTriple(0, 's', 'p', undefined);
2222
MappingSteps.type('w', () => MappingSteps.getTripleObjectValue(0));
23-
MappingSteps.getSuggestions(0).should('have.length', 5);
24-
MappingSteps.getSuggestions(0).first().should('contain', 'wgs:').click();
23+
MappingSteps.getSuggestions().should('have.length', 5);
24+
MappingSteps.getSuggestions().first().should('contain', 'wgs:').then((option) => {
25+
option[0].click();
26+
});
2527
MappingSteps.type('test', () => MappingSteps.getTripleObjectValue(0));
2628
MappingSteps.getTripleObjectValue(0).blur();
2729
MappingSteps.getTripleObjectPropertyTransformation(0).should('have.text', 'wgs:');
@@ -32,15 +34,19 @@ describe('Autocomplete mapping', () => {
3234
MappingSteps.getTriples().should('have.length', 1);
3335
MappingSteps.completeTriple(0, 's', 'p', undefined);
3436
MappingSteps.type('rdf:@', () => MappingSteps.getTripleObjectValue(0));
35-
MappingSteps.getSuggestions(0).should('have.length', 28);
36-
MappingSteps.getSuggestions(0).first().should('contain', 'color').click();
37+
MappingSteps.getSuggestions().should('have.length', 28);
38+
MappingSteps.getSuggestions().first().should('contain', 'color').then((option) => {
39+
option[0].click();
40+
});
3741
MappingSteps.getTripleObjectPropertyTransformation(0).should('have.text', 'rdf:');
3842
MappingSteps.getTripleObjectSource(0).should('have.text', ' @ color ');
3943
// When I type on the subject position an extended prefix plus column beginning
4044
MappingSteps.type('rdf:ext@du', () => MappingSteps.getTripleSubjectValue(1));
41-
MappingSteps.getSuggestions(0).should('have.length', 1);
45+
MappingSteps.getSuggestions().should('have.length', 1);
4246
// And I select the column from the suggestion
43-
MappingSteps.getSuggestions(0).first().should('contain', 'duration').click();
47+
MappingSteps.getSuggestions().first().should('contain', 'duration').then((option) => {
48+
option[0].click();
49+
});
4450
// Then I expect that the extended prefix is properly populated in the cell
4551
// And The column and type are properly set
4652
MappingSteps.getTripleSubjectPropertyTransformation(1).should('have.text', 'rdf:ext');
@@ -50,7 +56,9 @@ describe('Autocomplete mapping', () => {
5056
MappingSteps.type('p', () => MappingSteps.getTriplePredicateValue(1));
5157
MappingSteps.type('rdf:ext@co', () => MappingSteps.getTripleObjectValue(1));
5258
// And I select the columns from the suggestion
53-
MappingSteps.getSuggestions(0).first().should('contain', 'color').click();
59+
MappingSteps.getSuggestions().first().should('contain', 'color').then((option) => {
60+
option[0].click();
61+
});
5462
// Then I expect that the prefix, column and tpe are properly populated in the cell
5563
MappingSteps.getTripleObjectPropertyTransformation(1).should('have.text', 'rdf:ext');
5664
MappingSteps.getTripleObjectSource(1).should('have.text', ' @ color ');
@@ -64,7 +72,7 @@ describe('Autocomplete mapping', () => {
6472
// Call POST again to load tooltips
6573
cy.route('POST', '/repositories/Movies', 'fixture:autocomplete/autocomplete-iri-description-response.json').as('loadDescr');
6674
// When I hover an autocomplete
67-
MappingSteps.getSuggestions(0).first().trigger('mouseover');
75+
MappingSteps.getSuggestions().first().trigger('mouseover');
6876
// I expect tho see an IRI description
6977
MappingSteps.getTooltip().contains('IRI Description');
7078
});

cypress/test/edit-mapping.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,10 @@ describe('Edit mapping', () => {
752752

753753
MappingSteps.completeTriple(0, 's', undefined, undefined);
754754
MappingSteps.type('rdf:t', () => MappingSteps.getTriplePredicateValue(0));
755-
MappingSteps.getSuggestions(0).should('have.length', 1);
756-
MappingSteps.getSuggestions(0).first().should('contain', 'rdf:type').click();
755+
MappingSteps.getSuggestions().should('have.length', 1);
756+
MappingSteps.getSuggestions().first().should('contain', 'rdf:type').then((option) => {
757+
option[0].click();
758+
});
757759

758760
// THEN
759761
MappingSteps.getTriplePredicate(0).should('have.text', 'a<IRI>');

0 commit comments

Comments
 (0)