File tree Expand file tree Collapse file tree 3 files changed +25
-17
lines changed
Expand file tree Collapse file tree 3 files changed +25
-17
lines changed Original file line number Diff line number Diff line change 3636
3737 env :
3838 WP_VERSION : ${{ matrix.wordpress }}
39- WP_SITE_URL : http://127.0.0.1 :8100
39+ WP_SITE_URL : http://localhost :8100
4040 WP_DB_NAME : wordpress
4141 WP_DB_USER : root
4242 WP_DB_PASS : root
@@ -104,7 +104,7 @@ jobs:
104104
105105 - name : Start PHP server
106106 run : |
107- php -S 127.0.0.1 :8100 -t wordpress > /dev/null 2>&1 & until curl -sSf http://127.0.0.1 :8100 > /dev/null; do sleep 0.2; done
107+ php -S localhost :8100 -t wordpress > /dev/null 2>&1 & until curl -sSf http://localhost :8100 > /dev/null; do sleep 0.2; done
108108
109109 - name : Install pnpm
110110 uses : pnpm/action-setup@v4
Original file line number Diff line number Diff line change 44
55use function Tests \asAdmin ;
66
7- const DEFAULT_SA_NOTICE = '<!-- Simple Analytics: Not logging requests from admins --> ' ;
7+ const SA_ADMIN_NOTICE = '<!-- Simple Analytics: Not logging requests from admins --> ' ;
8+ const SA_DEFAULT_SCRIPT = '<script type="text/javascript" src="https://scripts.simpleanalyticscdn.com/latest.js"></script> ' ;
9+ const WP_PLUGIN_ROW_SELECTOR = 'tr[data-slug="simpleanalytics"] ' ;
10+ const WP_ACTIVATE_PLUGIN_SELECTOR = '#activate-simpleanalytics ' ;
811
9- test ('Sign in as admin and activate the plugin ' , function () {
10- $ page = asAdmin ();
12+ it ('can be activated ' , function () {
13+ asAdmin ()
14+ ->navigate ('http://localhost:8100/wp-admin/plugins.php ' )
15+ ->assertPresent (WP_PLUGIN_ROW_SELECTOR )
16+ ->click (WP_ACTIVATE_PLUGIN_SELECTOR );
17+ });
1118
12- $ page ->navigate ('http://127.0.0.1:8100/wp-admin/plugins.php ' )->screenshot ();
13- $ page ->assertSee ('Simple Analytics Official ' );
19+ it ('adds a script by default ' , function () {
20+ $ homePage = visit ('http://localhost:8100 ' );
21+ expect ($ homePage ->content ())->toContain (SA_DEFAULT_SCRIPT );
22+ });
1423
15- $ page2 = visit ('http://127.0.0.1:8100 ' );//->screenshot();
16- expect ($ page2 ->content ())->not ->toContain (DEFAULT_SA_NOTICE );
24+ it ('adds a comment when an authenticated user visits ' , function () {
25+ $ homePage = asAdmin ()->navigate ('http://localhost:8100 ' );
26+ expect ($ homePage ->content ())->toContain (SA_ADMIN_NOTICE );
27+ $ homePage ->assertNoConsoleLogs ();
1728});
Original file line number Diff line number Diff line change 4343
4444function asAdmin ()
4545{
46- $ page = visit ('http://127.0.0.1:8100/wp-admin ' );
47-
48- $ page ->fill ('user_login ' , 'admin ' );
49- $ page ->fill ('user_pass ' , 'admin ' );
50- $ page ->press ('wp-submit ' );
51- $ page ->assertUrlIs ('http://127.0.0.1:8100/wp-admin ' );
52-
53- return $ page ;
46+ return visit ('http://localhost:8100/wp-admin ' )
47+ ->fill ('user_login ' , 'admin ' )
48+ ->fill ('user_pass ' , 'admin ' )
49+ ->press ('wp-submit ' )
50+ ->assertUrlIs ('http://localhost:8100/wp-admin ' );
5451}
You can’t perform that action at this time.
0 commit comments