Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into feature/225-1-5-…
Browse files Browse the repository at this point in the history
…subgraph-add-reputationToken
  • Loading branch information
rulfo71 committed Mar 1, 2023
2 parents f11f09b + ebf9e18 commit 9b84c8f
Show file tree
Hide file tree
Showing 88 changed files with 1,675 additions and 748 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build dapp
run: CI=false pnpm run davi:build
run: CI=false pnpm run davi:build-graph-client && pnpm run davi:dev

- name: Archive artifacts
uses: actions/upload-artifact@v2
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/tests-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,7 @@ jobs:
run: node apps/davi/scripts/beforeBuild.js

- name: Run Jests Test
run: pnpm run test
run: pnpm run test --force

- name: Run code format check
run: pnpm run format-check









run: pnpm run format-check
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
## How to setup

1. Create a fork of this repo.
2. Clone your fork installing submodules `git clone --recurse-submodules [your-github-fork-url.git]`
2. Clone your fork installing submodules `git clone --recurse-submodules [your-github-fork-url.git]`. If you clone this repo without `--recurse-submodules` be sure to go to `packages/dxdao-contracts` and clone necesary branch pointed in `./.gitmodules` file.
3. Install dependencies `pnpm i`
4. Make an `.env` file in the `./packages/dev-scripts`folder (see `.env.example`) and write a seed phrase and deploy salt for hardhat.
5. Make an `.env` file in the `./apps/davi`folder (see `.env.example`).
4. Make an `.env` file in the `./packages/dev-scripts` folder (see `.env.example`) and write a seed phrase and deploy salt for hardhat.
5. Make an `.env` file in the `./apps/davi` folder (see `.env.example`).

## Development

To run project locally you need to compile contracts, run hardhat node from dev-scripts, run docker graph-node container, create/deploy local subgraphs and run davi-frontend. Currently`pnpm dev` from root project won't work. To do so, you need to run 4 different processes:

1. Run hardhat node locally: `pnpm run dev-scripts:dev`
2. Start docker containers: `pnpm run graph-node:dev` (Will require hardhat to be running and docker to be installed and open)
3. Create and deploy local subgraphs (1.5 & guilds): `pnpm run subgraph:dev` (graph-node container should be running. Verify before execute start-local).
4. After both subgraphs are deployed locally, build DAVI graph-client & run dApp with: `pnpm run davi:dev`. If you don't want to wait for hardhat node and subgraphs do `davi:dev-no-wait`
3. Point `deployedHashedBytecodesJSON` to local in `./apps/guilds-subgraph/src/mappings/Create2Deployer/mapping.ts#L13` (const deployedHashedBytecodesJSON = local)
4. Create and deploy local subgraphs (1.5 & guilds): `pnpm run subgraph:dev` (graph-node container should be running. Verify before execute start-local).
5. After both subgraphs are deployed locally, build DAVI graph-client & run dApp with: `pnpm run davi:dev`. If you don't want to wait for hardhat node and subgraphs do `davi:dev-no-wait`

### If you're on Linux:

Expand Down Expand Up @@ -92,3 +93,27 @@ If you see `permission denied: ./packages/graph-node/scripts/dev.sh` you might n
```
chmod +x ./packages/graph-node/scripts/dev.sh
```

# DAVI Monorepo QA tests

## Prerequisites

1. Navigate to `apps/davi`
2. Run `pnpm i`
3. Make an `.env` file in the `davi` folder (see `.env.qa.example`) - file contains all parameters for `localhost` and `metamask` setups

### How to run test

To run Smoke test in terminal run:

`pnpm test:[testName]`

All available `[testName]` can be found in:

`apps > davi > cypress > config`

Currently there are:

