Week 3 : Testing procedure
Tags: javascript, webdev, react, opensource
Published: 2022-02-01 04:44:01

Yes ! Not only understand the code itself but testing it is a hard challenge as well. As you recalled from my [week 2](https://dev.to/beamazedvariable/week-2-a-lot-of-opportunity-ahead-15on) I thought that 2 of my PR would be easy picker to start contributing to Telescope but no the testing and prove it working is a pain !!!! (By the way no pain no gain !)

## Rendering build header animation 
 This [PR](https://github.com/Seneca-CDOT/telescope/pull/2665) the changes to it is quite simple but testing locally is a bit tough. 

Firstly we did not know why even though when the build is successfull it still return us `code:1` as indicate an error happened during the build process. I did connect with Josue as he get access to the server and he been the one I talked to eveyrtime I need him to trigger a build manually to test out my PR. Ater and 2 hours session we regconize the error related to the `-f` command which might create a warning and return back the error code in `docker`. After that Josue just went ahead and create a temporary solution to the problem which send `code:0` equal to success build status.

Secondly it really bugging me when I work on the code at different time with Josue and can not always ask him to do it. I did try to make some research base on old PR and asking Andrew who been leading the creation of dashboard during fall semester and found this gem among the closed [issue](https://github.com/Seneca-CDOT/telescope/pull/2582). The code have been changed quite a bit in like 2 weeks span and I did make my update on how to test my PR locally. Before that I have try to point the `autodeploymentUrl` to our `dev` api but no luck for me since it telling me that I'm breaking a olicy which is new to me. But after reading the closed issue above I was able to find a `hack` for it. But yes, that was the first time I know that we would be able to create `policy` for our project as such.

## Fixing wrong build status url
[PR](https://github.com/Seneca-CDOT/telescope/pull/2750).When working on the above issue I regconized there was a mistake on our production where the we requesting wrong Url on `production` which only need to add a regex like such 

```js
`//${window.location.hostname.replace(/(api\.|\.api)/, '')}/deploy${path}`;
```
Even though it is a quick fix (than the other PR) but I still learn thing such as this is my first time using `or` logic with `regex`

## Third PR and it still going on
The challenging part of this [PR](https://github.com/Seneca-CDOT/telescope/pull/2706) would be where to put the code and how to test it.

At first I was trying out easiest way which choosing the `react` library to wrap the `description` section of the Youtube posts. But then I get some advice to make that change ideally in the backend which make me wondering about the difference of it. I then read and standing from the point of view of a `post` being procceded and changes that affect data should be happened in the back which help to avoid work for the `frontend`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2uc497pempt9vovfns8e.png)

If you see the picture above when I made a search to look for the `post` and as this time I could say I got 0 knowledge about the Telescope structure yet so i got consfused on where to put my changes. I remmeber talking with Abdul on Slack on why we having the `api` and `backend` at the same time and they seem to be duplicated with each orther. I did reach out to him again and what he gave me was adding my code in `api` would be a move to make. I then jump in the `Posts` service and make a dummy change on wrapping the html using `linkyfyhtml` in the `Post` object constructor which it work but then I receive a comment on how to change it which we should wrapping the `html` before we create the `post` I then make some change in to `default` function of the `api\posts` service and got no luck making it to work

I found out that Josue did also work on these files and matain the project for a long time so I did talk to him and now I know that the `parser` service is still under construction and `post` service only fetch the data from `redis` which I need to put my changes in the `backend`. For some reason my changes did not work at all and I stop at that point where it is just not working. I keep deleting the data and re run the project which is time consuming. Cause you know what ? I'm afraid of debugging but after calming my tilted reaction I regret not debugging it sooner. I put the break point on where it return the type of the `post` to be a `video`. I then recognized that all of the `video` post return `article.content` as an array and we expect `linkyfyHtml` to work on a string not an array of object. I then make a change to joint the content since only the first index of the returned array object needed to be process. After applying changes, my code work and I litterally dance on my chair of having the issue move away from my mind. But you know they say never be too excited about shipping software. I come across a gif which kind of related and I want to share it here and might delete it later. I feel so related with this `gif`.This is totally me after I received some feebacks which I need to make another changes, adding `test` for my changes before it got approved. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3uzigu4ho4d8kg2rd3f.gif)

I will keep you guys posted and at the same time I could not stop laughing on the `gif` :)

## What I learned this week

Firstly, if I bring up the 3rd PR up in the public Slack chat for Telescope. The third PR could have move way faster since I took most of the time figuring it myself instead of asking in the chanel where people who have knowledge can bring up disscussion. When talking to people, since they all contribute on different aspect of the project sometime their understanding about the project can be equal or less that what I already know about it. i guess the reason why I not feeling like doing it is because English was not my first language and I feeling like I did not do a good job of explaining things. But to be fair I try to go for this course to break those barrier. And why not doing that since I got a chance to learn with buch of great people who making fun of commits that breaking `production`.  

Secondly, the roller coaster feeling and pressure shipping software is what I'm in this course for. I know that sooner or later this is what I have to face if I made it to the workforce. I said this in the beginning of this course that this course get as hard as you want it to be so I would love to jump on that roller coaster over and over untill I get use to it ! 

Let's talk next week ^-^