Skip to content

Commit

Permalink
Merge pull request #3227 from ingef/feature/global_indexservice
Browse files Browse the repository at this point in the history
adds cypress tests for index service
  • Loading branch information
thoniTUB authored Jun 12, 2024
2 parents 9329190 + 22ded57 commit f16f91d
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 14 deletions.
46 changes: 44 additions & 2 deletions cypress/e2e/backend-admin-ui/test_2_dataset.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
});
});

Expand Down Expand Up @@ -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}`));

Expand Down
28 changes: 17 additions & 11 deletions cypress/support/test_data/all_types.concept.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions cypress/support/test_data/mapping.mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"csv": "file:./cypress/support/test_data/mapping_data.csv",
"externalTemplate": "{{external}}",
"internalColumn": "internal",
"name": "example_mapping",
"type": "CSV_MAP"
}
5 changes: 5 additions & 0 deletions cypress/support/test_data/mapping_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
internal,external
0,zero
1,one
2,two
3,three
7 changes: 6 additions & 1 deletion scripts/load_e2e_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f16f91d

Please sign in to comment.