Skip to content

Commit e6485e8

Browse files
authored
Merge pull request #1609 from SciCatProject/SWAP-4196-scicat-fe-add-e2e-tests-for-datafiles-actions
test: add e2e tests for datafiles action
2 parents dd59049 + dd40145 commit e6485e8

File tree

11 files changed

+417
-214
lines changed

11 files changed

+417
-214
lines changed

.eslintrc.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"root": true,
33
"ignorePatterns": ["projects/**/*"],
4+
"parserOptions": {
5+
"ecmaVersion": 2020,
6+
"sourceType": "module",
7+
"project": ["tsconfig.json"]
8+
},
49
"plugins": ["@typescript-eslint/eslint-plugin"],
510
"overrides": [
611
{
@@ -73,7 +78,7 @@
7378
"@typescript-eslint/no-inferrable-types": "error",
7479
"@typescript-eslint/no-explicit-any": "warn",
7580
"@typescript-eslint/no-unused-vars": "warn",
76-
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
81+
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
7782
"@typescript-eslint/quotes": [
7883
"error",
7984
"double",

CI/ESS/e2e/config.e2e.json

+63-11
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
{
2-
"skipSciCatLoginPageEnabled": false,
32
"accessTokenPrefix": "Bearer ",
4-
"addDatasetEnabled": true,
3+
"addDatasetEnabled": false,
54
"archiveWorkflowEnabled": false,
65
"datasetReduceEnabled": true,
76
"datasetJsonScientificMetadata": true,
87
"editDatasetSampleEnabled": true,
98
"editMetadataEnabled": true,
109
"editPublishedData": false,
11-
"addSampleEnabled": true,
12-
"externalAuthEndpoint": "/auth/msad",
13-
"facility": "ESS",
14-
"loginFacilityLabel": "ESS",
10+
"addSampleEnabled": false,
11+
"externalAuthEndpoint": "/api/v3/auth/msad",
12+
"facility": "SciCat Vanilla",
13+
"siteIcon": "site-header-logo.png",
14+
"loginFacilityLabel": "SciCat Vanilla",
1515
"loginLdapLabel": "Ldap",
1616
"loginLocalLabel": "Local",
1717
"loginFacilityEnabled": true,
1818
"loginLdapEnabled": true,
1919
"loginLocalEnabled": true,
20+
"localLoginLabel": "Local",
2021
"fileColorEnabled": true,
2122
"fileDownloadEnabled": true,
2223
"gettingStarted": null,
2324
"ingestManual": null,
2425
"jobsEnabled": true,
2526
"jsonMetadataEnabled": true,
26-
"jupyterHubUrl": "https://jupyterhub.esss.lu.se/",
27+
"jupyterHubUrl": "",
2728
"landingPage": "doi.ess.eu/detail/",
2829
"lbBaseURL": "http://localhost:3000",
2930
"logbookEnabled": true,
3031
"loginFormEnabled": true,
31-
"maxDirectDownloadSize": 5000000000,
32+
"maxDirectDownloadSize": 1047521824,
3233
"metadataPreviewEnabled": true,
3334
"metadataStructure": "",
34-
"multipleDownloadAction": "https://scicatfileserver.esss.dk/zip",
35+
"multipleDownloadAction": "http:/127.0.0.1:3012/zip",
3536
"multipleDownloadEnabled": true,
3637
"oAuth2Endpoints": [
3738
{
@@ -41,8 +42,8 @@
4142
],
4243
"policiesEnabled": true,
4344
"retrieveDestinations": [],
44-
"riotBaseUrl": "http://scitest.esss.lu.se/riot",
45-
"scienceSearchEnabled": false,
45+
"riotBaseUrl": "http://scichat.esss.lu.se",
46+
"scienceSearchEnabled": true,
4647
"scienceSearchUnitsEnabled": true,
4748
"searchPublicDataEnabled": true,
4849
"searchSamples": true,
@@ -53,6 +54,57 @@
5354
"tableSciDataEnabled": true,
5455
"datasetDetailsShowMissingProposalId": false,
5556
"notificationInterceptorEnabled": true,
57+
"metadataEditingUnitListDisabled": true,
58+
"datafilesActionsEnabled": true,
59+
"datafilesActions": [
60+
{
61+
"id": "eed8efec-4354-11ef-a3b5-d75573a5d37f",
62+
"order": 4,
63+
"label": "Download All",
64+
"files": "all",
65+
"mat_icon": "download",
66+
"type": "form",
67+
"url": "https://www.scicat.info/download/all",
68+
"target": "_blank",
69+
"enabled": "#SizeLimit",
70+
"authorization": ["#datasetAccess", "#datasetPublic"]
71+
},
72+
{
73+
"id": "3072fafc-4363-11ef-b9f9-ebf568222d26",
74+
"order": 3,
75+
"label": "Download Selected",
76+
"files": "selected",
77+
"mat_icon": "download",
78+
"type": "form",
79+
"url": "https://www.scicat.info/download/selected",
80+
"target": "_blank",
81+
"enabled": "#Selected && #SizeLimit",
82+
"authorization": ["#datasetAccess", "#datasetPublic"]
83+
},
84+
{
85+
"id": "4f974f0e-4364-11ef-9c63-03d19f813f4e",
86+
"order": 2,
87+
"label": "Notebook All",
88+
"files": "all",
89+
"icon": "/assets/icons/jupyter_logo.png",
90+
"type": "form",
91+
"url": "https://www.scicat.info/notebook/all",
92+
"target": "_blank",
93+
"authorization": ["#datasetAccess", "#datasetPublic"]
94+
},
95+
{
96+
"id": "fa3ce6ee-482d-11ef-95e9-ff2c80dd50bd",
97+
"order": 1,
98+
"label": "Notebook Selected",
99+
"files": "selected",
100+
"icon": "/assets/icons/jupyter_logo.png",
101+
"type": "form",
102+
"url": "https://www.scicat.info/notebook/selected",
103+
"target": "_blank",
104+
"enabled": "#Selected",
105+
"authorization": ["#datasetAccess", "#datasetPublic"]
106+
}
107+
],
56108
"labelMaps": {
57109
"filters": {
58110
"LocationFilter": "Location",

CI/ESS/e2e/docker-compose.e2e.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ services:
4444
volumes:
4545
- "./CI/ESS/e2e/.env.backend-next:/home/node/app/.env"
4646
- "./CI/ESS/e2e/functionalAccounts.json:/home/node/app/functionalAccounts.json"
47+
- "./CI/ESS/e2e/config.e2e.json:/home/node/app/dist/config/frontend.config.json"
4748
depends_on:
4849
mongodb:
4950
condition: service_healthy
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/// <reference types="Cypress" />
2+
3+
describe("Dataset datafiles", () => {
4+
beforeEach(() => {
5+
cy.login(Cypress.config("username"), Cypress.config("password"));
6+
cy.intercept("PATCH", "/api/v3/Datasets/**/*").as("change");
7+
cy.intercept("GET", "*").as("fetch");
8+
});
9+
10+
after(() => {
11+
cy.removeDatasets();
12+
});
13+
14+
describe("Datafiles action test", () => {
15+
const actionUrl = {
16+
downloadSelected: "https://www.scicat.info/download/selected",
17+
downloadAll: "https://www.scicat.info/download/all",
18+
notebookSelected: "https://www.scicat.info/notebook/selected",
19+
notebookAll: "https://www.scicat.info/notebook/all",
20+
};
21+
it("Should be able to download/notebook with selected/all", () => {
22+
cy.createDataset("raw", undefined, "small");
23+
24+
cy.visit("/datasets");
25+
26+
cy.get(".dataset-table mat-table mat-header-row").should("exist");
27+
28+
cy.finishedLoading();
29+
30+
cy.get('[data-cy="text-search"] input[type="search"]')
31+
.clear()
32+
.type("Cypress");
33+
34+
cy.isLoading();
35+
36+
cy.contains("mat-row", "Cypress Dataset").first().click();
37+
38+
cy.wait("@fetch");
39+
40+
cy.get(".mat-mdc-tab-link").contains("Datafiles").click();
41+
42+
cy.get(".mdc-checkbox__native-control").eq(1).check();
43+
44+
cy.window().then((win) => {
45+
cy.spy(win.HTMLFormElement.prototype, "submit").as("formSubmit");
46+
});
47+
48+
// Test download selected
49+
cy.get('button:contains("Download Selected")').click();
50+
cy.get("@formSubmit").should("have.been.called", 1);
51+
cy.get("form")
52+
.eq(0)
53+
.should("have.attr", "action", actionUrl.downloadSelected);
54+
55+
// Test download all
56+
cy.get('button:contains("Download All")').click();
57+
cy.get("@formSubmit").should("have.been.called", 2);
58+
cy.get("form").eq(1).should("have.attr", "action", actionUrl.downloadAll);
59+
60+
// Test notebook selected
61+
cy.get('button:contains("Notebook Selected")').click();
62+
cy.get("@formSubmit").should("have.been.called", 3);
63+
cy.get("form")
64+
.eq(2)
65+
.should("have.attr", "action", actionUrl.notebookSelected);
66+
67+
// Test notebook all
68+
cy.get('button:contains("Notebook All")').click();
69+
cy.get("@formSubmit").should("have.been.called", 4);
70+
cy.get("form").eq(3).should("have.attr", "action", actionUrl.notebookAll);
71+
});
72+
73+
it("Should not be able to download selected/all file that is exceeding size limit", () => {
74+
cy.createDataset("raw", undefined, "large");
75+
76+
cy.visit("/datasets");
77+
78+
cy.get(".dataset-table mat-table mat-header-row").should("exist");
79+
80+
cy.finishedLoading();
81+
82+
cy.get('[data-cy="text-search"] input[type="search"]')
83+
.clear()
84+
.type("Cypress");
85+
86+
cy.isLoading();
87+
88+
cy.contains("mat-row", "Cypress Dataset").first().click();
89+
90+
cy.wait("@fetch");
91+
92+
cy.get(".mat-mdc-tab-link").contains("Datafiles").click();
93+
94+
cy.get(".mdc-checkbox__native-control").eq(1).check();
95+
96+
cy.window().then((win) => {
97+
cy.spy(win.HTMLFormElement.prototype, "submit").as("formSubmit");
98+
});
99+
100+
cy.get('button:contains("Download Selected")').should("be.disabled");
101+
cy.get('button:contains("Download All")').should("be.disabled");
102+
cy.get('button:contains("Notebook Selected")').should("not.be.disabled");
103+
cy.get('button:contains("Notebook Selected")').should("not.be.disabled");
104+
105+
cy.get(".mdc-checkbox__native-control").eq(1).uncheck();
106+
cy.get(".mdc-checkbox__native-control").eq(2).check();
107+
108+
cy.get('button:contains("Download Selected")').should("not.be.disabled");
109+
cy.get('button:contains("Download All")').should("be.disabled");
110+
});
111+
});
112+
});

cypress/fixtures/derivedDataset.json

-42
This file was deleted.

cypress/fixtures/policy.json

-12
This file was deleted.

cypress/fixtures/proposal.json

-8
This file was deleted.

cypress/fixtures/rawDataset.json

-43
This file was deleted.

0 commit comments

Comments
 (0)