Skip to content

Commit

Permalink
Merge pull request #817 from hackforla/remove_typescript_errors
Browse files Browse the repository at this point in the history
Remove typescript errors
  • Loading branch information
johnwroge authored Nov 6, 2024
2 parents ee2c8b8 + c2bae7e commit 474d7e8
Show file tree
Hide file tree
Showing 32 changed files with 2,855 additions and 1,898 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/run-tests-v1.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run API and App Tests
name: Run API and Frontend Tests
on:
pull_request:
branches: [main]
Expand Down Expand Up @@ -28,7 +28,7 @@ jobs:
run: poetry install --with test
- name: Run tests
run: poetry run pytest
test-app:
test-frontend:
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -52,4 +52,4 @@ jobs:
install: false
start: npm run dev
working-directory: ./frontend
wait-on: "http://[::1]:4040/"
wait-on: "http://localhost:4040/"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Building with Docker is the simplest option, and debugging applications within t

1. Build and run all containers by running the `docker compose up -d --build` shell command from the root directory:
2. Verify there are no build errors. If there are build errors, reach out to the development team.
3. Open `http://localhost:34828` in any browser to use Home Unite Us.
3. Open `http://localhost:4040` in any browser to use Home Unite Us.

* `pgAdmin4` is available at http://localhost:5050/browser/ to query the database.
* `moto` server is available at http://localhost:5000/moto-api/ to view mocked AWS data.
Expand Down
2 changes: 2 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ poetry install # Installs all dependencies

poetry shell # Activates the virtual environment

fastapi run # Run the Fast API server

# If using a shell use this:
startup_scripts/entrypoint.sh # Creates test users and runs the API in developer mode

Expand Down
3 changes: 2 additions & 1 deletion backend/startup_scripts/setup_moto_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def create(self):
region_name="us-east-1",
aws_access_key_id="testing",
aws_secret_access_key="testing",
endpoint_url=os.environ['COGNITO_ENDPOINT_URL'])
endpoint_url=os.environ['COGNITO_ENDPOINT_URL']
)

# Only create a user pool and test data if one does not already exist
pools = cognito_client.list_user_pools(MaxResults=5)
Expand Down
11 changes: 9 additions & 2 deletions frontend/cypress/e2e/create-new-password.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@ describe('Forgot Password', () => {
});
});

cy.url().should('include', '/guest');
cy.url().then(url => {
cy.log('Current URL:', url);
console.log('Current URL:', url);
});

cy.url().should('include', '/signin');
});

