|
4 | 4 |
|
5 | 5 | use function Tests\{asAdmin, asAuthor, asEditor}; |
6 | 6 |
|
7 | | -const SA_ADMIN_NOTICE = '<!-- Simple Analytics: Not logging requests from admins -->'; |
8 | 7 | const SA_DEFAULT_SCRIPT = 'src="https://scripts.simpleanalyticscdn.com/latest.js"></script>'; |
| 8 | +const SA_INACTIVE_ADMIN_NOTICE = '<!-- Simple Analytics: Not logging requests from admins -->'; |
9 | 9 | const SA_INACTIVE_ADMIN_SCRIPT = 'src="http://localhost:8100/wp-content/plugins/simpleanalytics/resources/js/inactive.js"'; |
10 | 10 |
|
11 | 11 | it('can be activated', function () { |
|
27 | 27 | $homePage = asAdmin()->navigate('http://localhost:8100'); |
28 | 28 |
|
29 | 29 | expect($homePage->content()) |
30 | | - ->toContain(SA_ADMIN_NOTICE) |
| 30 | + ->toContain(SA_INACTIVE_ADMIN_NOTICE) |
31 | 31 | ->toContain(SA_INACTIVE_ADMIN_SCRIPT); |
32 | 32 | }); |
33 | 33 |
|
|
54 | 54 | }); |
55 | 55 |
|
56 | 56 | it('adds inactive script for selected user roles', function () { |
57 | | - asAdmin() |
58 | | - ->navigate('http://localhost:8100/wp-admin/options-general.php?page=simpleanalytics&tab=ignore-rules') |
| 57 | + $admin = asAdmin(); |
| 58 | + |
| 59 | + $admin->navigate('http://localhost:8100/wp-admin/options-general.php?page=simpleanalytics&tab=ignore-rules') |
59 | 60 | ->check('simpleanalytics_exclude_user_roles-editor') |
60 | 61 | ->check('simpleanalytics_exclude_user_roles-author') |
61 | 62 | ->click('Save Changes') |
62 | 63 | ->assertChecked('simpleanalytics_exclude_user_roles-editor') |
63 | 64 | ->assertChecked('simpleanalytics_exclude_user_roles-author'); |
64 | 65 |
|
| 66 | + expect($admin->navigate('http://localhost:8100')->content()) |
| 67 | + ->toContain(SA_DEFAULT_SCRIPT); |
| 68 | + |
65 | 69 | expect(asEditor()->navigate('http://localhost:8100')->content()) |
66 | | - ->toContain(SA_ADMIN_NOTICE) |
| 70 | + ->toContain(SA_INACTIVE_ADMIN_NOTICE) |
67 | 71 | ->toContain(SA_INACTIVE_ADMIN_SCRIPT); |
68 | 72 |
|
69 | 73 | expect(asAuthor()->navigate('http://localhost:8100')->content()) |
70 | | - ->toContain(SA_ADMIN_NOTICE) |
| 74 | + ->toContain(SA_INACTIVE_ADMIN_NOTICE) |
71 | 75 | ->toContain(SA_INACTIVE_ADMIN_SCRIPT); |
72 | 76 | }); |
0 commit comments