PromucFlow_constructor/app/client/test/factories/DatasourceFactory.ts
ashit-rath a72ae578bf
chore: Refactor DataSidePane to accept selector as prop to show usage messages in EE (#32870)
## Description
Adds a couple of props to alter the data displayed in the datasources
left pane to show the right count of entities using datasource. This
props are going to be used in Packages and Workflow editors datasources
page.

PR for https://github.com/appsmithorg/appsmith-ee/pull/4026

## Automation

/ok-to-test tags="@tag.IDE, @tag.Datasource, @tag.Sanity"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/8843287060>
> Commit: 66a5282be88c27fab11316bd136d88bc74de5d5b
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8843287060&attempt=1"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->










## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Enhanced the `DataSidePane` to display the name and count of actions,
improving the informational context for users.
- Added a new selector function to calculate and display the count of
queries for each datasource in the app.
- Introduced a `DatasourceFactory` for generating mock datasource
objects for testing purposes.
- Expanded the list of plugin package names in the `MockPluginsState` to
include additional plugins like `MY_SQL`, `S3`, `SNOWFLAKE`,
`FIRESTORE`, `GRAPHQL`, `APPSMITH_AI`, `MS_SQL`, `ORACLE`, and
`WORKFLOW`.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-04-26 15:38:25 +05:30

53 lines
1.6 KiB
TypeScript

import * as Factory from "factory.ts";
import { PluginPackageName } from "entities/Action";
import { PluginIDs } from "test/factories/MockPluginsState";
import { DatasourceConnectionMode, type Datasource } from "entities/Datasource";
import { SSLType } from "entities/Datasource/RestAPIForm";
interface DatasourceFactory extends Datasource {
pluginPackageName?: PluginPackageName;
}
export const datasourceFactory = (pluginPackageName?: PluginPackageName) =>
Factory.Sync.makeFactory<DatasourceFactory>({
id: "ds-id",
userPermissions: [
"create:datasourceActions",
"execute:datasources",
"delete:datasources",
"manage:datasources",
"read:datasources",
],
name: "Mock_DB",
pluginId: PluginIDs[pluginPackageName || PluginPackageName.POSTGRES],
workspaceId: "workspace-id",
datasourceStorages: {
"65fc11feb48e3e52a6d91d34": {
datasourceId: "65fc124fb48e3e52a6d91d44",
environmentId: "65fc11feb48e3e52a6d91d34",
datasourceConfiguration: {
url: "mockdb.internal.appsmith.com",
connection: {
mode: DatasourceConnectionMode.READ_ONLY,
ssl: {
authType: SSLType.DEFAULT,
authTypeControl: false,
certificateFile: {
name: "",
base64Content: null,
},
},
},
authentication: {
authenticationType: "dbAuth",
username: "mockdb",
},
},
isConfigured: true,
isValid: true,
},
},
invalids: [],
messages: [],
});