Skip to content

Commit

Permalink
chore: fix response type selector tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-golovanov committed Nov 18, 2024
1 parent 87d79d5 commit 041e7b6
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ describe(
EditorNavigation.SelectEntityByName(queryName, EntityType.Query);

BottomPane.response.switchToResponseTab();

BottomPane.response.openResponseTypeMenu();
agHelper.AssertElementVisibility(
BottomPane.response.getResponseTypeSelector("TABLE"),
BottomPane.response.getResponseTypeMenuItem("TABLE"),
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ describe(
//Add HSET
dataSources.CreateQueryAfterDSSaved();
dataSources.EnterQuery(hSetReceipe);
dataSources.RunQueryNVerifyResponseViews(1); //verify all views are returned!
dataSources.runQueryAndVerifyResponseViews(1); //verify all views are returned!
dataSources.AssertQueryTableResponse(0, "4"); //Success response for 4 keys inserted via above HSET!

//Read only one key from above HSET
dataSources.EnterQuery(hGetKeys);
dataSources.RunQueryNVerifyResponseViews(1); //verify all views are returned!
dataSources.runQueryAndVerifyResponseViews(1); //verify all views are returned!
dataSources.AssertQueryTableResponse(0, "Vegetable Stir Fry");

//Read more than one key from above HSET
dataSources.EnterQuery(hMGet);
dataSources.RunQueryNVerifyResponseViews(2);
dataSources.runQueryAndVerifyResponseViews(2);
dataSources.AssertQueryTableResponse(0, "easy");
dataSources.AssertQueryTableResponse(1, "Vegetable Stir Fry");

//Update key value in HSET
dataSources.EnterQuery(hUpdate);
dataSources.RunQueryNVerifyResponseViews(1); //verify all views are returned!
dataSources.runQueryAndVerifyResponseViews(1); //verify all views are returned!

//validate updated key
dataSources.EnterQuery(getUpdatedKey);
dataSources.RunQueryNVerifyResponseViews(1);
dataSources.runQueryAndVerifyResponseViews(1);
dataSources.AssertQueryTableResponse(0, "medium");

//Get All keys from HSET
dataSources.EnterQuery(getAll);
dataSources.RunQueryNVerifyResponseViews(8); //4 keys, 4 values
dataSources.runQueryAndVerifyResponseViews(8); //4 keys, 4 values
dataSources.ReadQueryTableResponse(0).then(($cellData: any) => {
expect($cellData).to.be.oneOf([
"name",
Expand All @@ -70,11 +70,11 @@ describe(

//Ading one more key/value to HSET
dataSources.EnterQuery(addNewKeyValue);
dataSources.RunQueryNVerifyResponseViews(1);
dataSources.runQueryAndVerifyResponseViews(1);

//Verify new key/value also added to HSET
dataSources.EnterQuery(getAll);
dataSources.RunQueryNVerifyResponseViews(10); //5 keys, 5 values
dataSources.runQueryAndVerifyResponseViews(10); //5 keys, 5 values
dataSources.ReadQueryTableResponse(0).then(($cellData: any) => {
expect($cellData).to.be.oneOf([
"name",
Expand All @@ -87,11 +87,11 @@ describe(

//Deleting the Hash key
dataSources.EnterQuery(deletehKey);
dataSources.RunQueryNVerifyResponseViews(1);
dataSources.runQueryAndVerifyResponseViews(1);

//Verify Deletion is success
dataSources.EnterQuery(hGetKeys);
dataSources.RunQueryNVerifyResponseViews(); //5 keys, 5 values
dataSources.runQueryAndVerifyResponseViews(); //5 keys, 5 values
dataSources.AssertQueryTableResponse(0, "null");

// Delete the query & datasource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe(
agHelper.FocusElement(locators._codeMirrorTextArea);
//agHelper.VerifyEvaluatedValue(tableCreateQuery); //failing sometimes!

dataSources.RunQueryNVerifyResponseViews();
dataSources.runQueryAndVerifyResponseViews();
dataSources.AssertTableInVirtuosoList(dsName, "productlines");

agHelper.ActionContextMenuWithInPane({
Expand Down Expand Up @@ -279,7 +279,7 @@ describe(
agHelper.FocusElement(locators._codeMirrorTextArea);
//agHelper.VerifyEvaluatedValue(tableCreateQuery);

dataSources.RunQueryNVerifyResponseViews();
dataSources.runQueryAndVerifyResponseViews();
dataSources.AssertTableInVirtuosoList(dsName, "Stores", false);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe(
agHelper.FocusElement(locators._codeMirrorTextArea);
//agHelper.VerifyEvaluatedValue(tableCreateQuery);

dataSources.RunQueryNVerifyResponseViews();
dataSources.runQueryAndVerifyResponseViews();
dataSources.AssertTableInVirtuosoList(dsName, "Stores");

agHelper.ActionContextMenuWithInPane({
Expand All @@ -79,7 +79,7 @@ describe(

it("2. Validate Select record from Postgress datasource & verify query response", () => {
dataSources.CreateQueryForDS(dsName, "SELECT * FROM Stores LIMIT 10");
dataSources.RunQueryNVerifyResponseViews(10);
dataSources.runQueryAndVerifyResponseViews(10);
dataSources.AssertQueryTableResponse(5, "2112");
dataSources.AssertQueryTableResponse(6, "Mike's Liquors");
// Commenting this deletion of query to make the generate crud work on the new page instead of the current page
Expand Down Expand Up @@ -375,7 +375,7 @@ describe(
agHelper.FocusElement(locators._codeMirrorTextArea);
//agHelper.VerifyEvaluatedValue(tableCreateQuery);

dataSources.RunQueryNVerifyResponseViews();
dataSources.runQueryAndVerifyResponseViews();
dataSources.AssertTableInVirtuosoList(dsName, "Stores", false);

agHelper.ActionContextMenuWithInPane({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe(
agHelper.FocusElement(locators._codeMirrorTextArea);
//agHelper.VerifyEvaluatedValue(tableCreateQuery); //failing sometimes!

dataSources.RunQueryNVerifyResponseViews();
dataSources.runQueryAndVerifyResponseViews();
});

it("2. Validate Select record from Postgress datasource & verify query response", () => {
Expand All @@ -70,7 +70,7 @@ describe(
"public.vessels",
"Select",
);
dataSources.RunQueryNVerifyResponseViews(10);
dataSources.runQueryAndVerifyResponseViews(10);
dataSources.AssertQueryTableResponse(0, "371681");
dataSources.AssertQueryTableResponse(6, "Passenger");
agHelper.ActionContextMenuWithInPane({
Expand Down Expand Up @@ -617,7 +617,7 @@ describe(
dataSources.CreateQueryForDS(dsName, deleteTblQuery, "DropVessels");
agHelper.FocusElement(locators._codeMirrorTextArea);

dataSources.RunQueryNVerifyResponseViews();
dataSources.runQueryAndVerifyResponseViews();
dataSources.AssertTableInVirtuosoList(dsName, "public.vessels", false);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ describe(
//Validating use of extention
query = `CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE EXTENSION IF NOT EXISTS "pgcrypto"`;
dataSources.CreateQueryForDS(dsName, query, "verifyUUIDFunctions");
dataSources.RunQueryNVerifyResponseViews(1);
dataSources.runQueryAndVerifyResponseViews(1);
dataSources.AssertQueryResponseHeaders(["affectedRows"]);
dataSources.ReadQueryTableResponse(0).then(($cellData) => {
expect($cellData).to.eq("0");
Expand Down Expand Up @@ -297,7 +297,7 @@ describe(
//Validating Addition of new column taking default value form package method
query = `ALTER TABLE uuidtype ADD COLUMN newUUID uuid DEFAULT uuid_generate_v4();`;
dataSources.EnterQuery(query);
dataSources.RunQueryNVerifyResponseViews(1);
dataSources.runQueryAndVerifyResponseViews(1);
dataSources.AssertQueryResponseHeaders(["affectedRows"]);
dataSources.ReadQueryTableResponse(0).then(($cellData) => {
expect($cellData).to.eq("0");
Expand All @@ -314,7 +314,7 @@ describe(
//Validating altering the new column default value to generate id from pgcrypto package
query = `ALTER TABLE uuidtype ALTER COLUMN newUUID SET DEFAULT gen_random_uuid();`;
dataSources.EnterQuery(query);
dataSources.RunQueryNVerifyResponseViews(1);
dataSources.runQueryAndVerifyResponseViews(1);
dataSources.AssertQueryResponseHeaders(["affectedRows"]);
dataSources.ReadQueryTableResponse(0).then(($cellData) => {
expect($cellData).to.eq("0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ describe(
"Find",
);
dataSources.ValidateNSelectDropdown("Command", "Find document(s)");
dataSources.RunQueryNVerifyResponseViews(1, false);
dataSources.runQueryAndVerifyResponseViews(1, false);
agHelper.ActionContextMenuWithInPane({
action: "Delete",
entityType: entityItems.Query,
Expand All @@ -352,7 +352,7 @@ describe(
directInput: false,
inputFieldName: "Query",
});
dataSources.RunQueryNVerifyResponseViews(1, false);
dataSources.runQueryAndVerifyResponseViews(1, false);
agHelper.ActionContextMenuWithInPane({
action: "Delete",
entityType: entityItems.Query,
Expand Down Expand Up @@ -738,7 +738,7 @@ describe(
"Aggregate",
);
dataSources.ValidateNSelectDropdown("Command", "Aggregate");
dataSources.RunQueryNVerifyResponseViews(7, false);
dataSources.runQueryAndVerifyResponseViews(7, false);
agHelper.ActionContextMenuWithInPane({
action: "Delete",
entityType: entityItems.Query,
Expand Down Expand Up @@ -899,7 +899,7 @@ describe(
"Find",
);
dataSources.ValidateNSelectDropdown("Command", "Find document(s)");
dataSources.RunQueryNVerifyResponseViews(4, false);
dataSources.runQueryAndVerifyResponseViews(4, false);
agHelper.ActionContextMenuWithInPane({
action: "Delete",
entityType: entityItems.Query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe(
"List files",
);

dataSources.RunQueryNVerifyResponseViews(100);
dataSources.runQueryAndVerifyResponseViews(100);
agHelper.ActionContextMenuWithInPane({
action: "Delete",
entityType: entityItems.Query,
Expand Down
10 changes: 5 additions & 5 deletions app/client/cypress/e2e/Sanity/Datasources/Arango_Basic_Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ if (CURRENT_REPO == REPO.CE) {
}
INTO ${collectionName}`;
dataSources.EnterQuery(query);
dataSources.RunQueryNVerifyResponseViews();
dataSources.runQueryAndVerifyResponseViews();
dataSources.AssertQueryResponseHeaders([
"writesExecuted",
"writesIgnored",
Expand All @@ -232,7 +232,7 @@ if (CURRENT_REPO == REPO.CE) {
FILTER place.type == "Natural"
RETURN { country: doc.country, name: place.name }`;
dataSources.EnterQuery(query);
dataSources.RunQueryNVerifyResponseViews(5); //Verify all records are filtered
dataSources.runQueryAndVerifyResponseViews(5); //Verify all records are filtered
dataSources.AssertQueryTableResponse(0, "Japan");
dataSources.AssertQueryTableResponse(1, "Mount Fuji");
dataSources.AssertQueryTableResponse(6, "Brazil"); //Widget binding is verified here
Expand Down Expand Up @@ -265,7 +265,7 @@ if (CURRENT_REPO == REPO.CE) {
}
IN ${collectionName}`;
dataSources.EnterQuery(query);
dataSources.RunQueryNVerifyResponseViews();
dataSources.runQueryAndVerifyResponseViews();

dataSources.createQueryWithDatasourceSchemaTemplate(
dsName,
Expand All @@ -276,7 +276,7 @@ if (CURRENT_REPO == REPO.CE) {
FILTER document._key == "1"
RETURN document`;
dataSources.EnterQuery(query);
dataSources.RunQueryNVerifyResponseViews(1);
dataSources.runQueryAndVerifyResponseViews(1);
dataSources.AssertQueryTableResponse(3, "Australia");

//Delete record from collection
Expand All @@ -287,7 +287,7 @@ if (CURRENT_REPO == REPO.CE) {
);
query = `REMOVE "1" in ${collectionName}`;
dataSources.EnterQuery(query);
dataSources.RunQueryNVerifyResponseViews(1); //Removing Australia
dataSources.runQueryAndVerifyResponseViews(1); //Removing Australia

//Verify no records return for the deleted key
query = `FOR document IN ${collectionName}
Expand Down
4 changes: 2 additions & 2 deletions app/client/cypress/e2e/Sanity/Datasources/MockDBs_Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe(
'SELECT * FROM public."users" LIMIT 10;',
);

dataSources.RunQueryNVerifyResponseViews(); //minimum 1 rows are expected
dataSources.runQueryAndVerifyResponseViews(); //minimum 1 rows are expected
AppSidebar.navigate(AppSidebarButton.Data);
dataSources
.getDatasourceListItemDescription(mockDBName)
Expand All @@ -57,7 +57,7 @@ describe(
expect(interception.request.body.source).to.equal("SELF");
});

dataSources.RunQueryNVerifyResponseViews(); //minimum 1 rows are expected
dataSources.runQueryAndVerifyResponseViews(); //minimum 1 rows are expected
AppSidebar.navigate(AppSidebarButton.Data);
dataSources
.getDatasourceListItemDescription(mockDBName)
Expand Down
22 changes: 22 additions & 0 deletions app/client/cypress/support/Pages/DataSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ export class DataSources {
this.assertHelper.AssertNetworkStatus("@saveAction", 200);
}

/** @deprecated */
public RunQueryNVerifyResponseViews(
expectedRecordsCount = 1,
tableCheck = true,
Expand All @@ -1152,6 +1153,27 @@ export class DataSources {
BottomPane.response.validateRecordCount(expectedRecordsCount);
}

public runQueryAndVerifyResponseViews(
expectedRecordsCount = 1,
tableCheck = true,
) {
this.RunQuery();
if (tableCheck) {
BottomPane.response.openResponseTypeMenu();

this.agHelper.AssertElementVisibility(
BottomPane.response.getResponseTypeMenuItem("TABLE"),
);
this.agHelper.AssertElementVisibility(
BottomPane.response.getResponseTypeMenuItem("JSON"),
);
this.agHelper.AssertElementVisibility(
BottomPane.response.getResponseTypeMenuItem("RAW"),
);
}
BottomPane.response.validateRecordCount(expectedRecordsCount);
}

public CreateDataSource(
dsType:
| "Postgres"
Expand Down
32 changes: 27 additions & 5 deletions app/client/cypress/support/Pages/IDE/BottomPane/Response.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
class Response {
private ResponseTab = "//button[@data-testid='t--tab-RESPONSE_TAB']";
private locators = {
responseTab: "//button[@data-testid='t--tab-RESPONSE_TAB']",
responseDataContainer: "[data-testid='t--query-response-data-container']",
responseTypeMenuTrigger: "[data-testid='t--query-response-type-trigger']",
responseType(type: string): string {
return `//div[@data-testid='t--response-tab-segmented-control']//span[text()='${type}']`;
},
responseTypeMenuItem(type: string): string {
return `//div[@data-testid='t--query-response-type-menu-item' and @data-value='${type}']`;
},
};

/** @deprecated */
public getResponseTypeSelector = this.locators.responseType;

public getResponseTypeMenuItem = this.locators.responseTypeMenuItem;

public switchToResponseTab(): void {
cy.xpath(this.ResponseTab).click({ force: true });
cy.xpath(this.locators.responseTab).click({ force: true });
}

public getResponseTypeSelector(type: string): string {
return `//div[@data-testid='t--response-tab-segmented-control']//span[text()='${type}']`;
public openResponseTypeMenu() {
cy.get(this.locators.responseDataContainer).realHover();
cy.get(this.locators.responseTypeMenuTrigger).realClick();
}

public selectResponseResponseTypeFromMenu(type: string): void {
this.switchToResponseTab();
this.openResponseTypeMenu();
cy.xpath(this.locators.responseTypeMenuItem(type)).realClick();
}

public switchResponseType(type: string): void {
this.switchToResponseTab();
cy.xpath(this.getResponseTypeSelector(type)).click({ force: true });
cy.xpath(this.locators.responseType(type)).click({ force: true });
}

// TODO: Implement this method when response UI is ready
Expand Down
Loading

0 comments on commit 041e7b6

Please sign in to comment.