Skip to content

Commit

Permalink
Merge pull request #2883 from NationalSecurityAgency/t#2882/transcrip…
Browse files Browse the repository at this point in the history
…t_export

#2882: utilize window?.location?.pathname to accurately determine whe…
  • Loading branch information
sudo-may authored Sep 20, 2024
2 parents 3c69f8d + cbb7c09 commit 365e4cd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
8 changes: 7 additions & 1 deletion dashboard/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ import PkiAppBootstrap from '@/components/access/PkiAppBootstrap.vue'
import { usePrimeVue } from 'primevue/config'
import ScrollToTop from '@/common-components/utilities/ScrollToTop.vue'
import IconManagerService from '@/components/utils/iconPicker/IconManagerService.js'
import log from 'loglevel';
log.setLevel('WARN')
const authState = useAuthState()
const appInfoState = useAppInfoState()
Expand Down Expand Up @@ -96,7 +99,9 @@ watch(() => themeHelper.currentTheme, (newTheme, oldTheme) => {
const iframeInit = useIframeInit()
onBeforeMount(() => {
iframeInit.handleHandshake()
if (skillsDisplayInfo.isSkillsClientPath()) {
iframeInit.handleHandshake()
}
errorHandling.registerErrorHandling()
userAgreementInterceptor.register()
customGlobalValidators.addValidators()
Expand All @@ -106,6 +111,7 @@ onMounted(() => {
invoke(async () => {
if (skillsDisplayInfo.isSkillsClientPath()) {
await until(iframeInit.loadedIframe).toBe(true)
log.debug('App.vue: skillsDisplayInfo.isSkillsClientPath()=true, loaded iframe!')
}
loadConfigs()
})
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/skills-display/UseSkillsDisplayInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useSkillsDisplayInfo = () => {
const localTestContextAppend = SkillsDisplayPathAppendValues.LocalTest

const isSkillsClientPath = () => {
return route.path.startsWith('/static/clientPortal/')
return window?.location?.pathname.startsWith('/static/clientPortal/')
}
const getContextSpecificRouteName = (name) => {
if (isSkillsClientPath()) {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/skills-display/iframe/UseIframeInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export const useIframeInit = () => {
// whether to use an internal back button as opposed to the browser back button
// displayAttributes.internalBackButton = parent.model.internalBackButton == null || parent.model.internalBackButton

log.debug(`UseIframeInit.js: serviceUrl: [${displayAttributes.serviceUrl}], projectId: [${displayAttributes.projectId}]`)
parentState.serviceUrl = parent.model.serviceUrl

displayAttributes.projectId = parent.model.projectId
displayAttributes.serviceUrl = parent.model.serviceUrl
log.debug(`UseIframeInit.js: serviceUrl: [${displayAttributes.serviceUrl}], projectId: [${displayAttributes.projectId}]`)

if (parent.model.options) {
parentState.options = { ...parent.model.options }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,4 +684,39 @@ describe('Transcript export tests', () => {
})
})

it('ability to export transcript from skills-client', () => {
const projName = 'Has Subject and Skills'
cy.createProject(1, { name: projName })
cy.createSubject(1)
cy.createSkill(1, 1, 1)
cy.createSkill(1, 1, 2)
cy.createSkill(1, 1, 3)

cy.reportSkill(1, 1, user, 'now')

cy.ignoreSkillsClientError()
cy.intercept('/api/projects/proj1/pointHistory').as('getProjPointsHistory')
cy.visit('/test-skills-client/proj1')
cy.wait('@getProjPointsHistory')
cy.wrapIframe().find('[data-cy="downloadTranscriptBtn"]').click()

cy.readTranscript(projName).then((doc) => {
expect(doc.numpages).to.equal(2)
expect(clean(doc.text)).to.include('SkillTree Transcript')
expect(clean(doc.text)).to.include(projName)
expect(clean(doc.text)).to.include('Level: 1 / 5 ')
expect(clean(doc.text)).to.include('Points: 100 / 600 ')
expect(clean(doc.text)).to.include('Skills: 0 / 3 ')
expect(clean(doc.text)).to.not.include('Badges')

// should be a title on the 2nd page
expect(clean(doc.text)).to.include('Subject: Subject 1'.toUpperCase())

expect(clean(doc.text)).to.not.include(expectedHeaderAndFooter)
expect(clean(doc.text)).to.not.include(expectedHeaderAndFooterCommunityProtected)
expect(clean(doc.text)).to.not.include('null')
})
})


})

0 comments on commit 365e4cd

Please sign in to comment.