Skip to content

Commit

Permalink
Merge pull request #89 from dfe-analytical-services/update-readme
Browse files Browse the repository at this point in the history
Update to README
  • Loading branch information
JT-39 committed Aug 21, 2024
2 parents 5995870 + 9f676d4 commit a52bcb5
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 70 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ Once you have a new repository set up from this template, you should start by ta
#### Check you can run it

1. Check that you can run the app successfully using the instructions in this README
2. Check that the example automated tests also run successfully using `shinytest2::test_app()`
2. Check that the example automated tests also run successfully using `shinytest2::test_app()`<br>
(If you get `Error in initialize(...) : Invalid path to Chrome`, the Analyst's Guide has a solution - [shinytest2 - Invalid path to Chrome (chromote) error message](https://dfe-analytical-services.github.io/analysts-guide/learning-development/r.html#shinytest2---invalid-path-to-chrome-chromote-error-message))

#### Update standard variables

3. Update the app title in the `ui.R` script and the `tests/testthat/test-UI-01-basic_load.R` UI test script
4. Update the rest of the app metadata set in the `ui.R` script
5. Update the variables set in the `global.R` script
6. Test that the app still loads okay in the tests using `shinytest2::test_app()`
7. Note: You may get a failure for the test in `test-UI-01-basic_load.R`, with a reason similar to `app$get_text("title") not equal to ...`. See this [workaround for the failure of the UI test](#ui-test-fail).

Finally before adding your own code, you should update the readme, deleting this version and then replacing with your own content applicable to your dashboard based on the README_template.md file in this repository. Once done you should also delete that template, leaving you with a single `README.md` file that documents an overview of your application. Continue to edit and maintain that as a key document for your application over time.

Expand Down Expand Up @@ -105,6 +107,8 @@ Whenever you add new packages, make sure to use `renv::snapshot()` to record the

#### Known issues

##### renv

We've found that some packages have particular issues with backwards / forwards compatibility when using different versions of R.

You'll hit this if you have older versions of some packages but have updated your R version, and you'll see install issues when running `renv::restore()`.
Expand All @@ -122,6 +126,26 @@ Once you've recorded the newest versions, try running `renv::restore()` again to

Be mindful that updating package versions can change behaviour, so make sure to test your dashboard thorough and check all automated tests are still passing after making any package updates.

##### UI test fail

Lines 49 to 68 in the `server.R` script are used to change the app title dependent on some selections.

Updating the app title in the `ui.R` script and the `tests/testthat/test-UI-01-basic_load.R` UI test script may lead to an error when `shinytest2::test_app()` is run. The error may look something similar to:

```
── Failed tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────
Failure (test-UI-01-basic_load.R:30:3): App loads and title of app appears as expected
app$get_text("title") not equal to "Your new app title".
1/1 mismatches
x[1]: "Your new app title - All Local authority maintained schools, England"
y[1]: "Your new app title"
```

To fix / workaround this, please comment out or delete the lines 49 to 68 in the `server.R` script.

However, this feature can be helpful. For example, if you have lots of tabs / pages in your dashboard to switch the title depending on which one a user is looking at. But, its biggest value is for screen readers and assistive tech users, as they will get an announcement every time the title changes.
So, note this may be a useful feature for later on in your app development.

### Tests

Automated tests have been created using shinytest2 that test the app loads and also give other examples of ways you can use tests. You should edit the tests as you add new features into the app and continue to add and maintain the tests over time.
Expand Down
138 changes: 69 additions & 69 deletions google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
<script>
// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

// Default ad_storage to 'denied' as a placeholder
// Determine actual values based on your own requirements
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied'
});
</script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z967JJVQQX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

gtag('js', new Date());

/*
The tracking number below MUST be replaced with a unique number, contact the Explore education statistics platforms team to set this up.
*/
gtag('config', 'G-Z967JJVQQX');


$(document).on('change', 'select#selectPhase', function(e) {
gtag('event', 'select phase', {'event_category' : 'choose Phase',
'event_label' : document.querySelector('select#selectPhase').value
});
});

$(document).on('change', 'select#selectArea', function(e) {
gtag('event', 'select area', {'event_category' : 'choose Area',
'event_label' : document.querySelector('select#selectArea').value
});
});

$(document).on('click', 'ul#navlistPanel', function(e) {
gtag('event', 'navlistPanel', {'event_category' : 'navbar click',
'event_label' : document.querySelector('ul#navlistPanel > li.active > a').getAttribute('data-value')
});
});

$(document).on('click', 'ul#tabsetpanels', function(e) {
gtag('event', 'tab panels', {'event_category' : 'tab panel clicks',
'event_label' : document.querySelector('ul#tabsetpanels > li.active > a').getAttribute('data-value')
});
});


$(document).on('click', 'a#download_data', function(e) {
gtag('event', 'Download button', {'event_category' : 'Download button click'
});
});

$(document).on('shiny:disconnected', function(e) {
gtag('event', 'disconnect', {
'event_label' : 'Disconnect',
'event_category' : 'Disconnect'
});
});



</script>


<script>
// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

// Default ad_storage to 'denied' as a placeholder
// Determine actual values based on your own requirements
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied'
});
</script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

gtag('js', new Date());

/*
The tracking number below MUST be replaced with a unique number, contact the Explore education statistics platforms team to set this up.
*/
gtag('config', 'G-XXXXXXXXXX');


$(document).on('change', 'select#selectPhase', function(e) {
gtag('event', 'select phase', {'event_category' : 'choose Phase',
'event_label' : document.querySelector('select#selectPhase').value
});
});

$(document).on('change', 'select#selectArea', function(e) {
gtag('event', 'select area', {'event_category' : 'choose Area',
'event_label' : document.querySelector('select#selectArea').value
});
});

$(document).on('click', 'ul#navlistPanel', function(e) {
gtag('event', 'navlistPanel', {'event_category' : 'navbar click',
'event_label' : document.querySelector('ul#navlistPanel > li.active > a').getAttribute('data-value')
});
});

$(document).on('click', 'ul#tabsetpanels', function(e) {
gtag('event', 'tab panels', {'event_category' : 'tab panel clicks',
'event_label' : document.querySelector('ul#tabsetpanels > li.active > a').getAttribute('data-value')
});
});


$(document).on('click', 'a#download_data', function(e) {
gtag('event', 'Download button', {'event_category' : 'Download button click'
});
});

$(document).on('shiny:disconnected', function(e) {
gtag('event', 'disconnect', {
'event_label' : 'Disconnect',
'event_category' : 'Disconnect'
});
});



</script>

0 comments on commit a52bcb5

Please sign in to comment.