-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat: Made changes to support datasources configuration page for workspace #41324
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
base: release
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,233 @@ | ||
| import * as _ from "../../../../support/Objects/ObjectsCore"; | ||
| import { | ||
| agHelper, | ||
| dataSources, | ||
| assertHelper, | ||
| } from "../../../../support/Objects/ObjectsCore"; | ||
| import { ObjectsRegistry } from "../../../../support/Objects/Registry"; | ||
|
|
||
| describe( | ||
| "Workspace Datasource Settings", | ||
| { tags: ["@tag.Workspace", "@tag.Datasource", "@tag.Sanity"] }, | ||
| function () { | ||
| const locator = ObjectsRegistry.CommonLocators; | ||
|
|
||
| beforeEach(() => { | ||
| // Start datasource routes | ||
| dataSources.StartDataSourceRoutes(); | ||
| }); | ||
|
|
||
| it("1. Workspace menu Datasources option should show an empty list and available plugins", function () { | ||
| _.homePage.NavigateToHome(); | ||
| _.agHelper.GenerateUUID(); | ||
| cy.get("@guid").then((uid) => { | ||
| const workspaceId = String(uid); | ||
| _.homePage.CreateNewWorkspace(workspaceId); | ||
|
|
||
| // Open the workspace menu (triple dot) and click the Datasources option | ||
| _.homePage.OpenWorkspaceOptions(workspaceId); | ||
| agHelper.GetNClick(locator.workspaceDatasources); | ||
|
|
||
| assertHelper.AssertNetworkStatus("@getDataSources", 200); | ||
|
|
||
| agHelper.AssertElementVisibility(locator.workspaceDatasourcesPage); | ||
|
|
||
| // No datasources should be present yet | ||
| cy.get(locator._datasource).should("have.length", 0); | ||
|
|
||
| // Workspace datasources main blank state should be visible | ||
| agHelper.AssertElementVisibility(locator._dataBlankState); | ||
|
|
||
| // Blank state CTA should be visible | ||
| agHelper.GetNClick(locator._addDatasourceButtonBlankScreen); | ||
|
|
||
| // When blank state CTA is shown, the header + icon should NOT be visible | ||
| agHelper.AssertElementAbsence(locator._addDatasourceButton); | ||
| }); | ||
| }); | ||
|
|
||
| it("1.a Blank state CTA navigation should not show + icon on Connect a datasource page", function () { | ||
| _.homePage.NavigateToHome(); | ||
| _.agHelper.GenerateUUID(); | ||
| cy.get("@guid").then((uid) => { | ||
| const workspaceId = String(uid); | ||
| _.homePage.CreateNewWorkspace(workspaceId); | ||
|
|
||
| _.homePage.OpenWorkspaceOptions(workspaceId); | ||
| agHelper.GetNClick(locator.workspaceDatasources); | ||
|
|
||
| assertHelper.AssertNetworkStatus("@getDataSources", 200); | ||
|
|
||
| // Click the blank state CTA button (Bring your data) | ||
| agHelper.GetNClick(locator._addDatasourceButtonBlankScreen); | ||
|
|
||
| // We should be on the Connect a datasource page | ||
| cy.location("pathname").should( | ||
| "match", | ||
| /^\/workspace\/[^/]+\/datasources\/NEW$/, | ||
| ); | ||
|
|
||
| // On Connect a datasource page, the header + icon should NOT be visible | ||
| agHelper.AssertElementAbsence(locator._addDatasourceButton); | ||
| }); | ||
| }); | ||
|
|
||
| it("2. Should allow adding DB and REST API datasources from workspace settings", function () { | ||
| _.homePage.NavigateToHome(); | ||
| _.agHelper.GenerateUUID(); | ||
| cy.get("@guid").then((uid) => { | ||
| const workspaceId = String(uid); | ||
| _.homePage.CreateNewWorkspace(workspaceId); | ||
|
|
||
| cy.intercept("POST", "/api/v1/datasources/mocks").as( | ||
| "addMockDatasource", | ||
| ); | ||
|
|
||
| _.homePage.OpenWorkspaceOptions(workspaceId); | ||
| agHelper.GetNClick(locator.workspaceDatasources); | ||
|
|
||
| assertHelper.AssertNetworkStatus("@getDataSources", 200); | ||
|
|
||
| agHelper.GetNClick(locator._addDatasourceButtonBlankScreen); | ||
|
|
||
| cy.contains(locator._mockDatasourceName, "Users") | ||
| .should("be.visible") | ||
| .click(); | ||
|
|
||
| assertHelper.AssertNetworkStatus("@addMockDatasource", 200); | ||
|
|
||
| cy.location("pathname").should( | ||
| "match", | ||
| /^\/workspace\/[^/]+\/datasource\/[^/]+$/, | ||
| ); | ||
| cy.contains("View data").should("be.visible"); | ||
| cy.contains("Configurations").should("be.visible"); | ||
| cy.contains("button", "Edit").should("be.visible"); | ||
|
|
||
| agHelper.GetNClick(dataSources._addNewDataSource, 0, true); | ||
| agHelper.AssertElementVisibility(locator._newIntegrationsWrapper); | ||
|
|
||
| cy.contains(locator._datasourceName, "Authenticated API") | ||
| .scrollIntoView() | ||
| .should("be.visible") | ||
| .click({ force: true }); | ||
|
|
||
| agHelper.RenameDatasource("Mock API"); | ||
| agHelper.TypeText("input[name='url']", "https://mock-api.appsmith.com"); | ||
|
|
||
| agHelper.GetNClick(dataSources._saveDs); | ||
| assertHelper.AssertNetworkStatus("@saveDatasource", 201); | ||
|
|
||
| cy.contains("button", "Edit").should("be.visible"); | ||
| cy.get(locator._datasource).contains("Users").should("be.visible"); | ||
| cy.get(locator._datasource).contains("Mock API").should("be.visible"); | ||
| cy.get(locator._datasource).should("have.length.at.least", 2); | ||
| }); | ||
| }); | ||
|
|
||
| it("3. Should support deleting workspace datasources via the context menu", function () { | ||
| _.homePage.NavigateToHome(); | ||
| _.agHelper.GenerateUUID(); | ||
| cy.get("@guid").then((uid) => { | ||
| const workspaceId = String(uid); | ||
| _.homePage.CreateNewWorkspace(workspaceId); | ||
|
|
||
| cy.intercept("POST", "/api/v1/datasources/mocks").as( | ||
| "addMockDatasource", | ||
| ); | ||
|
|
||
| _.homePage.OpenWorkspaceOptions(workspaceId); | ||
| agHelper.GetNClick(locator.workspaceDatasources); | ||
| assertHelper.AssertNetworkStatus("@getDataSources", 200); | ||
|
|
||
| agHelper.GetNClick(locator._addDatasourceButtonBlankScreen); | ||
|
|
||
| cy.contains(locator._mockDatasourceName, "Users") | ||
| .should("be.visible") | ||
| .click(); | ||
|
|
||
| assertHelper.AssertNetworkStatus("@addMockDatasource", 200); | ||
|
|
||
| cy.location("pathname").should( | ||
| "match", | ||
| /^\/workspace\/[^/]+\/datasource\/[^/]+$/, | ||
| ); | ||
| cy.contains("View data").should("be.visible"); | ||
| cy.contains("Configurations").should("be.visible"); | ||
| cy.contains("button", "Edit").should("be.visible"); | ||
|
|
||
| agHelper.GetNClick(locator._contextMenuTrigger, 0, true); | ||
|
|
||
| agHelper.GetNClick(locator._datasourceOptionDelete, 0, true); | ||
|
|
||
| cy.contains("span", "Are you sure?") | ||
| .should("be.visible") | ||
| .click({ force: true }); | ||
|
Comment on lines
+163
to
+165
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Replace plain element selector with a locator variable. The selector Based on coding guidelines: "Use locator variables for locators and do not use plain strings." Apply this pattern: - cy.contains("span", "Are you sure?")
- .should("be.visible")
- .click({ force: true });
+ agHelper.GetNClick(locator._confirmDeleteButton);Add
🤖 Prompt for AI Agents |
||
| assertHelper.AssertNetworkStatus("@deleteDatasource", 200); | ||
|
|
||
| cy.get(locator._datasource).should("have.length", 0); | ||
| cy.contains("Connect a datasource").should("be.visible"); | ||
| }); | ||
| }); | ||
|
|
||
| it("4. Should keep edits when saving changes from the discard dialog", function () { | ||
| _.homePage.NavigateToHome(); | ||
| _.agHelper.GenerateUUID(); | ||
| cy.get("@guid").then((uid) => { | ||
| const workspaceId = String(uid); | ||
| _.homePage.CreateNewWorkspace(workspaceId); | ||
|
|
||
| cy.intercept("POST", "/api/v1/datasources/mocks").as( | ||
| "addMockDatasource", | ||
| ); | ||
|
|
||
| _.homePage.OpenWorkspaceOptions(workspaceId); | ||
| agHelper.GetNClick(locator.workspaceDatasources); | ||
| assertHelper.AssertNetworkStatus("@getDataSources", 200); | ||
|
|
||
| agHelper.GetNClick(locator._addDatasourceButtonBlankScreen); | ||
|
|
||
| cy.contains(locator._mockDatasourceName, "Users") | ||
| .should("be.visible") | ||
| .click(); | ||
| assertHelper.AssertNetworkStatus("@addMockDatasource", 200); | ||
|
|
||
| agHelper.GetNClick(dataSources._addNewDataSource, 0, true); | ||
| agHelper.AssertElementVisibility(locator._newIntegrationsWrapper); | ||
|
|
||
| cy.contains(locator._datasourceName, "Authenticated API") | ||
| .scrollIntoView() | ||
| .should("be.visible") | ||
| .click({ force: true }); | ||
|
|
||
| agHelper.RenameDatasource("Mock API"); | ||
| agHelper.TypeText("input[name='url']", "https://mock-api.appsmith.com"); | ||
|
|
||
| agHelper.GetNClick(dataSources._saveDs); | ||
| assertHelper.AssertNetworkStatus("@saveDatasource", 201); | ||
|
|
||
| cy.contains("button", "Edit").should("be.visible").click(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Replace plain element selector with a locator variable. The selector Based on coding guidelines: "Use locator variables for locators and do not use plain strings." Apply this pattern: - cy.contains("button", "Edit").should("be.visible").click();
+ agHelper.GetNClick(locator._editDatasourceButton);Add
🤖 Prompt for AI Agents |
||
|
|
||
| agHelper.TypeText( | ||
| `${locator._headersArray} input[name$='.key']`, | ||
| "Content-Type", | ||
| ); | ||
| agHelper.TypeText( | ||
| `${locator._headersArray} input[name$='.value']`, | ||
| "application/json", | ||
| ); | ||
|
Comment on lines
+211
to
+218
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Replace attribute selectors with data-testid based locator variables. The composite selectors using Based on coding guidelines: "Avoid Xpaths, Attributes and CSS path" and "Use data-* attributes for selectors." Apply this pattern: - agHelper.TypeText(
- `${locator._headersArray} input[name$='.key']`,
- "Content-Type",
- );
- agHelper.TypeText(
- `${locator._headersArray} input[name$='.value']`,
- "application/json",
- );
+ agHelper.TypeText(locator._headerKeyInput, "Content-Type");
+ agHelper.TypeText(locator._headerValueInput, "application/json");Add to commonLocators.json: "_headerKeyInput": "[data-testid='t--header-key-input']",
"_headerValueInput": "[data-testid='t--header-value-input']"🤖 Prompt for AI Agents |
||
|
|
||
| agHelper.GetNClick(locator._cancelEditDatasource); | ||
| cy.contains(".ads-v2-modal__content-header", "Are you sure?").should( | ||
| "be.visible", | ||
| ); | ||
|
Comment on lines
+221
to
+223
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Replace CSS class selector with a data-testid based locator variable. The selector Based on coding guidelines: "Use data-* attributes for selectors" and "Avoid CSS path." Apply this pattern: - cy.contains(".ads-v2-modal__content-header", "Are you sure?").should(
- "be.visible",
- );
+ agHelper.AssertElementVisibility(locator._discardChangesModalHeader);
+ cy.contains(locator._discardChangesModalHeader, "Are you sure?").should("be.visible");Add
|
||
| agHelper.GetNClick(locator._datasourceModalSave); | ||
| assertHelper.AssertNetworkStatus("@updateDatasource", 200); | ||
|
|
||
| cy.contains("button", "Edit").should("be.visible"); | ||
| cy.contains(locator._datasource, "Users").should("be.visible"); | ||
| cy.contains(locator._datasource, "Mock API").should("be.visible"); | ||
| }); | ||
| }); | ||
| }, | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { ReduxActionTypes } from "ee/constants/ReduxActionConstants"; | ||
|
|
||
| export interface InitWorkspaceDatasourcePayload { | ||
| workspaceId: string; | ||
| } | ||
|
|
||
| export const initWorkspaceDatasource = ( | ||
| payload: InitWorkspaceDatasourcePayload, | ||
| ) => ({ | ||
| type: ReduxActionTypes.INITIALIZE_WORKSPACE_DATASOURCE, | ||
| payload, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Replace plain attribute selector with a locator variable.
The selector
"input[name='url']"violates the guideline to use locator variables and avoid attribute selectors. Define this selector incommonLocators.jsonand reference it via the locator variable.Based on coding guidelines: "Use locator variables for locators and do not use plain strings" and "Avoid Xpaths, Attributes and CSS path."
Apply this pattern:
Add
_datasourceUrl: "input[data-testid='t--datasource-url']"to commonLocators.json.🤖 Prompt for AI Agents