Skip to content

Commit 91314bf

Browse files
authored
Merge pull request #3419 from NationalSecurityAgency/t#3418/position_top_in_iframe
#3418: use `position=top` for search dialog when displaying within an…
2 parents 78ac890 + 2a41c33 commit 91314bf

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed

dashboard/src/skills-display/components/SkillsDisplaySearch.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616
<script setup>
17-
import { nextTick, onMounted, ref } from 'vue'
17+
import { computed, nextTick, onMounted, ref } from 'vue'
1818
import SkillsDialog from '@/components/utils/inputForm/SkillsDialog.vue'
1919
import { useSkillsDisplayService } from '@/skills-display/services/UseSkillsDisplayService.js'
2020
import { useSkillsAnnouncer } from '@/common-components/utilities/UseSkillsAnnouncer.js'
@@ -24,7 +24,7 @@ import { useFocusState } from '@/stores/UseFocusState.js'
2424
import SkillsSpinner from '@/components/utils/SkillsSpinner.vue'
2525
import { useSkillsDisplayAttributesState } from '@/skills-display/stores/UseSkillsDisplayAttributesState.js'
2626
27-
const emit = defineEmits(['level-changed', 'hidden']);
27+
const emit = defineEmits(['hidden']);
2828
const props = defineProps({
2929
projectId: {
3030
type: String,
@@ -139,6 +139,9 @@ const getTotalProgress = (skill) => {
139139
const getProgressLabel = (skill) => {
140140
return isSkill(skill) ? attributes.pointDisplayNamePlural : attributes.skillDisplayNamePlural
141141
}
142+
const dialogPosition = computed(() => {
143+
return skillDisplayInfo.isSkillsClientPath() ? 'top' : 'center'
144+
});
142145
</script>
143146
144147
<template>
@@ -149,6 +152,7 @@ const getProgressLabel = (skill) => {
149152
:aria-label="`Search for ${attributes.subjectDisplayName}s, ${attributes.skillDisplayName}s or Badges`"
150153
:enable-return-focus="true"
151154
@on-cancel="closeMe"
155+
:position="dialogPosition"
152156
:show-header="false"
153157
:show-ok-button="false"
154158
:show-cancel-button="false"

e2e-tests/cypress/e2e/client-display/skills-display-training-wide-search_spec.js

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe('Training Keyboard Shortcuts Tests', () => {
205205
cy.get('[data-cy="trainingSearchDialog"]').should('be.visible')
206206
})
207207

208-
it('search dialog honers custom labels', () => {
208+
it('search dialog honors custom labels', () => {
209209
cy.createProject(1);
210210
cy.createSubject(1, 1);
211211
cy.createSkill(1, 1, 1);
@@ -234,5 +234,60 @@ describe('Training Keyboard Shortcuts Tests', () => {
234234
cy.get('[data-cy="subjectName"]').first().should('have.text', "Course: Subject 1");
235235
});
236236

237+
it('client-display: training-wide search dialog is visible and displayed with position=top when in client-display iframe', () => {
238+
cy.createProject(1)
239+
cy.createSubject(1, 1)
240+
cy.createSkill(1, 1, 1)
241+
cy.createSkill(1, 1, 2)
242+
cy.createSkill(1, 1, 3)
243+
cy.createBadge(1, 1);
244+
cy.assignSkillToBadge(1, 1, 1);
245+
cy.createBadge(1, 1, { enabled: true });
246+
247+
cy.visit('/test-skills-client/proj1')
248+
cy.wrapIframe().contains('Overall Points');
249+
250+
cy.wrapIframe().find('[data-cy="skillsDisplaySearchBtn"]').click()
251+
cy.wait(1000)
252+
cy.wrapIframe().find('[data-cy="trainingSearchDialog"]').should('be.visible')
253+
cy.wrapIframe().find('[data-cy="trainingSearchDialog"]').first().then(($el) => {
254+
const bounding = $el[0].getBoundingClientRect();
255+
const windowWidth = Cypress.config('viewportWidth');
256+
const windowHeight = Cypress.config('viewportHeight');
257+
258+
expect(bounding.top).to.be.gte(0);
259+
expect(bounding.left).to.be.gte(0);
260+
expect(bounding.right).to.be.lte(windowWidth);
261+
expect(bounding.bottom).to.be.lte(windowHeight);
262+
});
263+
})
264+
265+
it('training-wide search dialog is visible and displayed with position=center when not in client-display iframe', () => {
266+
cy.createProject(1)
267+
cy.createSubject(1, 1)
268+
cy.createSkill(1, 1, 1)
269+
cy.createSkill(1, 1, 2)
270+
cy.createSkill(1, 1, 3)
271+
cy.createBadge(1, 1);
272+
cy.assignSkillToBadge(1, 1, 1);
273+
cy.createBadge(1, 1, { enabled: true });
274+
275+
cy.visit('/progress-and-rankings/projects/proj1');
276+
cy.contains('Overall Points');
277+
278+
cy.get('[data-cy="skillsDisplaySearchBtn"]').click()
279+
cy.wait(1000)
280+
cy.get('[data-cy="trainingSearchDialog"]').should('be.visible')
281+
cy.get('[data-cy="trainingSearchDialog"]').first().then(($el) => {
282+
const bounding = $el[0].getBoundingClientRect();
283+
const windowWidth = Cypress.config('viewportWidth');
284+
const windowHeight = Cypress.config('viewportHeight');
285+
286+
expect(bounding.top).to.be.gte(0);
287+
expect(bounding.left).to.be.gte(0);
288+
expect(bounding.right).to.be.lte(windowWidth);
289+
expect(bounding.bottom).to.be.lte(windowHeight);
290+
});
291+
})
237292

238293
})

0 commit comments

Comments
 (0)