1. `smokeLocal` - starts localhost:3000 and runs Smoke test on local
2. `smokeQa` - runs Smoke test on QA ENV
3. `smokeProd` - runs Smoke test on PROD ENV
2 changes: 1 addition & 1 deletion apps/dao-subgraph/scripts/generate-prod-networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fs.writeFileSync(
path.resolve(__dirname, '../networks.json'),
JSON.stringify(
{
private: {
gnosis: {
PermissionRegistry: {
address: '0x89df00AD80781349BE54232A06353b47B0EA3069',
startBlock: 1,
Expand Down
25 changes: 25 additions & 0 deletions apps/davi/cypress/config/local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"baseUrl": "http://localhost:3000/#",
"projectId": "zps4ub",
"experimentalStudio": true,
"viewportWidth": 1920,
"viewportHeight": 1080,
"userAgent": "synpress",
"retries": { "runMode": 0, "openMode": 0 },
"integrationFolder": "cypress/integration",
"screenshotsFolder": "cypress/screenshots",
"videosFolder": "cypress/videos",
"chromeWebSecurity": true,
"component": {
"componentFolder": "src",
"testFiles": "**/*spec.{js,jsx,ts,tsx}"
},
"env": {
"coverage": false,
"network": "localhost"
},
"defaultCommandTimeout": 120000,
"pageLoadTimeout": 120000,
"requestTimeout": 120000
}

5 changes: 5 additions & 0 deletions apps/davi/cypress/config/prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./local.json",
"baseUrl": "https://app.projectdavi.eth.limo/#/homestead"
}

5 changes: 5 additions & 0 deletions apps/davi/cypress/config/qa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./local.json",
"baseUrl": "https://qa.projectdavi.eth.limo/#/homestead"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Filename: CreateDiscussionTest.spec.ts
//

/// <reference types="cypress" />

import LandingPage from '../../support/pageObjects/LandingPage';
import Guilds from '../../support/pageObjects/Guilds';
import AnyGuildPage from '../../support/pageObjects/AnyGuildPage';
import CreateDiscussionPage from '../../support/pageObjects/CreateDiscussionPage';
import { clickAnywhereToClose, gnosisNetworkGuilds } from '../../utils';
import { data } from '../../utils/constants'
const url = Cypress.config().baseUrl;

describe('Check create discussion', () => {
before(() => {
cy.visit(url);
});

it('Click connect wallet and choose metamask', () => {
Guilds.clickOpenWalletModalBtn();
cy.contains('MetaMask').eq(0).click();
});

it('Accept metamask access', () => {
cy.acceptMetamaskAccess().should("be.true");
clickAnywhereToClose();
});

it('Go to gnosis network', () => {
LandingPage.goToGnosisNetwork();
});

it('Allow gnosis network', () => {
cy.allowMetamaskToAddNetwork()
});

it('Allow to switch to gnosis', () => {
cy.allowMetamaskToSwitchNetwork()
});

it(`Visit first Guild on Gnosis network`, () => {
LandingPage.goToGuildPage(gnosisNetworkGuilds[0], 0);
AnyGuildPage.checkIfYouAreOnSelectedGuildPage(gnosisNetworkGuilds[0])
});

it('Create Discussion on Gnosis network', () => {
AnyGuildPage.createDiscussion_Button().click()
cy.confirmMetamaskSignatureRequest()
CreateDiscussionPage.enterTitle(data.discussionTitle)
CreateDiscussionPage.enterDiscussionDescription(data.discussionDescription)
CreateDiscussionPage.clickCreateDiscussion()
});

it('Check if newly created discussion is showing', () => {
CreateDiscussionPage.clickNewDiscussion(data.discussionTitle)
AnyGuildPage.checkDiscussionName(data.discussionTitle)
AnyGuildPage.checkDiscussionDescription(data.discussionDescription)
});

});
9 changes: 4 additions & 5 deletions apps/davi/cypress/integration/smoke/SmokeTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

/// <reference types="cypress" />

import configDevelopmentJSON from '../../config/development.json';
import LandingPage from '../../support/pageObjects/LandingPage';
import AnyGuildPage from '../../support/pageObjects/AnyGuildPage';
import CreateProposalPage from '../../support/pageObjects/CreateProposalPage';
import { clickAnywhereToClose, ethereumNetworkGuilds, gnosisNetworkGuilds } from '../../utils';

const url = Cypress.config().baseUrl;

describe('Check Project-DAVI', () => {

before(() => {
cy.visit(configDevelopmentJSON.baseUrl);
cy.visit(url);
LandingPage.goToGnosisNetwork();
});

Expand All @@ -30,9 +29,9 @@ describe('Check Project-DAVI', () => {
clickAnywhereToClose();
});

it('Check Footer links'), () => {
it('Check Footer links', () => {
LandingPage.checkFooterLinks();
};
});

// TODO: ATM only asserting Gnosis network
gnosisNetworkGuilds.forEach((guildName, i) => {
Expand Down
63 changes: 34 additions & 29 deletions apps/davi/cypress/support/pageObjects/AnyGuildPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ class AnyGuildPage {
public firstDiscussionCard: string;
public firstDiscussionCreator: string;
public firstDiscussionTitle: string;
public createDiscussionButton: string;
public discussionPageCreator: string;
public discussionPageTitle: string;
public discussionPageDescription: string;
public discussionPageBackButton: string;
public creatorName: string;
public createProposalButton: string;
Expand All @@ -59,29 +56,36 @@ class AnyGuildPage {
this.proposalPageTitle = 'proposal-page-title';
this.proposalPageBackButton = 'proposal-back-btn';
this.creatorName = 'creator-address-name';
this.createProposalButton = 'create-proposal-btn';
this.createProposalButton = 'create-proposal-button';
// Discussions
this.allDiscussionPage = 'all-discussions-page';
this.firstDiscussionCard = 'discussion-card';
this.firstDiscussionCreator = 'discussion-creator';
this.firstDiscussionTitle = 'discussion-title';
this.discussionPageTitle = 'discussion-page-title';
this.discussionPageDescription = 'discussion-page-description';
this.createDiscussionButton = 'create-discussion-btn';
this.discussionPageBackButton = 'discussion-back-btn';
}

createDiscussion_Button() { return cy.findAllByTestId("create-discussion-btn");}
discussionPageTitle_Text() { return cy.findAllByTestId("discussion-page-title");}
discussionPageDescription_Text() { return cy.findAllByTestId("discussion-page-description");}

checkIfYouAreOnSelectedGuildPage(guildName) {
cy.findAllByTestId(this.guildName).contains(guildName);
};

checkDiscussionName(discussionName) {
this.discussionPageTitle_Text().should('include.text', discussionName)
}

checkDiscussionDescription(discussionDescription) {
this.discussionPageDescription_Text().should('include.text', discussionDescription)
}

// Governance page
checkIfYouAreOnGovernancePage() {
cy.findByTestId(this.governancePage)
.contains('Governance')
.should('have.css', 'color', 'rgb(222, 255, 78)');
cy.findByTestId(this.createDiscussionButton).should('be.visible');
this.createDiscussion_Button().should('be.visible');
};

// If there are no Active or Executable proposals there should be message with hyperlink
Expand Down Expand Up @@ -115,38 +119,38 @@ class AnyGuildPage {

checkIfYouAreOnAllProposalsPage() {
cy.findByTestId(this.allProposalsPage)
.contains('All Proposals')
.should('have.css', 'color','rgb(222, 255, 78)'
);
.contains('All proposals')
.should('have.css', 'color', 'rgb(222, 255, 78)'
);
};

checkStateFilterOptions() {
cy.findByTestId(this.stateFilterBtn).contains('State').click();

stateFilterOptions.forEach((option, i) => {
cy.findAllByTestId(this.stateFilterOption)
.eq(i)
.contains(option)
.eq(i)
.contains(option)
});
};

checkActionFilterOptions() {
cy.findByTestId(this.actionFilterBtn).contains('Action').click();

actionFilterOptions.forEach((option, i) => {
cy.findAllByTestId(this.actionFilterBtn)
.eq(i)
.contains(option)
cy.findAllByTestId(this.actionFilterOption)
.eq(i)
.contains(option)
});
};

checkCurrencyFilterOptions() {
cy.findByTestId(this.currencyFilterBtn).contains('Currency').click();
cy.findByTestId(this.currencyFilterBtn).contains('Token').click();

currencyFilterOptions.forEach((option, i) => {
cy.findAllByTestId(this.currencyFilterBtn)
.eq(i)
.contains(option)
cy.findAllByTestId(this.currencyFilterOption)
.eq(i)
.contains(option)
});
};

Expand All @@ -157,7 +161,7 @@ class AnyGuildPage {
.get('input[placeholder="Search proposal"]');
};

// TODO: improve with assertion of proposal creator
// TODO: improve with assertion of proposal creator
goToFirstProposalPage() {
cy.findAllByTestId(this.firstProposalTitle).first().click();
};
Expand All @@ -173,15 +177,16 @@ class AnyGuildPage {

checkIfYouAreOnAllDiscussionPage() {
cy.findByTestId(this.allDiscussionPage)
.contains('All Discussions')
.should('have.css', 'color','rgb(222, 255, 78)'
);
cy.findByTestId(this.createDiscussionButton).should('be.visible');
.contains('All discussions')
.should('have.css', 'color', 'rgb(222, 255, 78)'
);
this.createDiscussion_Button().should('be.visible');
};

// TODO: improve with assertion of discussion creator
goToFirstDiscussionPage() {
cy.findAllByTestId(this.firstDiscussionTitle).should('be.visible').click();
cy.scrollTo('bottom')
cy.findAllByTestId(this.firstDiscussionTitle).eq(0).should('be.visible').click();
};

returnToGuildPageFromDiscussionPage() {
Expand All @@ -200,7 +205,7 @@ class AnyGuildPage {

// Discussion page
checkIfYouAreOnDiscussionPage() {
cy.findByTestId(this.discussionPageTitle).should('be.visible');
this.discussionPageTitle_Text().should('be.visible');
cy.findByTestId(this.creatorName).should('be.visible');
cy.findByTestId(this.createProposalButton).should('be.visible');
};
Expand Down
30 changes: 30 additions & 0 deletions apps/davi/cypress/support/pageObjects/CreateDiscussionPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Filename: CreateDiscussionPage.ts
//

class CreateDiscussionPage {
discussionTitle_Field() { return cy.findAllByTestId("create-discussion-title"); }
discussionContent_Field() { return cy.findAllByTestId("proposal-description-input"); }
createDiscussion_Button() { return cy.findAllByTestId("create-proposal-action-button"); }

enterTitle(title) {
this.discussionTitle_Field().type(title)
}

enterDiscussionDescription(description) {
this.discussionContent_Field().type(description)
}

clickCreateDiscussion() {
this.createDiscussion_Button().click()
}

clickNewDiscussion(discussionName) {
cy.contains(discussionName).click()
}

};

const createDiscussionPage: CreateDiscussionPage = new CreateDiscussionPage();

export default createDiscussionPage;
Loading

0 comments on commit 9b84c8f

Please sign in to comment.