|
2 | 2 |
|
3 | 3 | namespace Tests\Browser; |
4 | 4 |
|
5 | | -use function Tests\asAdmin; |
| 5 | +use function Tests\{asAdmin, asAuthor, asEditor}; |
6 | 6 |
|
7 | 7 | const SA_ADMIN_NOTICE = '<!-- Simple Analytics: Not logging requests from admins -->'; |
8 | 8 | const SA_DEFAULT_SCRIPT = 'src="https://scripts.simpleanalyticscdn.com/latest.js"></script>'; |
|
20 | 20 |
|
21 | 21 | it('adds a script by default', function () { |
22 | 22 | $homePage = visit('http://localhost:8100'); |
23 | | - expect($homePage->content())->dump()->toContain(SA_DEFAULT_SCRIPT); |
| 23 | + expect($homePage->content())->toContain(SA_DEFAULT_SCRIPT); |
24 | 24 | }); |
25 | 25 |
|
26 | | -it('adds a comment when an authenticated user visits', function () { |
| 26 | +it('adds inactive script for authenticated users by default', function () { |
27 | 27 | $homePage = asAdmin()->navigate('http://localhost:8100'); |
28 | 28 |
|
29 | | - expect($homePage->content())->dump() |
| 29 | + expect($homePage->content()) |
30 | 30 | ->toContain(SA_ADMIN_NOTICE) |
31 | 31 | ->toContain(SA_INACTIVE_ADMIN_SCRIPT); |
32 | 32 | }); |
|
52 | 52 |
|
53 | 53 | expect(visit('http://localhost:8100')->content())->toContain('data-ignore-pages="/vouchers"'); |
54 | 54 | }); |
| 55 | + |
| 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') |
| 59 | + ->check('simpleanalytics_exclude_user_roles-editor') |
| 60 | + ->check('simpleanalytics_exclude_user_roles-author') |
| 61 | + ->click('Save Changes') |
| 62 | + ->assertChecked('simpleanalytics_exclude_user_roles-editor') |
| 63 | + ->assertChecked('simpleanalytics_exclude_user_roles-author'); |
| 64 | + |
| 65 | + expect(asEditor()->navigate('http://localhost:8100')->content()) |
| 66 | + ->toContain(SA_ADMIN_NOTICE) |
| 67 | + ->toContain(SA_INACTIVE_ADMIN_SCRIPT); |
| 68 | + |
| 69 | + expect(asAuthor()->navigate('http://localhost:8100')->content()) |
| 70 | + ->toContain(SA_ADMIN_NOTICE) |
| 71 | + ->toContain(SA_INACTIVE_ADMIN_SCRIPT); |
| 72 | +}); |
0 commit comments