From acb444298e6a6d349a778b9350d876e21dc92308 Mon Sep 17 00:00:00 2001
From: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
Date: Thu, 23 Nov 2023 15:13:18 +0100
Subject: [PATCH 1/3] adds cypress tests for index service
Signed-off-by: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
---
.../test_3_indexService.cy.js | 31 +++++++++++++++++++
.../support/test_data/all_types.concept.json | 28 ++++++++++-------
.../support/test_data/mapping.mapping.json | 7 +++++
cypress/support/test_data/mapping_data.csv | 5 +++
scripts/load_e2e_data.sh | 7 ++++-
5 files changed, 66 insertions(+), 12 deletions(-)
create mode 100644 cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
create mode 100644 cypress/support/test_data/mapping.mapping.json
create mode 100644 cypress/support/test_data/mapping_data.csv
diff --git a/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js b/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
new file mode 100644
index 0000000000..af307d03e3
--- /dev/null
+++ b/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
@@ -0,0 +1,31 @@
+///
+import { visitAdminUI } from "../../integration-helpers/visitAdminUI";
+
+context("Visit Index Service Page", () => {
+ describe("Perform Update Matching Stats", () => {
+
+ it("Start Update Matching Stats", () => {
+ visitAdminUI("datasets");
+ cy.get('[data-cy="datasets"]').contains('dataset1').click();
+ cy.get('[data-cy="update-matching-stats"]').click();
+ })
+
+ it("Wait for Update Matching Stats to finish", () => {
+ visitAdminUI("jobs");
+ cy.get('#origin_Manager > .card-header > .row > .accordion-infotext > div > .jobsAmount').eq(0);
+ })
+ });
+ describe("Visit Index Service Page", () => {
+
+ it("Check Statistics", () => {
+ visitAdminUI("index-service");
+
+ cy.get('[data-cy="statistics"]').contains('Miss count').next().should('not.equal', 0);
+ cy.get('[data-cy="statistics"]').contains('Total load time').next().should('not.equal', 0);
+
+ cy.get('[data-cy="indexes"]').contains('mapping_data.csv')
+ .next().contains("internal")
+ .next().contains('{{external}}');
+ })
+ });
+})
\ No newline at end of file
diff --git a/cypress/support/test_data/all_types.concept.json b/cypress/support/test_data/all_types.concept.json
index ad31d4561b..36e7d64ab8 100644
--- a/cypress/support/test_data/all_types.concept.json
+++ b/cypress/support/test_data/all_types.concept.json
@@ -118,17 +118,23 @@
}
],
"selects": [
- {
- "label": "SUM",
- "type": "SUM",
- "column": "table.INTEGER"
- },
- {
- "label": "COUNT",
- "type": "COUNT",
- "column": "table.INTEGER"
- },
- {
+ {
+ "label": "FIRST MAPPED",
+ "type": "FIRST",
+ "column": "table.INTEGER",
+ "mapping": "example_mapping"
+ },
+ {
+ "label": "SUM",
+ "type": "SUM",
+ "column": "table.INTEGER"
+ },
+ {
+ "label": "COUNT",
+ "type": "COUNT",
+ "column": "table.INTEGER"
+ },
+ {
"label": "DISTINCT",
"type": "DISTINCT",
"column": "table.INTEGER"
diff --git a/cypress/support/test_data/mapping.mapping.json b/cypress/support/test_data/mapping.mapping.json
new file mode 100644
index 0000000000..172f361c63
--- /dev/null
+++ b/cypress/support/test_data/mapping.mapping.json
@@ -0,0 +1,7 @@
+{
+ "csv": "file:./cypress/support/test_data/mapping_data.csv",
+ "externalTemplate": "{{external}}",
+ "internalColumn": "internal",
+ "name": "example_mapping",
+ "type": "CSV_MAP"
+}
\ No newline at end of file
diff --git a/cypress/support/test_data/mapping_data.csv b/cypress/support/test_data/mapping_data.csv
new file mode 100644
index 0000000000..c7473c48a6
--- /dev/null
+++ b/cypress/support/test_data/mapping_data.csv
@@ -0,0 +1,5 @@
+internal,external
+0,zero
+1,one
+2,two
+3,three
\ No newline at end of file
diff --git a/scripts/load_e2e_data.sh b/scripts/load_e2e_data.sh
index 6f3bdff45c..c9e6af1e8a 100755
--- a/scripts/load_e2e_data.sh
+++ b/scripts/load_e2e_data.sh
@@ -22,9 +22,14 @@ curl --fail -X POST "$admin_api/permissions/user.user2" -H "$h_ct" -H "$h_auth"
curl --fail -X POST "$admin_api/permissions/user.user2" -H "$h_ct" -H "$h_auth" -d 'concepts:read:*'
echo "Creating dataset"
-#create dataset
+# Create dataset
curl --fail -X POST "$admin_api/datasets/" -H "$h_ct" -H "$h_auth" -d '{"name": "dataset1", "label": "Dataset1"}'
sleep 3
+
+echo "Creating mappings"
+curl --fail -X POST "$admin_api/datasets/dataset1/internToExtern" -H "$h_ct" -H "$h_auth" -d "@./cypress/support/test_data/mapping.mapping.json"
+sleep 3
+
# TODO secondary ID
echo "Creating tables"
curl --fail -X POST "$admin_api/datasets/dataset1/tables" -H "$h_ct" -H "$h_auth" -d "@./cypress/support/test_data/all_types.table.json"
From 994361c63aa850eeb7034298264489596306ed84 Mon Sep 17 00:00:00 2001
From: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
Date: Fri, 24 May 2024 16:33:49 +0200
Subject: [PATCH 2/3] create dataset for new test
Signed-off-by: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
---
.../backend-admin-ui/test_3_indexService.cy.js | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js b/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
index af307d03e3..2bc72cc88b 100644
--- a/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
+++ b/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
@@ -2,11 +2,25 @@
import { visitAdminUI } from "../../integration-helpers/visitAdminUI";
context("Visit Index Service Page", () => {
+ const testDSLabel = "TestIndexDataset";
+ const testDSID = "TestIndexDatasetID";
+
+
+ describe("Create a new dataset", () => {
+ it("Can create a new dataset", () => {
+ visitAdminUI("datasets");
+ cy.get('[data-test-id="entity-name"]').type(testDSLabel);
+ cy.get('[data-test-id="entity-id"]').type(testDSID);
+ cy.get('[data-test-id="create-dataset-btn"]').click().as("createDataset");
+ cy.contains(testDSID);
+ });
+ });
+
describe("Perform Update Matching Stats", () => {
it("Start Update Matching Stats", () => {
visitAdminUI("datasets");
- cy.get('[data-cy="datasets"]').contains('dataset1').click();
+ cy.get('[data-cy="datasets"]').contains(testDSID).click();
cy.get('[data-cy="update-matching-stats"]').click();
})
From 26bff4958af253ad5dd131b9481ed11ce49d1878 Mon Sep 17 00:00:00 2001
From: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
Date: Fri, 24 May 2024 16:49:13 +0200
Subject: [PATCH 3/3] integrate index test in dataset test
---
.../e2e/backend-admin-ui/test_2_dataset.cy.js | 46 ++++++++++++++++++-
.../test_3_indexService.cy.js | 45 ------------------
2 files changed, 44 insertions(+), 47 deletions(-)
delete mode 100644 cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
diff --git a/cypress/e2e/backend-admin-ui/test_2_dataset.cy.js b/cypress/e2e/backend-admin-ui/test_2_dataset.cy.js
index 3c5c75d4b3..a57f95ea41 100644
--- a/cypress/e2e/backend-admin-ui/test_2_dataset.cy.js
+++ b/cypress/e2e/backend-admin-ui/test_2_dataset.cy.js
@@ -36,11 +36,24 @@ context("Admin UI Single Dataset", () => {
});
});
- describe("Can upload test table and concept", () => {
+ describe("Can upload mapping, table and concept", () => {
beforeEach(() => {
visitAdminUI(`datasets/${testDSID}`);
});
+
+ it("Can upload mapping", () => {
+ cy.intercept("/admin/datasets/*/internToExtern").as("apiCall");
+ cy.get('[data-test-id="upload-select"]').select("Mapping JSON");
+ cy.get('[data-test-id="upload-input"]').selectFile(
+ "./cypress/support/test_data/mapping.mapping.json"
+ );
+ cy.get('[data-test-id="upload-btn"]').click();
+ cy.wait("@apiCall").reload();
+ cy.get('[data-test-id="accordion-Mappings"]').contains("td", `example_mapping`);
+ });
+
+
it("Can upload table", () => {
cy.intercept("/admin/datasets/*/tables").as("apiCall");
cy.get('[data-test-id="upload-select"]').select("Table JSON");
@@ -126,7 +139,7 @@ context("Admin UI Single Dataset", () => {
it("Counts are right", () => {
visitAdminUI(`datasets/${testDSID}/connectors/${testDSID}.concept1.column`);
cy.get('[data-test-id="accordion-Filters"] > .card-header').contains("20 entries");
- cy.get('[data-test-id="accordion-Selects"] > .card-header').contains("16 entries");
+ cy.get('[data-test-id="accordion-Selects"] > .card-header').contains("17 entries");
});
});
@@ -170,6 +183,35 @@ context("Admin UI Single Dataset", () => {
});
});
+
+
+ describe("Perform Update Matching Stats", () => {
+
+ it("Start Update Matching Stats", () => {
+ visitAdminUI("datasets");
+ cy.get('[data-cy="datasets"]').contains(testDSID).click();
+ cy.get('[data-cy="update-matching-stats"]').click();
+ })
+
+ it("Wait for Update Matching Stats to finish", () => {
+ visitAdminUI("jobs");
+ cy.get('#origin_Manager > .card-header > .row > .accordion-infotext > div > .jobsAmount').eq(0);
+ })
+ });
+ describe("Visit Index Service Page", () => {
+
+ it("Check Statistics", () => {
+ visitAdminUI("index-service");
+
+ cy.get('[data-cy="statistics"]').contains('Miss count').next().should('not.equal', 0);
+ cy.get('[data-cy="statistics"]').contains('Total load time').next().should('not.equal', 0);
+
+ cy.get('[data-cy="indexes"]').contains('mapping_data.csv')
+ .next().contains("internal")
+ .next().contains('{{external}}');
+ })
+ });
+
describe("Can delete test concept and table", () => {
beforeEach(() => visitAdminUI(`datasets/${testDSID}`));
diff --git a/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js b/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
deleted file mode 100644
index 2bc72cc88b..0000000000
--- a/cypress/e2e/backend-admin-ui/test_3_indexService.cy.js
+++ /dev/null
@@ -1,45 +0,0 @@
-///
-import { visitAdminUI } from "../../integration-helpers/visitAdminUI";
-
-context("Visit Index Service Page", () => {
- const testDSLabel = "TestIndexDataset";
- const testDSID = "TestIndexDatasetID";
-
-
- describe("Create a new dataset", () => {
- it("Can create a new dataset", () => {
- visitAdminUI("datasets");
- cy.get('[data-test-id="entity-name"]').type(testDSLabel);
- cy.get('[data-test-id="entity-id"]').type(testDSID);
- cy.get('[data-test-id="create-dataset-btn"]').click().as("createDataset");
- cy.contains(testDSID);
- });
- });
-
- describe("Perform Update Matching Stats", () => {
-
- it("Start Update Matching Stats", () => {
- visitAdminUI("datasets");
- cy.get('[data-cy="datasets"]').contains(testDSID).click();
- cy.get('[data-cy="update-matching-stats"]').click();
- })
-
- it("Wait for Update Matching Stats to finish", () => {
- visitAdminUI("jobs");
- cy.get('#origin_Manager > .card-header > .row > .accordion-infotext > div > .jobsAmount').eq(0);
- })
- });
- describe("Visit Index Service Page", () => {
-
- it("Check Statistics", () => {
- visitAdminUI("index-service");
-
- cy.get('[data-cy="statistics"]').contains('Miss count').next().should('not.equal', 0);
- cy.get('[data-cy="statistics"]').contains('Total load time').next().should('not.equal', 0);
-
- cy.get('[data-cy="indexes"]').contains('mapping_data.csv')
- .next().contains("internal")
- .next().contains('{{external}}');
- })
- });
-})
\ No newline at end of file