From 4e8b19e25265c5c84291b014f3085139acef78b6 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 11 Nov 2024 14:33:42 +1100 Subject: [PATCH 1/2] refactor(@dpc-sdp/ripple-tide-api): :recycle: check for empty document --- .../fixture-api/pages/_fixture/document.vue | 35 +++++++++++++++++++ .../markup-transpiler/complex.fixture.js | 5 +++ .../utils/markup-transpiler/complex.test.ts | 9 +++++ .../markup-transpiler/default-plugins.ts | 5 +++ 4 files changed, 54 insertions(+) create mode 100644 examples/nuxt-app/layers/fixture-api/pages/_fixture/document.vue create mode 100644 packages/ripple-tide-api/src/utils/markup-transpiler/complex.fixture.js create mode 100644 packages/ripple-tide-api/src/utils/markup-transpiler/complex.test.ts diff --git a/examples/nuxt-app/layers/fixture-api/pages/_fixture/document.vue b/examples/nuxt-app/layers/fixture-api/pages/_fixture/document.vue new file mode 100644 index 000000000..55f3480a7 --- /dev/null +++ b/examples/nuxt-app/layers/fixture-api/pages/_fixture/document.vue @@ -0,0 +1,35 @@ + + + diff --git a/packages/ripple-tide-api/src/utils/markup-transpiler/complex.fixture.js b/packages/ripple-tide-api/src/utils/markup-transpiler/complex.fixture.js new file mode 100644 index 000000000..49ef7afe1 --- /dev/null +++ b/packages/ripple-tide-api/src/utils/markup-transpiler/complex.fixture.js @@ -0,0 +1,5 @@ +export default { + api: '

Important note

The resources on this page are password-protected and accessible only to departments, entities and agencies internal to the Victorian Public Sector (VPS).

Victorian Government users can request a login by contacting the website administrator via email to dtfweb@dtf.vic.gov.au. Please state the name of your organisation, your job title, and details of the resources you require access to.

2008 long service leave model

The objective of the 2008 long service leave (LSL) model is to provide an estimation, based on nominal leave amounts from the personnel system, of the LSL liability to be recognised in the financial statements. This model provides estimation at financial year end, and can also be updated at quarterly intervals.

The 2008 model also generates estimates of associated on-cost and provides index factors that can be used to allocate LSL liability to cost centres. In addition, the LSL model enables adjustments to employee numbers to allow for the impact of machinery of government or other administrative changes.

A single weighted average discount rate, which the 2008 LSL model requires, was originally issued for use with this LSL model on 1 July 2008 and is updated quarterly.

\n
\n
\n
\n
\n
\n

User documentation for 2008 model

User documentation has been written to assist users in understanding and navigating through the 2008 LSL model, and consists of:

\n
\n
\n
\n
\n
\n

2004 long service leave model

DTF no longer supports the maintenance of the 2004 long service leave model (the 2004 model). It is recommended that departments and entities transition to the 2008 model or an alternative by 30 June 2016.

The 2004 model requires the use of 12 year discount rates to calculate long service leave entitlements, which are issued quarterly by DTF (see wage inflation and discount rates). There are two versions of the 2004 model:

\n
\n
\n
\n

Important note

The resources on this page are password-protected and accessible only to departments, entities and agencies internal to the Victorian Public Sector (VPS).

Victorian Government users can request a login by contacting the website administrator via email to dtfweb@dtf.vic.gov.au. Please state the name of your organisation, your job title, and details of the resources you require access to.

', + processed: + '

Important note

The resources on this page are password-protected and accessible only to departments, entities and agencies internal to the Victorian Public Sector (VPS).

Victorian Government users can request a login by contacting the website administrator via email to dtfweb@dtf.vic.gov.au. Please state the name of your organisation, your job title, and details of the resources you require access to.

2008 long service leave model

The objective of the 2008 long service leave (LSL) model is to provide an estimation, based on nominal leave amounts from the personnel system, of the LSL liability to be recognised in the financial statements. This model provides estimation at financial year end, and can also be updated at quarterly intervals.

The 2008 model also generates estimates of associated on-cost and provides index factors that can be used to allocate LSL liability to cost centres. In addition, the LSL model enables adjustments to employee numbers to allow for the impact of machinery of government or other administrative changes.

A single weighted average discount rate, which the 2008 LSL model requires, was originally issued for use with this LSL model on 1 July 2008 and is updated quarterly.

\n
\n \n \n \n \n
\n Long service leave 2008 model\n
\n Excel\n 553.5 KB\n
\n
\n (opens in a new window)\n
\n
\n\n\n
\n \n \n \n \n
\n MOG transitional arrangements - sample Memorandum of Understanding\n
\n Word\n 180.02 KB\n
\n
\n (opens in a new window)\n
\n
\n\n\n
\n \n \n \n \n
\n Long service leave 2008 model - troubleshooting guide\n
\n Word\n 65.9 KB\n
\n
\n (opens in a new window)\n
\n
\n\n

User documentation for 2008 model

User documentation has been written to assist users in understanding and navigating through the 2008 LSL model, and consists of:

\n
\n \n \n \n \n
\n Long service leave 2008 model - overview\n
\n Word\n 371.5 KB\n
\n
\n (opens in a new window)\n
\n
\n\n\n
\n \n \n \n \n
\n Long service leave 2008 model - A step-by-step user guide\n
\n Word\n 1.5 MB\n
\n
\n (opens in a new window)\n
\n
\n\n\n
\n \n \n \n \n
\n Long service leave 2008 model - Introduction\n
\n PPT\n 1.04 MB\n
\n
\n (opens in a new window)\n
\n
\n\n

2004 long service leave model

DTF no longer supports the maintenance of the 2004 long service leave model (the 2004 model). It is recommended that departments and entities transition to the 2008 model or an alternative by 30 June 2016.

The 2004 model requires the use of 12 year discount rates to calculate long service leave entitlements, which are issued quarterly by DTF (see wage inflation and discount rates). There are two versions of the 2004 model:

\n
\n \n \n \n \n
\n Long service leave 2004 - Model 1\n
\n Excel\n 122.5 KB\n
\n
\n (opens in a new window)\n
\n
\n\n\n
\n \n \n \n \n
\n Long service leave 2004 - Model 2\n
\n Excel\n 120.5 KB\n
\n
\n (opens in a new window)\n
\n
\n\n

Important note

The resources on this page are password-protected and accessible only to departments, entities and agencies internal to the Victorian Public Sector (VPS).

Victorian Government users can request a login by contacting the website administrator via email to dtfweb@dtf.vic.gov.au. Please state the name of your organisation, your job title, and details of the resources you require access to.

' +} diff --git a/packages/ripple-tide-api/src/utils/markup-transpiler/complex.test.ts b/packages/ripple-tide-api/src/utils/markup-transpiler/complex.test.ts new file mode 100644 index 000000000..7b53b161b --- /dev/null +++ b/packages/ripple-tide-api/src/utils/markup-transpiler/complex.test.ts @@ -0,0 +1,9 @@ +import { expect, describe } from '@jest/globals' +import markupTranspiler from './index' +import fixture from './complex.fixture.js' + +describe('ripple-tide-api/utils/markup-transpiler/cheerio', () => { + it(`runs plugins on complex markup`, () => { + expect(markupTranspiler(fixture.api)).toEqual(fixture.processed) + }) +}) diff --git a/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts b/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts index b3e7e6125..70bb77961 100644 --- a/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts +++ b/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts @@ -95,6 +95,11 @@ const pluginDocuments = function (this: any) { fileSize = $element.find('.file--size').text(), updated = $element.attr('data-last-updated') + // Remove markup stub if there are no details + if (!title || !link) { + return $element.remove() + } + let updatedMarkup = '' if (updated) { From 02f55512253e78692b4b4ee8de3e8f64b3719d10 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Mon, 11 Nov 2024 14:54:11 +1100 Subject: [PATCH 2/2] test(@dpc-sdp/ripple-tide-api): :white_check_mark: allow empty title but not empty link --- .../src/utils/markup-transpiler/default-plugins.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts b/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts index 70bb77961..7f8431db8 100644 --- a/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts +++ b/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts @@ -96,7 +96,7 @@ const pluginDocuments = function (this: any) { updated = $element.attr('data-last-updated') // Remove markup stub if there are no details - if (!title || !link) { + if (!link) { return $element.remove() }