Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to phettest locally (for testing) #56

Closed
zepumph opened this issue Aug 11, 2021 · 6 comments
Closed

How to phettest locally (for testing) #56

zepumph opened this issue Aug 11, 2021 · 6 comments

Comments

@zepumph
Copy link
Member

zepumph commented Aug 11, 2021

I discovered while working on #55 that it is quite challenging to debug phettest and its server from bayes. It is much nicer to have a local way of testing this. I'll explain how I was able to set it up locally, and then this issue will be for optimizing this further, and making sure to document it.

Here is a patch that outlines a fair number of these steps. I don't think committing this makes sense because it feels like a workaround.

Index: phettest/index.html
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phettest/index.html b/phettest/index.html
--- a/phettest/index.html	(revision 589cdbe7c499adfc1cc478b11340fc0ac61ff93d)
+++ b/phettest/index.html	(date 1628701068282)
@@ -123,6 +123,6 @@
 <script type="text/javascript" src="sherpa/lib/jquery-2.1.0.min.js"></script>
 <script type="text/javascript"
         src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
-<script type="text/javascript" src="phettest.js"></script>
+<script type="text/javascript" src="./phetmarks/phettest/phettest.js"></script>
 </body>
 </html>
Index: phettest/phettest.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phettest/phettest.js b/phettest/phettest.js
--- a/phettest/phettest.js	(revision 589cdbe7c499adfc1cc478b11340fc0ac61ff93d)
+++ b/phettest/phettest.js	(date 1628698176955)
@@ -2,8 +2,8 @@
 
 // will be replaced by domain name in the future
 const domain = 'https://bayes.colorado.edu/dev/';
-const serverURL = `${domain}phettest-server/`;
-const phettestURL = `${domain}phettest/`;
+const serverURL = `http://localhost:45362/`;
+const phettestURL = `http://localhost:8080/phetmarks/phettest/`;
 
 // common repo fields
 const commonSameMasterStatusElements = {};
@@ -227,10 +227,10 @@
   $.ajax( `${serverURL}perennial-refresh` ).done( data => {
     $( status ).text( '' );
 
-    updateCommonRepos();
-    updateSims();
-    updateCommonCheckingStatus( false );
-    updateSimCheckingStatus( false );
+    // updateCommonRepos();
+    // updateSims();
+    // updateCommonCheckingStatus( false );
+    // updateSimCheckingStatus( false );
   } ).fail( () => {
     $( status ).text( 'perennial refresh failed' );
   } );
@@ -316,7 +316,7 @@
       } );
 
       updateAllCommon();
-      checkCommonSameMaster();
+      // checkCommonSameMaster();
     } );
   } );
 }
@@ -403,14 +403,12 @@
     } );
 
     updateAllSims();
-    checkSimSameMaster();
+    // checkSimSameMaster();
   } );
 }
 
 updateCommonRepos();
 updateSims();
-updateCommonCheckingStatus( false );
-updateSimCheckingStatus( false );
 commonFilter( false );
 simFilter( false );
   
\ No newline at end of file
  1. move the index.html to the root of your git repository structure, and change the link to phettest.js to point into ./phetmarks/phettest/phettest.js
  2. cd ./phetmarks/phettest/phettest-server.js
  3. node phettest-server.js
  4. change the hard coded URLs at the top phettest.js to point to the local URLs you plan to use.
  5. For my work in updating how to refresh perennial, it was helpful to stop the commands that occur one sim at a time and on launch of the page. (also in the patch).
  6. navigate via your normal method to the root of your directories. It will be phettest.

In addition to this, I found that some commands had to change to support windows platforms.

@zepumph zepumph self-assigned this Aug 11, 2021
@zepumph
Copy link
Member Author

zepumph commented Aug 11, 2021

  • Add these steps to a readme.

@zepumph
Copy link
Member Author

zepumph commented Aug 11, 2021

Committed above. @samreid can you review in whatever way you would like. From going through the instructions and trying to run it locally (more work), to just glancing through the doc (less work). Whatever you'd like is good with me. Feel free to close.

@samreid
Copy link
Member

samreid commented Sep 2, 2021

The documentation looks reasonable, but leaves me wondering if we can eliminate several steps if we just update phettest so that it runs from phetmarks/index.html instead of having to pop it up to index.html. Wouldn't this simplify steps on the server as well? Let me know if this should be a different issue.

@zepumph
Copy link
Member Author

zepumph commented Sep 2, 2021

but leaves me wondering if we can eliminate several steps if we just update phettest so that it runs from phetmarks/index.html instead of having to pop it up to index.html

This step is not needed on the server, because of htaccess directives. It is mostly just a hack for testing locally.

I remember trying to accomplish what you are recommending when working on phettest last time (I believe when moving it to bayes), but giving up. I'm not currently in a position to devote more resources to phettest, and feel like it is nice for the index page to be at the root of the directory structure, i.e. phettest/ instead of phettest/phetmarks/phettest/.

I feel ready to close.

@zepumph zepumph assigned samreid and unassigned zepumph Sep 2, 2021
@samreid
Copy link
Member

samreid commented Sep 2, 2021

Sounds good, let's close. @jonathanolson and I may take it for a test drive as part of phetsims/chipper#1073

@samreid samreid closed this as completed Sep 2, 2021
@samreid
Copy link
Member

samreid commented Sep 4, 2021

I tested this in phetsims/chipper#1073 and it worked great. I got tricked for a while because I forgot a slash after the port. I'll add a note about that to protect me next time. Here is my patch that worked will (along with moving index.html).

Index: phettest/phettest.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phettest/phettest.js b/phettest/phettest.js
--- a/phettest/phettest.js	(revision 5a2f4f399e6f62c5814a625bbc33c600178f6855)
+++ b/phettest/phettest.js	(date 1630766681654)
@@ -1,8 +1,8 @@
 // Copyright 2020, University of Colorado Boulder
 
 // will be replaced by domain name in the future
-const domain = 'https://bayes.colorado.edu/dev/';
-const serverURL = `${domain}phettest-server/`;
+const domain = 'http://localhost/main/';
+const serverURL = 'http://localhost:45362/'; // must end with /
 const phettestURL = `${domain}phettest/`;
 
 // common repo fields

samreid added a commit that referenced this issue Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants