TDD Practice in Brave

For this lab, we’d like to practice the TDD (Test Driven Development) on Brave URL bug.  Essentially, TDD is the process of test-first development, making our code passing the test we just created.

After you start your brave build, heading to the URL bar and input

https://www.google.ca/search?q=dog cat

enter (space in between), you will notice the different result compared with the behavior in Chrome for example.

It turns out Brave doesn’t take care of the spacing in the query string. Instead of returning a search string with “dog%20cat”, we actually got 2 separate string “dog” and “cat”.

Once we have our desired result, we can now add our test case for this specific behavior in test/unit/lib/urlutilTest.jsScreen Shot 2018-04-23 at 10.57.22 PM.png

Note the urlUtil inside the assert statement, it gives us hint where the code might sit. So heading to the js/lib/urlutil.js, navigate to isNotURL function, let’s make changes right before the UrlUtil.getScheme(str)Screen Shot 2018-04-23 at 11.15.10 PM.png

By issuing npm run test -- --grep="urlutil", our test should pass and also the bug should be fixed now
Screen Shot 2018-04-23 at 11.29.29 PM

A bit Intro of Brave Browser

The project I picked for release 0.2 is the Brave Browser. Many of you may wonder what special about it. So do I. IMO, Chrome and Firefox are two dominating browsers in the mainstream of web. How come a newborn browser influences and attracts so many people to contribute.

Let’s have a look at the feature highlight from the official:

Browse faster by blocking ads and trackers that violate your privacy and cost you time and money.

Ad Block, cool! Seems Brave has included a bunch of pleasant extensions into the system. Well, we could use extensions in Chrome too, why bother?

The real interesting yet controversial topic is the mechanism of the Ad Block. Instead of the traditional third-party advertising, users can now donate their BAT to those most visited sites using Brave Payment as the rewards for the content publishers.

I don’t know much about how advertisements profit on the web, but the idea of publisher-advertiser-user eco-system seems very appealing. It may have a huge impact on the browser ecology, who knows.

If you feel like getting involved, here’re some helpful info:

Happy Contributing 🙂

Contribute to Open Source as A Translator

As our release 0.2 requested, we are asked to contribute to an existing open source project on Github. The challenge for us is actually to find a suitable bug/issue (Good First Issue) to work on since most of us are newbies to open source.

As for me, I end up picking the localization as my main goal to contribute. I have been looked into the Brave project for a while (browser-laptop ver). Surprisingly, the translation for Chinese (China) isn’t fully completed yet (about 80% for zh_cn). Also, most of the work was done by 5 translators 2 years ago, and no more maintenance since then. Compared to VSCode, you will notice there is still not much attention for the Brave browser in China, perhaps people don’t even aware of the project is open.

Well, I thought it might be worthwhile doing it. Let’s take a look at how we can contribute to translation.

  1. Create a Transifex account
  2. Join an existing project – Brave Laptop
  3. Pick a language – Chinese (China)
  4. Join a team – Team 1

Transifex lets the project utilizing their API to store the content into a platform (file system) where translators and collaborators can do their work. After translation, the project can just pull the translated content back to their repo.

After you have access to the project, you will be assigned to the translator role:Screen Shot 2018-03-26 at 2.36.48 AM

Heading to the project page, under language tab, search your desired language:Screen Shot 2018-03-26 at 3.01.44 AM

After selecting the language, you will see the content is grouped into various properties. Click on any property to start translating 🙂Screen Shot 2018-03-26 at 3.06.58 AM.png

You can check your recent activities by viewing your profile. After your translation, your job is mostly done. The project will pull the translation files based on their release. Screen Shot 2018-03-26 at 2.41.36 AM

Overall, the translation process is pretty straightforward, but I think it will be rewarding for the community later on. As more translation get going, more people will be noticed and get involved, which brings more end users, and more feedback will be provided to the project.

Localization work seems so easy that gets underestimated sometimes. In open source, anything open will eventually create the snowball effect and get more attention, so there’s also no exception for languages.