Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Automated tests fixes and refactoring #7951

Merged
merged 7 commits into from
Apr 5, 2017

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented Mar 29, 2017

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Resolves #7950
Closes #8061

Changed from
image

to
image

Auditors

@bsclifton @bbondy

Refactor


waitForExist('X, Y, true) -> waitForElementCount(X, 0)


.waitUntil(function () {
    return this.getText(X).then((val) => val === Y)
})

-> waitForTextValue(X, Y)


isExisting(X).then((isExisting) => isExisting === false) -> waitForElementCount(X, 0)


.waitUntil(function () {
        return this.getValue(X).then((val) => val === Y)
})

-> waitForInputText(X, Y)


waitForVisible(X, Y, true) -> waitForElementCount(X, 0)


Note

In this PR I also added BRAVE_TEST_COMMAND_LOGS=1 flag to Travis. This way we can see the problem easier and resolve it faster

DO NOT SQUASH COMMITS

Test Plan

  • npm run test

@NejcZdovc NejcZdovc added this to the 0.14.1 milestone Mar 29, 2017
@NejcZdovc NejcZdovc self-assigned this Mar 29, 2017
@luixxiul luixxiul requested a review from bsclifton March 29, 2017 08:20
@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from 8a5d0dc to f6bcfb0 Compare March 29, 2017 10:29
@NejcZdovc NejcZdovc removed the request for review from bsclifton March 29, 2017 10:31
@NejcZdovc NejcZdovc changed the title Automated tests fixes Automated tests fixes and refactoring Mar 29, 2017
@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from f6bcfb0 to e42bf66 Compare March 29, 2017 12:39
NejcZdovc added a commit to NejcZdovc/browser-laptop that referenced this pull request Mar 29, 2017
@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch 2 times, most recently from 32e0228 to 06d7007 Compare March 29, 2017 21:12
@@ -213,7 +213,7 @@ describe('Autofill', function () {
.waitForTextValue('.creditCardPExpirationDate',
(expMonth < 10 ? '0' + expMonth.toString() : expMonth.toString()) + '/' + expYear.toString())
})
it('autofills the credit card', function * () {
it.skip('autofills the credit card', function * () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Update of #5389 is necessary I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you will do

@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from c89f00b to e257fd5 Compare March 30, 2017 13:48
NejcZdovc added a commit to NejcZdovc/browser-laptop that referenced this pull request Mar 30, 2017
@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from 52a4838 to 81587d3 Compare March 30, 2017 15:28
NejcZdovc added a commit to NejcZdovc/browser-laptop that referenced this pull request Mar 30, 2017
@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from 53a4e29 to 5a24237 Compare April 3, 2017 21:49
NejcZdovc added a commit to NejcZdovc/browser-laptop that referenced this pull request Apr 3, 2017
@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from 5a24237 to 92ed4e3 Compare April 3, 2017 22:32
NejcZdovc added a commit to NejcZdovc/browser-laptop that referenced this pull request Apr 3, 2017
@NejcZdovc NejcZdovc requested a review from darkdh April 3, 2017 22:34
@NejcZdovc
Copy link
Contributor Author

NejcZdovc commented Apr 3, 2017

@darkdh Because of Standard I needed to add some brackets to this file app/browser/ads/adBlockUtil.js. Can you please double check if everything is still ok?

siteHacks[firstPartyUrl.hostname] &&
siteHacks[firstPartyUrl.hostname].allowFirstPartyAdblockChecks
)
) &&
Copy link
Member

Choose a reason for hiding this comment

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

I think this ) should be in L39 so that resourceType !== 'mainFrame' only affect isThirdPartyHost(firstPartyUrl.hostname || '', url.hostname)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. Please verify the change

Copy link
Member

Choose a reason for hiding this comment

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

lgtm now! Thanks for doing this 😉

@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch 3 times, most recently from d2c49da to bec610a Compare April 3, 2017 22:50
@bsclifton
Copy link
Member

@NejcZdovc ready for another rebase 😛

@NejcZdovc
Copy link
Contributor Author

NejcZdovc commented Apr 3, 2017

We have two tests that can be fixed easily because they can be reproduced, but I don't know how to fix it. It fails in tabHandles(). This are tests in bravery-components and misc-components.

cc @bbondy

@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from bec610a to 1b04f89 Compare April 3, 2017 23:34
NejcZdovc added a commit to NejcZdovc/browser-laptop that referenced this pull request Apr 3, 2017
@NejcZdovc
Copy link
Contributor Author

@bsclifton rebased

@@ -54,7 +54,7 @@ const addPageView = (url, tabId) => {
tab.isDestroyed() ||
!tab.session.partition.startsWith('persist:')

if (url && isSourceAboutUrl(url) || isPrivate) {
if (url && (isSourceAboutUrl(url) || isPrivate)) {
Copy link
Member

Choose a reason for hiding this comment

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

i think this should be (url && isSourceAboutUrl(url)) || isPrivate, assuming the previous code was correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thank you

@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from 111e01d to 4e11205 Compare April 4, 2017 19:02
NejcZdovc added a commit to NejcZdovc/browser-laptop that referenced this pull request Apr 4, 2017
@@ -31,16 +31,27 @@ const mapFilterType = {
const shouldDoAdBlockCheck = (resourceType, firstPartyUrl, url, shouldCheckMainFrame) =>
Copy link
Member

@diracdeltas diracdeltas Apr 4, 2017

Choose a reason for hiding this comment

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

i thought this function was supposed to do the following instead:

 firstPartyUrl.protocol &&
  // By default first party hosts are allowed, but enable the check if a flag is specified in siteHacks
  (
    shouldCheckMainFrame ||
    (
      (
        resourceType !== 'mainFrame' &&
        isThirdPartyHost(firstPartyUrl.hostname || '', url.hostname)
      ) ||
      (
        siteHacks[firstPartyUrl.hostname] &&
        siteHacks[firstPartyUrl.hostname].allowFirstPartyAdblockChecks
      )
    )
  ) &&
  // Only check http and https for now
  firstPartyUrl.protocol.startsWith('http') &&
  // Only do adblock if the host isn't in the whitelist
  !whitelistHosts.find((whitelistHost) => whitelistHost === url.hostname || url.hostname.endsWith('.' + whitelistHost)) &&
  // Make sure there's a valid resource type before trying to use adblock
  mapFilterType[resourceType] !== undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @darkdh

@diracdeltas I am not familiar with this code, so any feedback and help is more then welcome

Copy link
Member

Choose a reason for hiding this comment

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

for reference, here's what was in startAdBlocking prior to 85464b9:

    const cancel = firstPartyUrl.protocol &&
      (shouldCheckMainFrame || (details.resourceType !== 'mainFrame' &&
                                Filtering.isThirdPartyHost(firstPartyUrlHost, urlHost))) &&
      firstPartyUrl.protocol.startsWith('http') &&
      mapFilterType[details.resourceType] !== undefined &&
      !whitelistHosts.includes(urlHost) &&
      !urlHost.endsWith('.disqus.com') &&
      adblock.matches(details.url, mapFilterType[details.resourceType], firstPartyUrl.host)

Copy link
Member

Choose a reason for hiding this comment

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

cc @bbondy

Copy link
Member

Choose a reason for hiding this comment

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

yes @diracdeltas is right.
Please do test that youtube videos do not give ads just to be sure though (logged in and out) and also do the test cases here:
fc24493#diff-1f92b9d4310a18761948d6ea1fbefc84

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code from @diracdeltas first comment was added

@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch 3 times, most recently from 838c6da to 24ad5c4 Compare April 5, 2017 15:49
NejcZdovc added a commit to NejcZdovc/browser-laptop that referenced this pull request Apr 5, 2017
Test were refactored to prevent intermediate fails and optimization of the code
List of changes: brave#7951
Resolves brave#7950

Auditors: @bsclifton

Test Plan:
- `npm run test -- --grep="navigationBar tests"`
Test were refactored to prevent intermediate fails and optimization of the code
List of changes: brave#7951
All test command has now log, so that we know which one is called
We also have verbose mode in travis by default
Sites for about:bookmarks in now added as a batch

Test Plan:
- `npm run test -- --grep="bookmarks"`
@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from 24ad5c4 to 3869152 Compare April 5, 2017 15:54
Copy link
Contributor

@cezaraugusto cezaraugusto left a comment

Choose a reason for hiding this comment

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

Tests described on test plan all passed except for navigationBar tests lockIcon shows insecure icon on an HTTP PDF but I think it's not related to PR. Addressed, works ++

Lint for standard@9.0.0 works as well. LGTM

This is a follow up of brave#7813 and resolves linter errors

Resolves brave#8061
Now we get title from a toolbar and use this for test value

Test Plan:
- npm run test -- --grep="bookmark pdf"
@NejcZdovc NejcZdovc force-pushed the hotfix/#7950-tests branch from 3869152 to 79e5f72 Compare April 5, 2017 16:00
@NejcZdovc NejcZdovc merged commit 952790b into brave:master Apr 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Standard.js lint errors Automated tests fixes
7 participants