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

Cypress testing/add grant creation test #9461

Merged
merged 8 commits into from
Sep 21, 2021
Merged
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
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cache:
npm: false
directories:
- $HOME/.cache/pip
- node_modules
- node_modules/

jobs:
include:
Expand All @@ -46,10 +46,10 @@ jobs:
- sudo apt-get install -y libvips libvips-dev
# Install Node and Python dependencies.
- node --version
- npm install
- yarn install
- pip install -r requirements/test.txt
- npm run eslint
- npm run stylelint
- yarn run eslint
- yarn run stylelint
- (cd app; python3 ./manage.py collectstatic --noinput --disable-collectfast)
- pytest -p no:ethereum -p no:warnings
# Run cypress tests
Expand Down
1 change: 1 addition & 0 deletions app/app/travis.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ GEOIP_PATH=/opt/GeoIP/
WEB3_HTTP_PROVIDER=https://rinkeby.infura.io/v3/e24d261245fa47d28f0bb4b0dda7a2cb
INFURA_USE_V3=True
INFURA_V3_PROJECT_ID=e24d261245fa47d28f0bb4b0dda7a2cb
NETWORK_NAME=localhost
25 changes: 25 additions & 0 deletions app/grants/migrations/0070_auto_20200808_1145.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ def create_grant_type(apps, schema_editor):
print(f'Succesfully Created Grant Type {_type}')


def create_grant_categories(apps, schema_editor):
GrantCategory = apps.get_model('grants', 'GrantCategory')
category_names = [
'blog',
'community',
'COVID19 research',
'COVID19 response',
'defi',
'devEx',
'education',
'eth1.x',
'eth2.0',
'notes',
'reddit',
'scalability',
'security',
'twitter',
'usability',
'wallets',
]
for category_name in category_names:
GrantCategory.objects.get_or_create(category=category_name)


def map_grant_type_to_catergories(apps, schema_editor):
try:
GrantType = apps.get_model('grants', 'GrantType')
Expand Down Expand Up @@ -74,6 +98,7 @@ class Migration(migrations.Migration):

operations = [
migrations.RunPython(create_grant_type),
migrations.RunPython(create_grant_categories),
migrations.RunPython(map_grant_type_to_catergories),
migrations.RunPython(migrate_grant_type)
]
10 changes: 6 additions & 4 deletions app/grants/migrations/0123_auto_20210726_0703.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

# Generated by Django 2.2.24 on 2021-07-26 07:03
import os

from django.db import migrations, models
import economy.models


def port_data(apps, schema_editor):
if not os.getenv('CI'):
pass
zlsgh marked this conversation as resolved.
Show resolved Hide resolved

Grant = apps.get_model('grants', 'Grant')
GrantTag = apps.get_model('grants', 'GrantTag')
GrantCategory = apps.get_model('grants', 'GrantCategory')
Expand Down Expand Up @@ -56,7 +59,6 @@ class Migration(migrations.Migration):
model_name='grant',
name='tags',
field=models.ManyToManyField(blank=True, to='grants.GrantTag'),
)
#,
# migrations.RunPython(port_data)
),
migrations.RunPython(port_data)
]
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"chromeWebSecurity": true,
"baseUrl": "http://localhost:8000",
"projectId": "e7rv3w"
"projectId": "e7rv3w",
"pageLoadTimeout": 90000
}
52 changes: 52 additions & 0 deletions cypress/integration/grants/test_grant_creation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
describe('Creating a new grant', () => {
before(() => {
cy.setupMetamask();
});

beforeEach(() => {
cy.impersonateUser();
});

afterEach(() => {
cy.logout();
});

after(() => {
cy.clearWindows();
});

it('can navigate to the new grant screen', () => {
cy.get('#dropdownProducts').trigger('mouseenter');
cy.get('[data-submenu=products]').find('[data-submenu=grants]').click();

cy.get('#grants-showcase').contains('Create a Grant').click();
cy.url().should('contain', 'grants/new');
});

describe('creation:success - required fields only', () => {
it('submits a grant for review', () => {
cy.visit('grants/new');

cy.get('form').within(() => {
cy.get('input[name=title]').type('Gitcoin Fund');
cy.get('.quill-editor').type('We’re on a mission to build an internet that is open source, collaborative, and economically empowering.');
cy.get('input[name=reference_url]').type('https://gitcoin.co');
cy.get('input[name=twitter_handle_1]').type('@gitcoin');

cy.contains('ETH').click();
cy.get('input[name=eth_payout_address]').type('0xd08Fe0c97c80491C6ee696Ee8151bc6E57d1Bf1d');
cy.get('input[placeholder="Yes/No"]').click();
cy.contains('No, this project has not raised external funding.').click();

cy.get('input[placeholder="Pick a category"]').click();
cy.contains('Community').click();
cy.get('input[placeholder="Add tags to help others discover your grant"]').click();
cy.contains('education').click();

cy.contains('Create Grant').click();
});

cy.url().should('contain', 'gitcoin-fund');
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"babel-loader": "^8.2.2",
"css-loader": "^5.2.4",
"cypress": "^8.3.1",
"cypress-metamask": "github:gitcoinco/cypress-metamask#v1.0.10-dev",
"eslint": "^7.14.0",
"file-loader": "^6.2.0",
"filemanager-webpack-plugin": "^4.0.0",
Expand All @@ -49,7 +50,6 @@
"@joeattardi/emoji-button": "^3.1.1",
"bootstrap": "4.6.0",
"bootstrap-vue": "2.18.0",
"cypress-metamask": "https://github.com/gitcoinco/cypress-metamask",
"daterangepicker": "3.0.5",
"dompurify": "^2.2.9",
"gsap": "3.6.0",
Expand Down
Loading