Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Feature request: Allow users to specify which URLs to sync against #3858

Open
sjelin opened this issue Dec 21, 2016 · 4 comments
Open

Feature request: Allow users to specify which URLs to sync against #3858

sjelin opened this issue Dec 21, 2016 · 4 comments

Comments

@sjelin
Copy link
Contributor

sjelin commented Dec 21, 2016

(edited based on the discussion below)

Instead of forcing users to manage browser.ignoreSynchronization, we could allow users to tell us which URLs point to apps which need to be synced, and which do not. Probably, a good API would be:

type syncCondition:  boolean | string | string[] | {[url: string]: boolean} | RegExp | RegExp[] | (url: string) => boolean;
config.synchronizeWhen: syncCondition;
config.disableSynchronizeWhen: syncCondition;
browser.setSynchronizeWhen: (synchronizeWhen: syncCondition | wdpromise.Promise<syncCondition>) => wdpromise.Promise<syncCondition>; // Returns old `synchronizeWhen`
browser.setDisableSynchronizeWhen: (disableSynchronizeWhen: syncCondition | wdpromise.Promise<syncCondition>) => wdpromise.Promise<syncCondition>;  // Returns old `disableSynchronizeWhen`
/**
 * We will synchronize on a page if its url passes `synchronizeWhen` but not
 * `disableSynchronizeWhen`. `synchronizeWhen` defaults to `true` and
 * `disableSynchronizeWhen defaults to `false`.  Users can modify these at run time
 * via the corresponding `browser` methods
 */

Users can use synchronizeWhen to specify the base URL for their app, and disableSynchronizeWhen to specify any sub pages which don't have angular. If there are special cases where they need finer control, they can do something like:

browser.setSynchronizeWhen(false).then((oldSyncWhen) =>
  doSomeUnsynchedStuff();
  return setSynchronizeWhen(oldSyncWhen);
});

Edge Case: Navigation without bootstrap

An issue with this idea is that if navigation happened via something other than browser.get (e.g. someone clicks on a link), we wouldn't get to bootstrap and would end up using an outdated synchronization setting from a previous page. However, #3857 should address that.

Edge Case: Blocking Proxy

Blocking Proxy currently does not have the APIs needed to support this change. There is an issue to expand the APIs on the Blocking Proxy repo: angular/blocking-proxy#16

@heathkit
Copy link
Contributor

FYI, we're replacing browser.ignoreSynchronization = true with browser.waitForAngularEnabled(false). I do like this more than #3859, since detecting Angular seems to be so messy and involved.

I like making it a function for maximum flexibility, but wouldn't most users be testing a single Angular app, and that's the only url they'd want to wait for Angular on? It'd be nice to make the common case easy.

@sjelin
Copy link
Contributor Author

sjelin commented Dec 21, 2016

Sure, we could have something like:

browser.synchronizeIf: string | string[] | RegExp | RegExp[] | (url: string) => boolean

I don't think it gets much more general than that 😝

@heathkit
Copy link
Contributor

Actually, thinking about this more, the most common case I see for people using ignoreSynchronization is a login page or a TOS page or something. So this would be a big improvement.

@sjelin sjelin changed the title Idea: config.synchronizeOnUrl() Feature request: Allow users to specify which URLs to sync against Dec 22, 2016
@sjelin
Copy link
Contributor Author

sjelin commented Feb 2, 2017

Blocked on #3857, as mentioned in the Edge Case: Navigation without bootstrap section

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

No branches or pull requests

2 participants