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

#github-username #743

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

krafcik02
Copy link

@krafcik02 krafcik02 commented Oct 12, 2024

-create internal User type with github username property,
-create lit task,
-handle error after fetching,

Tests were not implemented, I need your help/ guidance for this part of task. :)

…rty, create lit task, handle error after fetching
@jcscottiii
Copy link
Collaborator

Hey @krafcik02 I haven't forgotten about this. I am just doing a little bit of research. We may be able to do this without calling the GitHub API. I see there's a method called getAdditionalUserInfo [1][2].

You will need to change the signature of signIn to return a Promise instead of Promise by chaining the call from signInWithPopup to get additional info.

If you want to take a look, go ahead. But otherwise, I should get to this some time this week

@krafcik02
Copy link
Author

Hello @jcscottiii, thank you for response. Let me know the future steps you would like to do with implementation :).

if (user !== null) {
this.user =
user !== null ? {...user, gitHubUsername: 'empty'} : undefined;
this._loadingGithubUsername = new Task(this, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will continue to make a request for the information. However, we should:

  1. use octokit. This should simplify the retry logic since the client handles it automatically.
  2. Try to do it without the Task. We actually shouldn't need it. That should make this a lot simpler too.

For step 1: run cd frontend && npm install octokit

@jcscottiii
Copy link
Collaborator

@krafcik02 I left a comment with some more details

@jcscottiii
Copy link
Collaborator

can you rebase your changes? There are some conflicts of two files in your branch vs the main branch.

@jcscottiii
Copy link
Collaborator

Also for testing, there are two types of tests:

  • component testing
  • playwright tests

Let's talk about the playwright tests first.

In the login test file, you will want to intercept the your call to the authenticated user api to supply your own data. Here's an example calling it for another Github API.

You can also assert what happens when the api calls fails by creating a separate test case in that file but have it return a 500 error. Ideally, there should be a toast that comes up. The toast should be triggered from the UI component (the login) and not this firebase auth service. So you will probably need to change FirebaseUser to also have an optional error too.

@krafcik02
Copy link
Author

krafcik02 commented Oct 21, 2024

Also I would like to know more about the DevOps tools and services that the project use in production and in development. I just know that for development we use web Dev Containers extension that allows you to open the project in docker and then the whole app is launched via make start-local command that starts the app in docker. Could you provide some informations ?

@jcscottiii
Copy link
Collaborator

Also I would like to know more about the DevOps tools and services that the project use in production and in development. I just know that for development we use web Dev Containers extension that allows you to open the project in docker and then the whole app is launched via make start-local command that starts the app in docker. Could you provide some informations ? I need that for school exam :), here is my email [email protected].

I recently talked about this :) Feel free to take a look. https://youtu.be/pY29akiiw2U?feature=shared&t=802

@krafcik02
Copy link
Author

I found your guide for running test. I will try and let you know. :) And thank you for provided link to video.

@jcscottiii
Copy link
Collaborator

Also, if you run npx without sudo, is it still not found? If so, you may need to rebuild your devcontainer.

@krafcik02
Copy link
Author

I have tried to run "make playwright-test" command from https://github.com/GoogleChrome/webstatus.dev/blob/main/docs/testing.md but i ran into this error:

`kubectl wait --for=condition=ready --timeout=300s pod/spanner
pod/spanner condition met
Error command: version, version: 1.10.1
Failed to execute the operation to Cloud Spanner, Instance not found: projects/local/instances/local
command terminated with exit code 1
Migration not ready (attempt 0). Retrying in 5 seconds...
Migration not ready (attempt 1). Retrying in 5 seconds...
Migration not ready (attempt 2). Retrying in 5 seconds...
Migration not ready (attempt 3). Retrying in 5 seconds...
Migration not ready (attempt 4). Retrying in 5 seconds...
fuser -k 9010/tcp || true
kubectl port-forward --address 127.0.0.1 pod/spanner 9010:9010 2>&1 >/dev/null &
fuser -k 8086/tcp || true
kubectl port-forward --address 127.0.0.1 pod/datastore 8086:8086 2>&1 >/dev/null &
SPANNER_EMULATOR_HOST=localhost:9010 DATASTORE_EMULATOR_HOST=localhost:8086 go run ./util/cmd/load_fake_data/main.go -spanner_project=local -spanner_instance=local -spanner_database=local -datastore_project=local
2024/10/21 19:41:55 INFO establishing spanner client project=local instance=local database=local
2024/10/21 19:41:55 INFO establishing datastore client project=local database=""
E1021 19:41:55.854262 96523 portforward.go:413] "Unhandled Error" err=<
an error occurred forwarding 8086 -> 8086: error forwarding port 8086 to pod 4d1a6af587858db1c5a7d3a6e491382efe806fa1f7a055fac5c090f1e045d404, uid : exit status 1: 2024/10/21 19:41:55 socat[61685] E connect(5, AF=2 127.0.0.1:8086, 16): Connection refused

error: lost connection to pod
2024/10/21 19:41:57 INFO releases generated "amount of releases created"=200
2024/10/21 19:41:59 INFO features generated "amount of features created"=80`

It got stuck here.

@jcscottiii
Copy link
Collaborator

image

It takes around 2 minutes just for the data load process to run before the tests run themselves. However, I see that port 8086 failed partway through. That's a connection to one of the databases. Could you try again?

@krafcik02
Copy link
Author

Hi @jcscottiii, I have edited the test. Where can I see the code coverage for this project? I need this information for my university exam. :)

@jcscottiii
Copy link
Collaborator

jcscottiii commented Nov 5, 2024

You can see the coverage when running make precommit but it may not be straightforward if you're not familiar with the languages.
There are two languages tested in this repository. Go and Typescript.

Go

We have many Go modules in this repository.

For each module: check the line that has total: You will see that each module has different total coverage.

image

Typescript

This is simpler. At the end of the command, it will print a single coverage amount.

image

Summary

Feel free to check the logs in the run. Example

@krafcik02
Copy link
Author

Maybe you could help again. I run the project in dev containers, run make start-local , then make port-forward-manual in second consol. Then make playwright update snapshots because tests with screenshots were not passing. In console where I ran make start local the datastore is sucesfully created. But I still get this error even after re-launching a few-times and waiting every time at least for 5 minutes. Could you try to test it in my branch ? I do not know what I am doing wrong.

kubectl wait --for=condition=ready --timeout=300s pod/spanner
pod/spanner condition met
Error command: version, version: 1.10.1
Failed to execute the operation to Cloud Spanner, Instance not found: projects/local/instances/local
command terminated with exit code 1
Migration not ready (attempt 0). Retrying in 5 seconds...
Migration not ready (attempt 1). Retrying in 5 seconds...
Migration not ready (attempt 2). Retrying in 5 seconds...
Migration not ready (attempt 3). Retrying in 5 seconds...
Migration not ready (attempt 4). Retrying in 5 seconds...
fuser -k 9010/tcp || true
kubectl port-forward --address 127.0.0.1 pod/spanner 9010:9010 2>&1 >/dev/null &
fuser -k 8086/tcp || true
kubectl port-forward --address 127.0.0.1 pod/datastore 8086:8086 2>&1 >/dev/null &
SPANNER_EMULATOR_HOST=localhost:9010 DATASTORE_EMULATOR_HOST=localhost:8086 go run ./util/cmd/load_fake_data/main.go -spanner_project=local -spanner_instance=local -spanner_database=local -datastore_project=local
2024/11/06 20:04:43 INFO establishing spanner client project=local instance=local database=local
2024/11/06 20:04:43 INFO establishing datastore client project=local database=""
E1106 20:04:43.166832 78609 portforward.go:413] "Unhandled Error" err=<
an error occurred forwarding 8086 -> 8086: error forwarding port 8086 to pod c0dedd91b00a87ec20f97da7a6e684345711bdfc6e515ca5c51838136ec22247, uid : exit status 1: 2024/11/06 20:04:43 socat[43888] E connect(5, AF=2 127.0.0.1:8086, 16): Connection refused

