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

Remove typescript errors #817

Merged
merged 44 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
eedf716
Fixed imports, removed type validation for date
johnwroge Oct 6, 2024
1e6ef23
Fixed imports, removed type validation for date
johnwroge Oct 6, 2024
1984f6a
Removed packagelock.json
johnwroge Oct 7, 2024
ad82d8f
Npm install
johnwroge Oct 7, 2024
7eb65a2
Updated run tests file
johnwroge Oct 7, 2024
4b2c008
Update frontend package lock
paulespinosa Oct 7, 2024
913ecb4
Update frontend package lock
paulespinosa Oct 7, 2024
c17a770
Fixed signupform tests
johnwroge Oct 8, 2024
1362ae9
Update package lock
paulespinosa Oct 7, 2024
522c2dc
Update package lock
paulespinosa Oct 7, 2024
9cfcff3
Fixed resend code success message test
johnwroge Oct 15, 2024
31a181e
Fixed Imports
johnwroge Oct 15, 2024
d91aa8d
Fix display error message in forgot password code test
johnwroge Oct 15, 2024
9835116
Fix run tests yml file with new cypress port
johnwroge Oct 15, 2024
91db276
Updated cypress paths and auth endpoint
johnwroge Oct 15, 2024
fa9f174
Merge branch 'main' into remove_typescript_errors
paulespinosa Oct 15, 2024
8688ea1
Removed comments
johnwroge Oct 15, 2024
a8ffa0d
Update cypress e2e authentication test
paulespinosa Oct 16, 2024
111e219
Add role
johnwroge Oct 18, 2024
868dcdf
Update signup cypress test
johnwroge Oct 18, 2024
875e002
Changes to auth
johnwroge Oct 18, 2024
9b86c3e
Updated file changes
johnwroge Oct 18, 2024
cc8fe2f
Update port used by frontend for development to 4040
paulespinosa Oct 19, 2024
4f1c627
Merge branch 'main' into remove_typescript_errors
paulespinosa Oct 19, 2024
c98c301
Update README with port 4040 used for frontend dev and testing
paulespinosa Oct 19, 2024
f3e3e32
Update packages
erikguntner Oct 23, 2024
c347333
Merge branch 'remove_typescript_errors' of https://github.com/hackfor…
erikguntner Oct 23, 2024
0b5e11a
Added error handling to main.tsx for cypress tests
johnwroge Oct 24, 2024
7a80dae
Remove comments
johnwroge Oct 24, 2024
ffecfd5
Added run command to backend readme and 404 page for frontend
johnwroge Oct 24, 2024
47339fa
Debugging api tests
johnwroge Oct 24, 2024
b3e22db
Debugging api tests
johnwroge Oct 24, 2024
4c2570c
changing github actions file
johnwroge Oct 24, 2024
8689079
reverting changes to runtestv1.yml
johnwroge Oct 24, 2024
4a7142c
sync querys
erikguntner Oct 24, 2024
39e92a9
Merge branch 'remove_typescript_errors' of https://github.com/hackfor…
erikguntner Oct 24, 2024
f2c0801
Updated authentication test
johnwroge Oct 30, 2024
88aff7e
remove error message test
johnwroge Oct 30, 2024
4fe0139
add log to failing test
johnwroge Oct 30, 2024
c2ec972
Update failing tests
johnwroge Oct 30, 2024
78ceee4
Update failing tests
johnwroge Oct 30, 2024
a7e6686
Update failing tests
johnwroge Oct 30, 2024
49700e7
Update failing tests
johnwroge Oct 30, 2024
c2bae7e
Update failing tests
johnwroge Oct 30, 2024
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
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
Loading