it('should display error message from params', () => {
// To be updated when alerting is finalized in new backend
it.skip('should display error message from params', () => {
const errorMessage = 'Incorrect username or password.';
cy.visit(`/create-password?error=${errorMessage}`);

// the following line fails
cy.findByRole('alert').should('have.text', errorMessage);
});
});
6 changes: 4 additions & 2 deletions frontend/cypress/e2e/forgot-password.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
describe('Forgot Password', () => {
beforeEach(() => {
cy.intercept('POST', '/api/auth/forgot_password', {statusCode: 200}).as(
cy.intercept('POST', '/api/auth/forgot-password', {statusCode: 200}).as(
'forgotPassword',
);

cy.intercept('POST', '/api/auth/forgot_password/confirm', {
cy.intercept('POST', '/api/auth/forgot-password/confirm', {
statusCode: 200,
}).as('forgotPasswordConfirm');
});
Expand Down Expand Up @@ -52,3 +52,5 @@ describe('Forgot Password', () => {
cy.url().should('include', '/signin');
});
});

// path
37 changes: 21 additions & 16 deletions frontend/cypress/e2e/sign-up.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,33 @@ describe('Sign Up', () => {
beforeEach(() => {
if (Cypress.env('USE_MOCK')) {
// While Mocking always return a successful status code
cy.intercept('POST', '/api/auth/signup/coordinator', {
cy.intercept('POST', '/api/auth/signup', {
statusCode: 200,
}).as('signUpCoordinator');

cy.intercept('POST', '/api/auth/signup/host', {statusCode: 200}).as(
'signUpHost',
);
}).as('signUp');
} else {
// cy.intercept without a request will not stub out the real API call
cy.intercept('POST', '/api/auth/signup/coordinator').as(
'signUpCoordinator',
);
cy.intercept('POST', '/api/auth/signup/host').as('signUpHost');
cy.intercept('POST', '/api/auth/signup').as('signUp');
}

cy.intercept('GET', '/api/auth/session', req => {
req.reply({
statusCode: 401,
});
}).as('session');

cy.intercept('GET', '/api/auth/refresh', req => {
req.reply({
statusCode: 401,
});
}).as('refresh');
});

it('user can sign up as a coordinator', () => {
const user = {
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
email: faker.internet.email(),
role: 'coordinator',
password: 'Test123!',
};

Expand All @@ -38,7 +44,7 @@ describe('Sign Up', () => {
.should('be.enabled')
.click();

cy.url().should('include', '/signup/coordinator');
cy.url().should('include', '/signup');

cy.findByRole('button', {name: /sign up/i}).should('be.disabled');

Expand All @@ -50,9 +56,7 @@ describe('Sign Up', () => {
.should('be.enabled')
.click();

cy.wait('@signUpCoordinator')
.its('request.body')
.should('deep.equal', user);
cy.wait('@signUp').its('request.body').should('deep.equal', user);

cy.url().should('include', `signup/success?email=${user.email}`);
});
Expand All @@ -62,6 +66,7 @@ describe('Sign Up', () => {
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
email: faker.internet.email(),
role: 'host',
password: 'Test123!',
};

Expand All @@ -75,7 +80,7 @@ describe('Sign Up', () => {
.should('be.enabled')
.click();

cy.url().should('include', '/signup/host');
cy.url().should('include', '/signup');

cy.findByRole('button', {name: /sign up/i}).should('be.disabled');

Expand All @@ -87,7 +92,7 @@ describe('Sign Up', () => {
.should('be.enabled')
.click();

cy.wait('@signUpHost').its('request.body').should('deep.equal', user);
cy.wait('@signUp').its('request.body').should('deep.equal', user);

cy.url().should('include', `signup/success?email=${user.email}`);
});
Expand Down
12 changes: 7 additions & 5 deletions frontend/cypress/e2e/test-authentication.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ describe('Authentication', () => {
email: '[email protected]',
firstName: 'Test',
lastName: 'User',
id: 2,
role: {
name: 'Guest',
id: 2,
type: 'guest',
},
},
}
Expand All @@ -82,7 +84,7 @@ describe('Authentication', () => {
statusCode: getIsSignedIn() ? 200 : 401,
});
}).as('refresh');
cy.intercept('GET', '/api/auth/user', {
cy.intercept('GET', '/api/users/current', {
statusCode: 200,
body: {
token: 'fake.jwt.token',
Expand All @@ -96,7 +98,7 @@ describe('Authentication', () => {
cy.intercept('POST', '/api/auth/signout').as('signout');
cy.intercept('GET', '/api/auth/session').as('session');
cy.intercept('GET', '/api/auth/refresh').as('refresh');
cy.intercept('GET', '/api/auth/user').as('user');
cy.intercept('GET', '/api/users/current').as('user');
}
});

Expand Down Expand Up @@ -206,8 +208,8 @@ describe('Authentication', () => {
it('should have access to user data after signin', function () {
cy.visit('/signin');
loginUsingUI(this.password, this.email);
cy.wait('@signin').its('response.statusCode').should('be.within', 200, 299);
cy.wait('@user').then(intercept => {

cy.wait('@signin').then(intercept => {
expect(intercept.response?.statusCode).eq(200);
const body = intercept.response?.body;
expect(body).to.have.property('user');
Expand Down
Loading

0 comments on commit 474d7e8

Please sign in to comment.