-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(glance-tag): tag pages with cobrowse script for glance EB-774
- Loading branch information
Orion Wolf-Hubbard
committed
Nov 20, 2024
1 parent
5897344
commit 693a255
Showing
11 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# @availity/glance-tag | ||
|
||
> adds a script to allow glance to view the page for share my screen support | ||
## Installation | ||
|
||
### NPM | ||
|
||
```bash | ||
npm install @availity/glance-tag | ||
``` | ||
|
||
### Yarn | ||
|
||
```bash | ||
yarn add @availity/glance-tag | ||
``` | ||
|
||
## Usage | ||
|
||
> All you have to do is include this as a dependency and import it into the root of your web application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const global = require('../../jest.config'); | ||
|
||
module.exports = { | ||
...global, | ||
displayName: 'glance-tag', | ||
coverageDirectory: '../../coverage/glance-tag', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@availity/glance-tag", | ||
"version": "0.0.0", | ||
"description": "adds a script to allow glance to view the page for share my screen support", | ||
"main": "src/index.js", | ||
"keywords": [], | ||
"author": "Orion Wolf-Hubbard <[email protected]>", | ||
"engines": { | ||
"node": "^18.0.0 || ^20.0.0" | ||
}, | ||
"dependencies": { | ||
"@availity/env-var": "workspace:*" | ||
}, | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "@availity/glance-tag", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "library", | ||
"targets": { | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/resolve-url"], | ||
"options": { | ||
"jestConfig": "packages/glance-tag/jest.config.js" | ||
} | ||
}, | ||
"version": { | ||
"executor": "@jscutlery/semver:version", | ||
"options": { | ||
"preset": "angular", | ||
"commitMessageFormat": "chore(glance-tag): release version ${version} [skip ci]", | ||
"tagPrefix": "{projectName}@", | ||
"baseBranch": "master", | ||
"trackDeps": true | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"options": { | ||
"eslintConfig": ".eslintrc.yaml", | ||
"silent": false, | ||
"fix": false, | ||
"cache": true, | ||
"cacheLocation": "./node_modules/.cache/glance-tag/.eslintcache", | ||
"maxWarnings": -1, | ||
"quiet": false, | ||
"noEslintrc": false, | ||
"hasTypeAwareRules": true, | ||
"cacheStrategy": "metadata" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* eslint-disable unicorn/no-empty-file */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable unicorn/prefer-dom-node-dataset */ | ||
import envVar from '@availity/env-var' | ||
|
||
export const addGlanceScript = () => { | ||
const script = document.createElement('script') | ||
const isProd = envVar({ prod: true }) | ||
const site = isProd ? 'production' : 'staging' | ||
|
||
script.setAttribute('id', 'glance-cobrowse') | ||
script.setAttribute('charset', 'glance-cobrowse') | ||
script.setAttribute('type', 'text/javascript') | ||
script.setAttribute('src', `https://www.glancecdn.net/cobrowse/CobrowseJS.ashx?group=21510&site=${site}`) | ||
script.setAttribute('data-groupid', '21510') | ||
script.setAttribute('data-site', site) | ||
script.setAttribute('data-ws', 'www.glance.net') | ||
script.setAttribute('data-presence', 'on') | ||
script.setAttribute('data-cookietype', 'normal') | ||
|
||
document.head.append(script) | ||
} | ||
|
||
window.addEventListener('load', addGlanceScript); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const envVar = require('@availity/env-var') | ||
const { addGlanceScript } = require('../index') | ||
|
||
jest.mock('@availity/env-var/src', () => jest.fn()) | ||
|
||
describe('glance-tag', () => { | ||
beforeEach(() => { | ||
document.head.innerHTML = ''; | ||
}); | ||
|
||
test('load event should add glance script just from importing package', () => { | ||
window.dispatchEvent(new Event('load')) | ||
const scriptTag = document.getElementById('glance-cobrowse') | ||
expect(scriptTag).not.toBeNull() | ||
}) | ||
|
||
test('glance script should have production site in production', () => { | ||
envVar.mockReturnValue(true) | ||
addGlanceScript() | ||
const scriptTag = document.getElementById('glance-cobrowse') | ||
expect(scriptTag.src).toBe('https://www.glancecdn.net/cobrowse/CobrowseJS.ashx?group=21510&site=production') | ||
}) | ||
|
||
test('glance script should have staging site when not in production', () => { | ||
envVar.mockReturnValue(undefined) | ||
addGlanceScript() | ||
const scriptTag = document.getElementById('glance-cobrowse') | ||
expect(scriptTag.src).toBe('https://www.glancecdn.net/cobrowse/CobrowseJS.ashx?group=21510&site=staging') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["."], | ||
"exclude": ["dist", "build", "node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"], | ||
"allowJs": true | ||
}, | ||
"include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters