Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Open-Earth-Foundation/CityCataly…
Browse files Browse the repository at this point in the history
…st into feature/manual-input
  • Loading branch information
lemilonkh committed Aug 31, 2023
2 parents 940b5d9 + 7f51c9b commit 3051f38
Show file tree
Hide file tree
Showing 101 changed files with 5,839 additions and 2,908 deletions.
8 changes: 4 additions & 4 deletions app/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "next",
"rules": {
"react/no-unescaped-entities": "off"
}
"extends": "next",
"rules": {
"react/no-unescaped-entities": "off"
}
}
5 changes: 1 addition & 4 deletions app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": [
"next/core-web-vitals",
"plugin:storybook/recommended"
]
"extends": ["next/core-web-vitals", "plugin:storybook/recommended"]
}
5 changes: 5 additions & 0 deletions app/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore artifacts:
build
coverage
node_modules
.next
3 changes: 3 additions & 0 deletions app/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"semi": true
}
2 changes: 1 addition & 1 deletion app/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Preview } from "@storybook/react";

import '../src/app/globals.css';
import "../src/app/globals.css";

const preview: Preview = {
parameters: {
Expand Down
1 change: 1 addition & 0 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ createuser citycatalyst
```

Then, create the database

```bash
createdb citycatalyst -O citycatalyst
```
Expand Down
44 changes: 22 additions & 22 deletions app/config/config.cjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
const conf = require('dotenv/config');
const conf = require("dotenv/config");

module.exports = {
"development": {
"username": process.env.DATABASE_USER,
"password": process.env.DATABASE_PASSWORD || null,
"database": process.env.DATABASE_NAME,
"host": process.env.DATABASE_HOST,
"dialect": "postgres",
"logging": true
development: {
username: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD || null,
database: process.env.DATABASE_NAME,
host: process.env.DATABASE_HOST,
dialect: "postgres",
logging: true,
},
"test": {
"username": process.env.DATABASE_USER,
"password": process.env.DATABASE_PASSWORD || null,
"database": process.env.DATABASE_NAME,
"host": process.env.DATABASE_HOST,
"dialect": "postgres"
test: {
username: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD || null,
database: process.env.DATABASE_NAME,
host: process.env.DATABASE_HOST,
dialect: "postgres",
},
"production": {
"username": process.env.DATABASE_USER,
"password": process.env.DATABASE_PASSWORD || null,
"database": process.env.DATABASE_NAME,
"host": process.env.DATABASE_HOST,
"dialect": "postgres"
}
}
production: {
username: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD || null,
database: process.env.DATABASE_NAME,
host: process.env.DATABASE_HOST,
dialect: "postgres",
},
};
3 changes: 1 addition & 2 deletions app/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ export default defineConfig({
video: false,
screenshotOnRunFailure: false,
e2e: {
baseUrl: 'http://localhost:3000',
baseUrl: "http://localhost:3000",
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});

43 changes: 21 additions & 22 deletions app/cypress/e2e/login.cy.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
describe('Login page', () => {
it('redirects to dashboard after entering correct data', () => {
cy.visit('/login')
cy.contains('Log In')
cy.get('input[name="email"]').type('test@openearth.org')
cy.get('input[name="password"]').type('password')
cy.get('button[type="submit"]').click()
describe("Login page", () => {
it("redirects to dashboard after entering correct data", () => {
cy.visit("/login");
cy.contains("Log In");
cy.get('input[name="email"]').type("test@openearth.org");
cy.get('input[name="password"]').type("password");
cy.get('button[type="submit"]').click();

cy.url().should('equal', Cypress.config().baseUrl + '/en')
cy.contains('Welcome Back,')
})
cy.url().should("equal", Cypress.config().baseUrl + "/en");
cy.contains("Welcome Back,");
});

it('shows errors when entering invalid data', () => {
cy.visit('/login')
cy.contains('Log In')
it("shows errors when entering invalid data", () => {
cy.visit("/login");
cy.contains("Log In");

cy.get('input[name="email"]').type('testopenearthorg')
cy.get('input[name="password"]').type('pas')
cy.get('button[type="submit"]').click()

cy.url().should('equal', Cypress.config().baseUrl + '/en/login')
cy.contains('valid email address')
cy.contains('Minimum length')
})
})
cy.get('input[name="email"]').type("testopenearthorg");
cy.get('input[name="password"]').type("pas");
cy.get('button[type="submit"]').click();

cy.url().should("equal", Cypress.config().baseUrl + "/en/login");
cy.contains("valid email address");
cy.contains("Minimum length");
});
});
91 changes: 47 additions & 44 deletions app/cypress/e2e/signup.cy.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
describe('Signup page', () => {
it('redirects to dashboard after entering correct data', () => {
cy.visit('/signup')
cy.contains('Sign Up')
cy.get('input[name="name"]').type('Test Account')
cy.get('input[name="email"]').type('test@openearth.org')
cy.get('input[name="password"]').type('Password1')
cy.get('input[name="confirmPassword"]').type('Password1')
cy.get('input[name="inviteCode"]').type('ABCDEF')
cy.get('input[name="acceptTerms"]').siblings('.chakra-checkbox__control').click()
cy.get('button[type="submit"]').click()
describe("Signup page", () => {
it("redirects to dashboard after entering correct data", () => {
cy.visit("/signup");
cy.contains("Sign Up");
cy.get('input[name="name"]').type("Test Account");
cy.get('input[name="email"]').type("test@openearth.org");
cy.get('input[name="password"]').type("Password1");
cy.get('input[name="confirmPassword"]').type("Password1");
cy.get('input[name="inviteCode"]').type("ABCDEF");
cy.get('input[name="acceptTerms"]')
.siblings(".chakra-checkbox__control")
.click();
cy.get('button[type="submit"]').click();

cy.url().should('contain', '/check-email')
cy.contains('Check Your Email')
})
cy.url().should("contain", "/check-email");
cy.contains("Check Your Email");
});

it('shows errors when entering invalid data', () => {
cy.visit('/signup')
cy.contains('Sign Up')
cy.get('input[name="name"]').type('asd')
cy.get('input[name="email"]').type('testopenearthorg')
cy.get('input[name="password"]').type('Pas')
cy.get('input[name="confirmPassword"]').type('Pa1')
cy.get('input[name="inviteCode"]').type('ABCDE')
cy.get('button[type="submit"]').click()
it("shows errors when entering invalid data", () => {
cy.visit("/signup");
cy.contains("Sign Up");
cy.get('input[name="name"]').type("asd");
cy.get('input[name="email"]').type("testopenearthorg");
cy.get('input[name="password"]').type("Pas");
cy.get('input[name="confirmPassword"]').type("Pa1");
cy.get('input[name="inviteCode"]').type("ABCDE");
cy.get('button[type="submit"]').click();

cy.url().should('contain', '/signup')
cy.contains('valid email address')
cy.contains('Minimum length')
cy.contains('Invalid invite code')
cy.contains('Please accept the terms')
})
cy.url().should("contain", "/signup");
cy.contains("valid email address");
cy.contains("Minimum length");
cy.contains("Invalid invite code");
cy.contains("Please accept the terms");
});

it('should require matching passwords', () => {
cy.visit('/signup')
cy.contains('Sign Up')
cy.get('input[name="name"]').type('Test Account')
cy.get('input[name="email"]').type('test@openearth.org')
cy.get('input[name="password"]').type('Password1')
cy.get('input[name="confirmPassword"]').type('Password2')
cy.get('input[name="inviteCode"]').type('ABCDEF')
cy.get('input[name="acceptTerms"]').siblings('.chakra-checkbox__control').click()
cy.get('button[type="submit"]').click()

cy.url().should('contain', '/signup')
cy.contains('Passwords don\'t match')
})
})
it("should require matching passwords", () => {
cy.visit("/signup");
cy.contains("Sign Up");
cy.get('input[name="name"]').type("Test Account");
cy.get('input[name="email"]').type("test@openearth.org");
cy.get('input[name="password"]').type("Password1");
cy.get('input[name="confirmPassword"]').type("Password2");
cy.get('input[name="inviteCode"]').type("ABCDEF");
cy.get('input[name="acceptTerms"]')
.siblings(".chakra-checkbox__control")
.click();
cy.get('button[type="submit"]').click();

cy.url().should("contain", "/signup");
cy.contains("Passwords don't match");
});
});
2 changes: 1 addition & 1 deletion app/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
// }
4 changes: 2 additions & 2 deletions app/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')
// require('./commands')
45 changes: 34 additions & 11 deletions app/migrations/20230728183114-Init.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

/** @type {import('sequelize-cli').Migration} */
module.exports = {
Expand Down Expand Up @@ -475,21 +475,44 @@ module.exports = {

async down(queryInterface) {
const tables = [
'User', 'City', 'CityUser', 'Publisher', 'ReportingLevel', 'Scope',
'Sector', 'SubSector', 'SubCategory', 'ActivityData', 'EmissionsFactor',
'GHGs', 'DataSource', 'Methodology', 'DataSourceActivityData',
'DataSourceEmissionsFactor', 'DataSourceGHGs', 'DataSourceMethodology',
'DataSourceReportingLevel', 'DataSourceScope', 'DataSourceSector',
'DataSourceSubCategory', 'DataSourceSubSector', 'GDP', 'Inventory',
'Population', 'SectorValue', 'SubCategoryValue',
'SubSectorReportingLevel', 'SubSectorScope', 'SubSectorValue', 'Version'
"User",
"City",
"CityUser",
"Publisher",
"ReportingLevel",
"Scope",
"Sector",
"SubSector",
"SubCategory",
"ActivityData",
"EmissionsFactor",
"GHGs",
"DataSource",
"Methodology",
"DataSourceActivityData",
"DataSourceEmissionsFactor",
"DataSourceGHGs",
"DataSourceMethodology",
"DataSourceReportingLevel",
"DataSourceScope",
"DataSourceSector",
"DataSourceSubCategory",
"DataSourceSubSector",
"GDP",
"Inventory",
"Population",
"SectorValue",
"SubCategoryValue",
"SubSectorReportingLevel",
"SubSectorScope",
"SubSectorValue",
"Version",
];

return queryInterface.sequelize.transaction(async (transaction) => {
for (const table of tables) {
await transaction.dropTable(table, { cascade: true, transaction });
}
});
}
},
};

Loading

0 comments on commit 3051f38

Please sign in to comment.