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

Postgres Migration Support for Plugins and Plugin store in orgDashboard #3745

Closed
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
204 changes: 104 additions & 100 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ If you are new to contributing to open source, please read the Open Source Guide
- [Pull Requests](#pull-requests)
- [Branching Strategy](#branching-strategy)
- [Conflict Resolution](#conflict-resolution)
- [Contributing Code](#contributing-code)
- [General:](#general)
- [Testing:](#testing)
- [Jest Testing](#jest-testing)
Expand Down Expand Up @@ -69,10 +68,10 @@ Make sure you are following [issue report guidelines](ISSUE_GUIDELINES.md) avail

#### Branching Strategy

For Talawa Admin, we had employed the following branching strategy to simplify the development process and to ensure that only stable code is pushed to the `main` branch:
For Talawa Admin, we had employed the following branching strategy to simplify the development process and to ensure that only stable code is pushed to the `master` branch:

- `develop`: For unstable code and bug fixing
- `main`: Where the stable production ready code lies. This is our default branch.
- `master`: Where the stable production ready code lies. This is our default branch.

#### Conflict Resolution

Expand All @@ -83,8 +82,6 @@ When multiple developers are working on issues there is bound to be a conflict o
- Last but not the least, communication is important make sure to talk to other contributors, in these cases, in slack channel or in a issue/PR thread.
- As a last resort the Admins would be responsible for deciding how to resolve this conflict.

### Contributing Code

Code contributions to Talawa come in the form of pull requests. These are done by forking the repo and making changes locally.

Make sure you have read the [Documentation for Setting up the Project](https://github.com/PalisadoesFoundation/talawa-admin#project-setup)
Expand All @@ -100,105 +97,112 @@ The process of proposing a change to Talawa Admin can be summarized as:

### General:

- We need to get to 100% test coverage for the app. We periodically increase the desired test coverage for our pull requests to meet this goal.
- Pull requests that don't meet the minimum test coverage levels will not be accepted. This may mean that you will have to create tests for code you did not write. You can decide which part of the code base needs additional tests if this happens to you.
- We need to get to 100% test coverage for the app. We periodically increase the desired test coverage for our pull requests to meet this goal.
- Pull requests that don't meet the minimum test coverage levels will not be accepted. This may mean that you will have to create tests for code you did not write. You can decide which part of the code base needs additional tests if this happens to you.

### Testing:

This section outlines the different testing strategies and tools used in this project. It includes instructions on running tests, viewing code coverage, and debugging using Jest and Vitest. Following these guidelines ensures code reliability and maintains the project's high standards for quality.
#### Jest Testing
- Running a single test:
```
npm run test path/to/test/file
```
- Running all tests:
```
npm run test --watchAll=false
```
- Viewing the code coverage of a single test file:
```
npm run test --watchAll=false --coverage /path/to/test/file
```
- Viewing the code coverage of all test files:
```
npm run test --watchAll=false --coverage
```
- Debug tests in browser
You can see the output of failing tests in broswer by running `jest-preview` package before running your tests
```
npm run jest-preview
npm run test --watchAll=false --coverage
```
You don't need to re-run the `npm run jest-preview` command each time, simply run the `npm run test` command if the Jest Preview server is already running in the background, it'll automatically detect any failing tests and show the preview at `http://localhost:3336` as shown in this screenshot -

![Debugging Test Demo](./public/images/jest-preview.webp)
#### Vitest Testing
- Running a single test:
```
npm run test:vitest /path/to/test/file
```
- Running all tests:
```
npm run test:vitest
```
- Viewing the code coverage of a single test file:
```
npm run test:vitest:coverage /path/to/test/file
```
- Viewing the code coverage of all test files:
```
npm run test:vitest:coverage
```

#### Combined testing and coverage
- Running all tests:
```
npm run test && npm run test:vitest
```
- Viewing combined code coverage:
```
npm run test --watchAll=false --coverage && npm run test:vitest:coverage
```

#### Test Code Coverage:

1. _General Information_
- The current code coverage of the repo is: [![codecov](https://codecov.io/gh/PalisadoesFoundation/talawa-admin/branch/develop/graph/badge.svg?token=II0R0RREES)](https://codecov.io/gh/PalisadoesFoundation/talawa-admin)
- You can determine the percentage test coverage of your code by running these two commands in sequence:
```
npm install
npm run test --watchAll=false --coverage
genhtml coverage/lcov.info -o coverage
```
- The output of the `npm run test` command will give you a tablular coverage report per file
- The overall coverage rate will be visible on the penultimate line of the `genhtml` command's output.
- The `genhtml` command is part of the Linux `lcov` package. Similar packages can be found for Windows and MacOS.
- The currently acceptable coverage rate can be found in the [GitHub Pull Request file](.github/workflows/pull-requests.yml). Search for the value below the line containing `min_coverage`.
2. _Testing Individual Files_
- You can test an individual file by running this command:
```
npm run test --watchAll=false /path/to/test/file
```
- You can get the test coverage report for that file by running this command. The report will list all tests in the suite. Those tests that are not run will have zero values. You will need to look for the output line relevant to your test file.
```
npm run test --watchAll=false --coverage /path/to/test/file
```
3. _Creating your code coverage account_

- You can also see your code coverage online for your fork of the repo. This is provided by `codecov.io`

1. Go to this link: `https://app.codecov.io/gh/XXXX/YYYY` where XXXX is your GitHub account username and YYYY is the name of the repository
2. Login to `codecov.io` using your GitHub account, and add your **repo** and **branches** to the `codecov.io` dashboard.
![Debugging Test Demo](/public/images/codecov/authorise-codecov-github.jpg)
3. Remember to add the `Repository Upload Token` for your forked repo. This can be found under `Settings` of your `codecov.io` account.

4. Click on Setup Repo option
![Debugging Test Demo](</public/images/codecov/homescrenn%20(1).jpg>)
5. Use the value of this token to create a secret named CODE_COV for your forked repo.
[![Code-cov-token.jpg](/public/images/codecov/Code-cov-token.jpg)]()
[![addd-your-key.jpg](/public/images/codecov/addd-your-key.jpg)]()
6. You will see your code coverage reports with every push to your repo after following these steps
[![results.jpg](/public/images/codecov/results.jpg)]()

#### Jest Testing

- Running a single test:
```
npm run test path/to/test/file
```
- Running all tests:
```
npm run test --watchAll=false
```
- Viewing the code coverage of a single test file:
```
npm run test --watchAll=false --coverage /path/to/test/file
```
- Viewing the code coverage of all test files:
```
npm run test --watchAll=false --coverage
```
- Debug tests in browser
You can see the output of failing tests in broswer by running `jest-preview` package before running your tests

```
npm run jest-preview
npm run test --watchAll=false --coverage
```

You don't need to re-run the `npm run jest-preview` command each time, simply run the `npm run test` command if the Jest Preview server is already running in the background, it'll automatically detect any failing tests and show the preview at `http://localhost:3336` as shown in this screenshot -

![Debugging Test Demo](./public/images/jest-preview.webp)

#### Vitest Testing

- Running a single test:
```
npm run test:vitest /path/to/test/file
```
- Running all tests:
```
npm run test:vitest
```
- Viewing the code coverage of a single test file:
```
npm run test:vitest:coverage /path/to/test/file
```
- Viewing the code coverage of all test files:
```
npm run test:vitest:coverage
```

#### Combined testing and coverage

- Running all tests:
```
npm run test && npm run test:vitest
```
- Viewing combined code coverage:
```
npm run test --watchAll=false --coverage && npm run test:vitest:coverage
```

#### Test Code Coverage:

1. _General Information_
- The current code coverage of the repo is: [![codecov](https://codecov.io/gh/PalisadoesFoundation/talawa-admin/branch/develop/graph/badge.svg?token=II0R0RREES)](https://codecov.io/gh/PalisadoesFoundation/talawa-admin)
- You can determine the percentage test coverage of your code by running these two commands in sequence:
```
npm install
npm run test --watchAll=false --coverage
genhtml coverage/lcov.info -o coverage
```
- The output of the `npm run test` command will give you a tablular coverage report per file
- The overall coverage rate will be visible on the penultimate line of the `genhtml` command's output.
- The `genhtml` command is part of the Linux `lcov` package. Similar packages can be found for Windows and MacOS.
- The currently acceptable coverage rate can be found in the [GitHub Pull Request file](.github/workflows/pull-requests.yml). Search for the value below the line containing `min_coverage`.
2. _Testing Individual Files_
- You can test an individual file by running this command:
```
npm run test --watchAll=false /path/to/test/file
```
- You can get the test coverage report for that file by running this command. The report will list all tests in the suite. Those tests that are not run will have zero values. You will need to look for the output line relevant to your test file.
```
npm run test --watchAll=false --coverage /path/to/test/file
```
3. _Creating your code coverage account_

- You can also see your code coverage online for your fork of the repo. This is provided by `codecov.io`

1. Go to this link: `https://app.codecov.io/gh/XXXX/YYYY` where XXXX is your GitHub account username and YYYY is the name of the repository
2. Login to `codecov.io` using your GitHub account, and add your **repo** and **branches** to the `codecov.io` dashboard.
![Debugging Test Demo](/public/images/codecov/authorise-codecov-github.jpg)
3. Remember to add the `Repository Upload Token` for your forked repo. This can be found under `Settings` of your `codecov.io` account.

4. Click on Setup Repo option
![Debugging Test Demo](</public/images/codecov/homescrenn%20(1).jpg>)
5. Use the value of this token to create a secret named CODE_COV for your forked repo.
![Code-cov-token.jpg](/public/images/codecov/Code-cov-token.jpg)
![addd-your-key.jpg](/public/images/codecov/addd-your-key.jpg)
6. You will see your code coverage reports with every push to your repo after following these steps
![results.jpg](/public/images/codecov/results.jpg)

1. After making changes you can add them to git locally using `git add <file_name>`(to add changes only in a particular file) or `git add .` (to add all changes).
1. After adding the changes you need to commit them using `git commit -m '<commit message>'`(look at the commit guidelines below for commit messages).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Defined in: [src/GraphQl/Mutations/mutations.ts:496](https://github.com/Palisado

## Remarks

used `updatePluginStatus`to add or remove the current Organization the in the plugin list `uninstalledOrgs`
Used `updatePluginStatus` to add or remove the current organization in the plugin list `uninstalledOrgs`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Admin Docs](/)

***

# Function: getInstalledIds()

> **getInstalledIds**(`plugins`): `string`[]

Defined in: [src/components/AddOn/core/AddOnStore/AddOnStore.tsx:248](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/core/AddOnStore/AddOnStore.tsx#L248)

## Parameters

### plugins

[`InterfacePluginHelper`](../../../../../../types/AddOn/interface/interfaces/InterfacePluginHelper.md)[]

## Returns

`string`[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Admin Docs](/)

***

# Function: getStorePlugins()

> **getStorePlugins**(): `Promise`\<`void`\>

Defined in: [src/components/AddOn/core/AddOnStore/AddOnStore.tsx:226](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/core/AddOnStore/AddOnStore.tsx#L226)

Fetches store plugins and updates the Redux store with the plugin data.

## Returns

`Promise`\<`void`\>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Admin Docs](/)

***

# Function: markInstalledPlugins()

> **markInstalledPlugins**(`plugins`, `installedIds`): [`InterfacePluginHelper`](../../../../../../types/AddOn/interface/interfaces/InterfacePluginHelper.md)[]

Defined in: [src/components/AddOn/core/AddOnStore/AddOnStore.tsx:238](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/core/AddOnStore/AddOnStore.tsx#L238)

## Parameters

### plugins

[`InterfacePluginHelper`](../../../../../../types/AddOn/interface/interfaces/InterfacePluginHelper.md)[]

### installedIds

`string`[]

## Returns

[`InterfacePluginHelper`](../../../../../../types/AddOn/interface/interfaces/InterfacePluginHelper.md)[]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Class: default

Defined in: [src/components/AddOn/support/services/Plugin.helper.ts:5](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/support/services/Plugin.helper.ts#L5)
Defined in: [src/components/AddOn/support/services/Plugin.helper.ts:4](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/support/services/Plugin.helper.ts#L4)

Helper class for managing plugin-related tasks such as fetching store data, installed plugins, and generating plugin links.

Expand All @@ -22,31 +22,31 @@ Helper class for managing plugin-related tasks such as fetching store data, inst

### fetchInstalled()

> **fetchInstalled**(): `Promise`\<`any`\>
> **fetchInstalled**(): `Promise`\<`unknown`\>

Defined in: [src/components/AddOn/support/services/Plugin.helper.ts:21](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/support/services/Plugin.helper.ts#L21)
Defined in: [src/components/AddOn/support/services/Plugin.helper.ts:20](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/support/services/Plugin.helper.ts#L20)

Fetches the list of installed plugins from a local server.

#### Returns

`Promise`\<`any`\>
`Promise`\<`unknown`\>

A promise that resolves to the installed plugins data in JSON format.

***

### fetchStore()

> **fetchStore**(): `Promise`\<`any`\>
> **fetchStore**(): `Promise`\<`unknown`\>

Defined in: [src/components/AddOn/support/services/Plugin.helper.ts:11](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/support/services/Plugin.helper.ts#L11)
Defined in: [src/components/AddOn/support/services/Plugin.helper.ts:10](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/support/services/Plugin.helper.ts#L10)

Fetches the store data from a local server.

#### Returns

`Promise`\<`any`\>
`Promise`\<`unknown`\>

A promise that resolves to the store data in JSON format.

Expand All @@ -56,15 +56,15 @@ A promise that resolves to the store data in JSON format.

> **generateLinks**(`plugins`): `object`[]

Defined in: [src/components/AddOn/support/services/Plugin.helper.ts:32](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/support/services/Plugin.helper.ts#L32)
Defined in: [src/components/AddOn/support/services/Plugin.helper.ts:33](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/AddOn/support/services/Plugin.helper.ts#L33)

Generates an array of links for the enabled plugins.

#### Parameters

##### plugins

`any`[]
`object`[]

An array of plugin objects.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ Defined in: [src/types/AddOn/interface.ts:33](https://github.com/PalisadoesFound

## Properties

### \_id

> **\_id**: `string`

Defined in: [src/types/AddOn/interface.ts:34](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/types/AddOn/interface.ts#L34)

***

### component

> **component**: `string`
Expand All @@ -32,6 +24,14 @@ Defined in: [src/types/AddOn/interface.ts:41](https://github.com/PalisadoesFound

***

### id

> **id**: `string`

Defined in: [src/types/AddOn/interface.ts:34](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/types/AddOn/interface.ts#L34)

***

### installed

> **installed**: `boolean`
Expand Down
Loading