error: lost connection to pod
2024/11/06 20:04:44 INFO releases generated "amount of releases created"=200
2024/11/06 20:04:46 INFO features generated "amount of features created"=80

@jcscottiii
Copy link
Collaborator

I haven't had the chance to check out your branch yet. But, is this still happening? It looks like it lost the connection to the pod. You may also want to run "kubectl describe pods" if it happens again

@krafcik02
Copy link
Author

Okay, I will try out next time, I will get to that :), thanks.

@krafcik02
Copy link
Author

Hello James, I am still not able to update screenshots for tests. Would you mind trying to checkout my branch and test it? If so please provide steps to reproduce. :)

@krafcik02
Copy link
Author

krafcik02 commented Nov 19, 2024

Also i wanted to check code coverage for frontend unit test using npm run test, I have updated my fork of this project, clone it and ran in devContainer in VScode. Then i got into frontend directory and ran npm i and the command (npm run test), but got this error.
vscode ➜ /workspaces/webstatus.dev/frontend (main) $ npm run test

[email protected] test
npm run tsc-clean && tsc && wtr --coverage --node-resolve --playwright --browsers chromium firefox webkit

[email protected] tsc-clean
tsc --build --clean

error TS5083: Cannot read file '/workspaces/webstatus.dev/node_modules/gts/tsconfig-google.json'.

src/static/js/api/client.ts:23:43 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

23 import {type components, type paths} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

src/static/js/components/test/webstatus-overview-cells.test.ts:30:26 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

30 import {components} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

src/static/js/components/webstatus-feature-page.ts:30:31 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

30 import {type components} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

src/static/js/components/webstatus-overview-cells.ts:17:31 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

17 import {type components} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

src/static/js/components/webstatus-overview-content.ts:20:31 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

20 import {type components} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

src/static/js/components/webstatus-overview-filters.ts:20:31 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

20 import {type components} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

src/static/js/components/webstatus-overview-page.ts:21:31 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

21 import {type components} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

src/static/js/components/webstatus-overview-table.ts:22:31 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

22 import {type components} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

src/static/js/components/webstatus-overview-table.ts:157:42 - error TS7006: Parameter 'f' implicitly has an 'any' type.

157 ${this.taskTracker.data?.data?.map(f =>
~

src/static/js/utils/test/urls.test.ts:18:31 - error TS2307: Cannot find module 'webstatus.dev-backend' or its corresponding type declarations.

18 import {type components} from 'webstatus.dev-backend';
~~~~~~~~~~~~~~~~~~~~~~~

Found 11 errors in 9 files.

Errors Files
1 src/static/js/api/client.ts:23
1 src/static/js/components/test/webstatus-overview-cells.test.ts:30
1 src/static/js/components/webstatus-feature-page.ts:30
1 src/static/js/components/webstatus-overview-cells.ts:17
1 src/static/js/components/webstatus-overview-content.ts:20
1 src/static/js/components/webstatus-overview-filters.ts:20
1 src/static/js/components/webstatus-overview-page.ts:21
2 src/static/js/components/webstatus-overview-table.ts:22
1 src/static/js/utils/test/urls.test.ts:18
npm error Lifecycle script test failed with error:
npm error code 2
npm error path /workspaces/webstatus.dev/frontend
npm error workspace [email protected]
npm error location /workspaces/webstatus.dev/frontend
npm error command failed
npm error command sh -c npm run tsc-clean && tsc && wtr --coverage --node-resolve --playwright --browsers chromium firefox webkit

@jcscottiii
Copy link
Collaborator

Can you try make gen -B? That should regenerate the components?

@jcscottiii
Copy link
Collaborator

Also, could you rebase/update your branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants