Substitute reference to a remote script with local one - testing

This is regarding my developmnent stage and the practice of testing all the JS before releasing it.
Unfortunatly we have some hardcoded references in our code. and this is the reason why there is no way for me to test a new version of test.js on the Stage server. and you only see the effects when it goes live.
Now, I know I should use relative paths etc.. but I was wondering if there is a Firefox plugin that could maybe substitute http://remote.site/test.js with /dev_path/to/test.js during pageload ?
I have also tried using hosts file for this purpose but it doesn't work in my scenario as I only need to map it to this 1 reference and not the whole domain.

Is there anything stopping you from changing the hard-coded references? That's really the easiest answer to your problem.
Run a find-and-replace on your files to replace the absolute links to relative ones. So long as the site hierarchy is the same for development and production, there shouldn't be any problems.

Related

how can I execute a three.js example in my project folder?

How can I execute a three.js example in my project folder? The example I want to execute is this:
https://threejs.org/examples/webgl_animation_keyframes.html
.
After installing three.js through npm, I copied example's source code:
https://github.com/mrdoob/three.js/blob/master/examples/webgl_animation_keyframes.html
in my empty examples folder located at '/node_modules/three/examples'.
I think there's a path direction problem importing some of including library files such as
"import { RoomEnvironment } from './jsm/environments/RoomEnvironment.js';"
"loader.load( 'models/gltf/LittlestTokyo.glb', function ( gltf )"
etc.
Do I have to copy those library files and paste it on the right path by hand? I'm afraid this is not a correct solution. Is there a solution something like, as I wish, downloading all necessary library files in the right places by input some npm command?
The situation is certainly not ideal, but here are some tips:
You can clone the whole repository so you have all the resources used by the examples: git clone --depth=1 https://github.com/mrdoob/three.js.git
You can use a web browser's web page saving feature (Ctrl+S) but be sure to replace the HTML with the example's source HTML, because it will be much cleaner. You'll need to fix up file path references, and it may still miss some resources. Also make sure not to get the iframe containing page, but rather the demo itself.
If Save Webpage As misses some resources, you can use Chrome's dev tools Network tab. Refresh the page to populate it, then right click inside the table > Copy > Copy All as CURL. This will give you a command you can paste in your terminal (in an empty directory, ideally) to download all the resources used by the webpage. This can still miss some resources that are dynamically loaded, such as with 1. the model selector in the LDraw Loader example, in which case you could switch to each model to purposely populate the network requests table, or 2. a fallback for older browsers, in which case you may not be able to get it through this method.
It's much easier to remove features than to add and combine them, so try to find an example that uses as many of the things you want as possible (without being overwhelmingly complex). It's worth looking outside of the official examples to real projects and third party experiments. Just note that they may not be up to date with the latest APIs.
I hope someone writes a script to automate setting up a Three.js project from an example... and posts a better answer than this!

TFS Api - trigger test run conditionally (when new files come)

I'm trying to get acquainted with test automation using Microsoft TFS Api.
I've created the program which runs my test set - it uses code similar to one described here, e.g.:
var testRun = _testPoint.Plan.CreateTestRun(false);
testRun.DateStarted = DateTime.Now;
// ...
testRun.Save();
I believe this forces them to start as soon as any of agents can run them, instead of being delayed to certain time. Am I wrong? Anyway, it works all right.
But I was told by my lead that the task should be started each time the new input files are copied to certain folder (on the network I think, or perhaps in TFS).
So I'm searching for a way which allow to trigger tests on some condition - but currently without any luck. Probably I miss proper keywords.
I only found something vaguely related here but it seems they say it is not possible in a proper way.
So are there any facilities in TFS / MTM, any ways or approaches to achieve my goal? Thanks in advance for any hints / links.
You would need to write a system service (or other) that uses the file system watcher. Then when the file changes you can run your code above.
There is no built in feature in TFS to watch a folder for changes.

Intellij 11.1.5 - Project specific path variable

I am using the Intellij 11.1.5. We are a large team, and have a pretty complex project setup. so we've made a template and when someone needs a new project set up, we just clone it and she is pretty much ready to go. One other thing i would like to automate is the creation of run configurations. One such configuration starts a custom bat file that requires a parameter representing a path that is user specific. I wanted to know if can store that value as a path variable specific to each project. Maybe somewhere in the .idea folder in my project. I know that Intellij stores it in its .IntelliJIdea11\config\options\path.macros.xml file, but is there a way to tweak that?
Any other idea that would allow me to locally store a parameter passed to the run config script would be usefull.
Thanks
I'm afraid you can't do it in IDEA, but you can use some environment variable directly in the .bat file instead of using the parameter (or rewrite the batch script to detect this value automatically, if possible). Instruct your users to define this environment variable.
IDEA Path variables are global and cannot be made project specific.

How to compare test website and live website

We have our production server running our website. Then we have a test server which has exact same data but with changes to code to do some new functionality. This web app has over 500 pages.
Is there any program that can
Login to the test site
Crawl through each page and then save the page as html
Compare with the same page saved with live site?
This way we can make sure that new features that we add to our test site will not break the live site when code updates are applied to production.
I am currently trying to use WinHTTrack website copier and then comparing the test and live folders with some code comparison tool like beyond compare. This works ok but there are lot of files changed because of the domain name changes.
Looking forward to ideas / solutions for this problem.
Regards
Have you looked at using Watir for this? It's not exactly the thing you are looking for but it might allow you some more granularity in your tests and ensure the site is functionally identical rather than getting caught up on changing guids, timestamps and all the other things that tend to change across any significant size website from day to day as part of it's standard functionality.
Apparently you can't make consistent, reproduceable builds in your project, can you? I would recommend moving towards that in the long run, it will save you a lot of headaches. That way you would know exactly what was deployed to which server when, so there would be no more need to bend around backwards to get the deployed sources back like this...
I know this is not a direct solution to your problem... but maybe it is worth comparing, whether you would save more in the long run by investing the efforts into your build process now, instead of implementing this workaround (and then improving your build process anyway - because one day you will almost surely need to do that).
wget has a --convert-links option, there are also some options to preserve cookies that might let you do it logged in http://drupal.org/node/118759#comment-664498
use an Offline Downloader, download all files to your computer from both sources, then compare the folder contents using a free tool like Total Commander.
EDIT
Load both of your sources into a CVS, and compare it there.

browser plugin to test a site's look when migrating

I'm thinking I need a browser plugin that does the following, and if it doesn't exist, it should. I may as well say FF for now, but it could be any browser.
The problem: when moving a website from one server to another, you need migration testing. It is a pain to click on every link by hand and compare it to the old host. You really need 2 machines or have to constantly thrash your hosts file.
The plugin:
Would allow you to specify an alternate hosts entry for a website. 2 entries would make it clear, one for live, one for test.
The plugin would crawl every link on the site, and render the page in the browser, and save an image of the entire page.
It would switch hosts and repeat, and save images in a second folder. Since the rendering engines match, the images should match. We need to switch hosts (like /etc/hosts) so all absolute links are the same for the site.
Now this could be part of the plugin or external, now that we have 2 folders of identically named images, we run an image-diff program on the whole batch. A quick test would be a bdiff or hash, or we could get more sophisticated and determine how different each image is.
This would save so much time. So can it be done with existing tools, or do I need to go write it?
Have a look at Selenium, it allows you to script interactions with the browser and verify content.
That is overengineered. What kind of website is it? How big? Which framework (PHP, JSP, Rails, etc.)? Why not copy the website onto the new server and grep the code for specific ties to the old server?
I'd concentrate on why you think the site would differ between two servers, and focus on testing those specific cases rather than the whole site. When a site is moved to a new machine the issues are generally very obvious from looking at a couple of pages.
Presumably they are both looking at the same data source, assuming there is a data source, otherwise a folder diff on the two installations would suffice. This being the case, it should be a simple task to identify which areas of the site are likely to be affected by a server migration.
Also, I wouldn't personally trust a machine matching two images to sign off system as ready to go live. There just isn't a substitute for real human testing. Yes it's time consuming, but how important is your site?
Try http://www.browsercam.com/ - free trial should allow you to specify main page and follow links to make screenshots automatically of the sub-pages as well.