Skip to content

Commit 07551f0

Browse files
authored
Merge pull request #833 from europeana/feat/MET-5784-Handle-Empty-Transformation-Result
MET-5785 Handle Empty Transformation Result
2 parents 316e3d7 + 423bec0 commit 07551f0

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

projects/metis/cypress/e2e/mapping.cy.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cleanupUser, setupUser } from '../support/helpers';
1+
import { cleanupUser, setEmptyDataResult, setupUser } from '../support/helpers';
22

33
context('metis-ui', () => {
44
describe('mapping', () => {
@@ -42,6 +42,23 @@ context('metis-ui', () => {
4242
cy.url().should('contain', '/mapping');
4343
});
4444

45+
it('should show try out XSLT (fail)', () => {
46+
const selSampleEmpty = '.sample-data-empty';
47+
cy.get(selSampleEmpty).should('not.exist');
48+
cy.wait(1);
49+
50+
setEmptyDataResult(
51+
'/orchestrator/proxies/records?workflowExecutionId=0&pluginType=OAIPMH_HARVEST&nextPage=',
52+
true
53+
);
54+
55+
cy.get(selBtnTryDefaultXSLT)
56+
.first()
57+
.click();
58+
59+
cy.get(selSampleEmpty).should('have.length', 1);
60+
});
61+
4562
it('should initialise an editor with the default XSLT', () => {
4663
cy.get(selBtnInitDefault).should('not.exist');
4764
cy.visit('/dataset/mapping/1');

projects/metis/cypress/support/helpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ export function cleanupUser(): void {
3737
});
3838
}
3939

40-
export function setEmptyDataResult(url: string): void {
41-
url = Cypress.env('dataServer') + url + UrlManipulation.RETURN_EMPTY;
40+
export function setEmptyDataResult(url: string, emptyArray = false): void {
41+
const manipulationType = emptyArray
42+
? UrlManipulation.RETURN_EMPTY_ARRAY
43+
: UrlManipulation.RETURN_EMPTY;
44+
url = Cypress.env('dataServer') + url + manipulationType;
4245
cy.request(url);
4346
}
4447

projects/metis/src/app/dataset/preview/preview.component.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
(closed)="notification = undefined"
55
></app-notification>
66

7+
<ng-template #sampleDataEmpty>
8+
<span class="sample-data-empty">
9+
There is no tranformation available
10+
</span>
11+
</ng-template>
12+
713
<div *ngIf="!tempXSLT">
814
<div class="filter-wrapper">
915
<ul
@@ -225,7 +231,12 @@
225231
</div>
226232
</div>
227233

228-
<div *ngIf="allTransformedSamples && allSamples">
234+
<div
235+
*ngIf="
236+
allTransformedSamples && allTransformedSamples.length && allSamples && allSamples.length;
237+
else sampleDataEmpty
238+
"
239+
>
229240
<ng-container *ngFor="let sample of allSamples; let i = index">
230241
<app-editor
231242
[index]="i"

projects/metis/test-data/_models/test-models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum UrlManipulation {
77
RETURN_401 = 'METIS_UI_401',
88
RETURN_404 = 'METIS_UI_404',
99
RETURN_EMPTY = 'METIS_UI_EMPTY',
10+
RETURN_EMPTY_ARRAY = 'METIS_UI_EMPTY_ARRAY',
1011
METIS_UI_CLEAR = 'METIS_UI_CLEAR'
1112
}
1213

projects/metis/test-data/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const FAIL = 'fail';
2626
const SWITCH_TYPES = [
2727
UrlManipulation.RETURN_401,
2828
UrlManipulation.RETURN_404,
29+
UrlManipulation.RETURN_EMPTY_ARRAY,
2930
UrlManipulation.RETURN_EMPTY
3031
];
3132

@@ -83,9 +84,13 @@ new (class extends TestDataServer {
8384
depublicationInfoCache: Array<RecordDepublicationInfo> = [];
8485
switchedOff: { [key: string]: string } = {};
8586

86-
returnEmpty(response: ServerResponse): void {
87+
returnEmpty(response: ServerResponse, fmtRecords = false): void {
8788
response.setHeader('Content-Type', 'application/json;charset=UTF-8');
88-
response.end('{ "results": [], "listSize":0, "nextPage":-1 }');
89+
if (fmtRecords) {
90+
response.end('{ "records":[], "nextPage": null }');
91+
} else {
92+
response.end('{ "results": [], "listSize":0, "nextPage":-1 }');
93+
}
8994
}
9095

9196
return404(response: ServerResponse, statusMessage = 'Not found'): void {
@@ -472,6 +477,7 @@ new (class extends TestDataServer {
472477

473478
if (regRes) {
474479
const params = url.parse(route, true).query;
480+
475481
response.end(
476482
JSON.stringify(
477483
executionsByDatasetIdAsList(
@@ -738,14 +744,16 @@ new (class extends TestDataServer {
738744

739745
if (new RegExp(SWITCH_TYPES.join('|')).exec(route)) {
740746
this.switchOff(route);
741-
this.returnEmpty(response);
747+
this.returnEmpty(response, route.indexOf(UrlManipulation.RETURN_EMPTY_ARRAY) > -1);
742748
return;
743749
}
744750

745751
const switchedOff = this.isSwitchedOff(route);
746752
if (switchedOff) {
747753
if (switchedOff === UrlManipulation.RETURN_EMPTY) {
748754
this.returnEmpty(response);
755+
} else if (switchedOff === UrlManipulation.RETURN_EMPTY_ARRAY) {
756+
this.returnEmpty(response, true);
749757
} else if (switchedOff === UrlManipulation.RETURN_401) {
750758
this.return401(response);
751759
} else if (switchedOff === UrlManipulation.RETURN_404) {

0 commit comments

Comments
 (0)