Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds cypress tests for index service #3227

Merged
merged 8 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muss die Anzahl von Entries hardgecoded sein?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Für einen Test ist das gut so.

Da man Testdaten nicht aus dem zu testenden Code erzeugen soll, braucht man entweder eine Referenzimplementierung gegen die man testet oder einen festen Datensatz, aus den man liest.

});
});

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
Loading