Skip to content

Commit 474d7e8

Browse files
authored
Merge pull request #817 from hackforla/remove_typescript_errors
Remove typescript errors
2 parents ee2c8b8 + c2bae7e commit 474d7e8

32 files changed

+2855
-1898
lines changed

.github/workflows/run-tests-v1.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run API and App Tests
1+
name: Run API and Frontend Tests
22
on:
33
pull_request:
44
branches: [main]
@@ -28,7 +28,7 @@ jobs:
2828
run: poetry install --with test
2929
- name: Run tests
3030
run: poetry run pytest
31-
test-app:
31+
test-frontend:
3232
runs-on: ubuntu-latest
3333
defaults:
3434
run:
@@ -52,4 +52,4 @@ jobs:
5252
install: false
5353
start: npm run dev
5454
working-directory: ./frontend
55-
wait-on: "http://[::1]:4040/"
55+
wait-on: "http://localhost:4040/"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Building with Docker is the simplest option, and debugging applications within t
5151

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

5656
* `pgAdmin4` is available at http://localhost:5050/browser/ to query the database.
5757
* `moto` server is available at http://localhost:5000/moto-api/ to view mocked AWS data.

backend/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ poetry install # Installs all dependencies
5050

5151
poetry shell # Activates the virtual environment
5252

53+
fastapi run # Run the Fast API server
54+
5355
# If using a shell use this:
5456
startup_scripts/entrypoint.sh # Creates test users and runs the API in developer mode
5557

backend/startup_scripts/setup_moto_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def create(self):
4141
region_name="us-east-1",
4242
aws_access_key_id="testing",
4343
aws_secret_access_key="testing",
44-
endpoint_url=os.environ['COGNITO_ENDPOINT_URL'])
44+
endpoint_url=os.environ['COGNITO_ENDPOINT_URL']
45+
)
4546

4647
# Only create a user pool and test data if one does not already exist
4748
pools = cognito_client.list_user_pools(MaxResults=5)

frontend/cypress/e2e/create-new-password.cy.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,20 @@ describe('Forgot Password', () => {
6363
});
6464
});
6565

66-
cy.url().should('include', '/guest');
66+
cy.url().then(url => {
67+
cy.log('Current URL:', url);
68+
console.log('Current URL:', url);
69+
});
70+
71+
cy.url().should('include', '/signin');
6772
});
6873

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

79+
// the following line fails
7380
cy.findByRole('alert').should('have.text', errorMessage);
7481
});
7582
});

frontend/cypress/e2e/forgot-password.cy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
describe('Forgot Password', () => {
22
beforeEach(() => {
3-
cy.intercept('POST', '/api/auth/forgot_password', {statusCode: 200}).as(
3+
cy.intercept('POST', '/api/auth/forgot-password', {statusCode: 200}).as(
44
'forgotPassword',
55
);
66

7-
cy.intercept('POST', '/api/auth/forgot_password/confirm', {
7+
cy.intercept('POST', '/api/auth/forgot-password/confirm', {
88
statusCode: 200,
99
}).as('forgotPasswordConfirm');
1010
});
@@ -52,3 +52,5 @@ describe('Forgot Password', () => {
5252
cy.url().should('include', '/signin');
5353
});
5454
});
55+
56+
// path

frontend/cypress/e2e/sign-up.cy.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,33 @@ describe('Sign Up', () => {
44
beforeEach(() => {
55
if (Cypress.env('USE_MOCK')) {
66
// While Mocking always return a successful status code
7-
cy.intercept('POST', '/api/auth/signup/coordinator', {
7+
cy.intercept('POST', '/api/auth/signup', {
88
statusCode: 200,
9-
}).as('signUpCoordinator');
10-
11-
cy.intercept('POST', '/api/auth/signup/host', {statusCode: 200}).as(
12-
'signUpHost',
13-
);
9+
}).as('signUp');
1410
} else {
1511
// cy.intercept without a request will not stub out the real API call
16-
cy.intercept('POST', '/api/auth/signup/coordinator').as(
17-
'signUpCoordinator',
18-
);
19-
cy.intercept('POST', '/api/auth/signup/host').as('signUpHost');
12+
cy.intercept('POST', '/api/auth/signup').as('signUp');
2013
}
14+
15+
cy.intercept('GET', '/api/auth/session', req => {
16+
req.reply({
17+
statusCode: 401,
18+
});
19+
}).as('session');
20+
21+
cy.intercept('GET', '/api/auth/refresh', req => {
22+
req.reply({
23+
statusCode: 401,
24+
});
25+
}).as('refresh');
2126
});
2227

2328
it('user can sign up as a coordinator', () => {
2429
const user = {
2530
firstName: faker.person.firstName(),
2631
lastName: faker.person.lastName(),
2732
email: faker.internet.email(),
33+
role: 'coordinator',
2834
password: 'Test123!',
2935
};
3036

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

41-
cy.url().should('include', '/signup/coordinator');
47+
cy.url().should('include', '/signup');
4248

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

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

53-
cy.wait('@signUpCoordinator')
54-
.its('request.body')
55-
.should('deep.equal', user);
59+
cy.wait('@signUp').its('request.body').should('deep.equal', user);
5660

5761
cy.url().should('include', `signup/success?email=${user.email}`);
5862
});
@@ -62,6 +66,7 @@ describe('Sign Up', () => {
6266
firstName: faker.person.firstName(),
6367
lastName: faker.person.lastName(),
6468
email: faker.internet.email(),
69+
role: 'host',
6570
password: 'Test123!',
6671
};
6772

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

78-
cy.url().should('include', '/signup/host');
83+
cy.url().should('include', '/signup');
7984

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

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

90-
cy.wait('@signUpHost').its('request.body').should('deep.equal', user);
95+
cy.wait('@signUp').its('request.body').should('deep.equal', user);
9196

9297
cy.url().should('include', `signup/success?email=${user.email}`);
9398
});

frontend/cypress/e2e/test-authentication.cy.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ describe('Authentication', () => {
5454
5555
firstName: 'Test',
5656
lastName: 'User',
57+
id: 2,
5758
role: {
58-
name: 'Guest',
59+
id: 2,
60+
type: 'guest',
5961
},
6062
},
6163
}
@@ -82,7 +84,7 @@ describe('Authentication', () => {
8284
statusCode: getIsSignedIn() ? 200 : 401,
8385
});
8486
}).as('refresh');
85-
cy.intercept('GET', '/api/auth/user', {
87+
cy.intercept('GET', '/api/users/current', {
8688
statusCode: 200,
8789
body: {
8890
token: 'fake.jwt.token',
@@ -96,7 +98,7 @@ describe('Authentication', () => {
9698
cy.intercept('POST', '/api/auth/signout').as('signout');
9799
cy.intercept('GET', '/api/auth/session').as('session');
98100
cy.intercept('GET', '/api/auth/refresh').as('refresh');
99-
cy.intercept('GET', '/api/auth/user').as('user');
101+
cy.intercept('GET', '/api/users/current').as('user');
100102
}
101103
});
102104

@@ -206,8 +208,8 @@ describe('Authentication', () => {
206208
it('should have access to user data after signin', function () {
207209
cy.visit('/signin');
208210
loginUsingUI(this.password, this.email);
209-
cy.wait('@signin').its('response.statusCode').should('be.within', 200, 299);
210-
cy.wait('@user').then(intercept => {
211+
212+
cy.wait('@signin').then(intercept => {
211213
expect(intercept.response?.statusCode).eq(200);
212214
const body = intercept.response?.body;
213215
expect(body).to.have.property('user');

0 commit comments

Comments
 (0)