Skip to content

Commit

Permalink
#2489 - rename button's label to "Show Justification" for Approval Re…
Browse files Browse the repository at this point in the history
…quested items in the history and fixed id prop for markdown-text in ApprovalEventMessage
  • Loading branch information
rmmayo committed Jan 13, 2025
1 parent 31668e4 commit 7111211
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ import MarkdownText from '@/common-components/utilities/markdown/MarkdownText.vu
const props = defineProps({
message: String,
messageId: String
messageId: String,
isApprovalRequest: {
type: Boolean,
default: false,
},
})
const isDescriptionShowing = ref(false)
const showMessageBtnLabel = computed(() => {
return `${isDescriptionShowing.value ? 'Hide' : 'Show'} Message`
return `${isDescriptionShowing.value ? 'Hide' : 'Show'} ${props.isApprovalRequest ? 'Justification' : 'Message'}`
})
const toggleShowMessage = () => {
isDescriptionShowing.value = !isDescriptionShowing.value
Expand All @@ -42,7 +46,7 @@ const toggleShowMessage = () => {
size="small"
@click="toggleShowMessage"
data-cy="toggleShowMessageBtn"/>
<markdown-text v-if="isDescriptionShowing" :text="props.message" :instance-id="props.id" data-cy="approvalEventMessage" />
<markdown-text v-if="isDescriptionShowing" :text="props.message" :instance-id="props.messageId" data-cy="approvalEventMessage" />
</div>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const props = defineProps({
const timeUtils = useTimeUtils()
const REQUESTED = 'Approval Requested'
// const PENDING = 'Pending Approval'
const APPROVED = 'Approved'
const REJECTED = 'Rejected'
const AWAITING_GRADING = "Awaiting Grading"
Expand Down Expand Up @@ -58,6 +57,7 @@ const getIconBackground = (item) => {
}
return 'bg-gray-500'
}
</script>

<template>
Expand All @@ -77,7 +77,7 @@ const getIconBackground = (item) => {
<div>
<span class="text-muted text-sm">{{ timeUtils.formatDate(slotProps.item.eventTime) }}</span>
</div>
<ApprovalEventMessage class="py-2" v-if="slotProps.item.description" :message="slotProps.item.description" :messageId="slotProps.item.id" />
<ApprovalEventMessage class="py-2" v-if="slotProps.item.description" :message="slotProps.item.description" :is-approval-request="slotProps.item.eventStatus === REQUESTED" :messageId="slotProps.item.id" />
</template>
</Timeline>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ describe('Client Display Self Report Skills Tests', () => {
});
});

Cypress.Commands.add('submitForApproval', (skillNum = '1') => {
Cypress.Commands.add('submitForApproval', (skillNum = '1', approvalRequestedMsg = '', timestamp = null) => {
// cy.request('POST', `/api/projects/proj1/skills/${skillId}`)
const m = moment.utc();
cy.request('POST', `/api/projects/proj1/skills/skill${skillNum}`, {
userId: Cypress.env('proxyUser'),
timestamp: m.clone()
if (!timestamp) {
const m = moment.utc();
timestamp = m.clone()
.subtract(5, 'day')
.format('x')
}
cy.request('POST', `/api/projects/proj1/skills/skill${skillNum}`, {
userId: Cypress.env('proxyUser'),
approvalRequestedMsg,
timestamp
});
});
});
Expand Down Expand Up @@ -323,7 +327,7 @@ describe('Client Display Self Report Skills Tests', () => {
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(1)
.get('[data-cy="toggleShowMessageBtn"]')
.find('[data-cy="toggleShowMessageBtn"]')
.click();
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
Expand All @@ -333,7 +337,7 @@ describe('Client Display Self Report Skills Tests', () => {
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(1)
.get('[data-cy="toggleShowMessageBtn"]')
.find('[data-cy="toggleShowMessageBtn"]')
.click();
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
Expand Down Expand Up @@ -912,4 +916,118 @@ describe('Client Display Self Report Skills Tests', () => {
cy.get('[data-cy="overallStars"]').find('[data-p-active="true"]').should('have.length', 1)
cy.get('[data-cy="overallStars"]').find('[data-p-active="false"]').should('have.length', 4)
});

it('self report - expand multiple messages', () => {
cy.createSkill(1, 1, 1, { selfReportingType: 'Approval' });
cy.submitForApproval(1, 'please approve request 1');
cy.rejectRequest();
cy.submitForApproval(1, 'please approve request 2', moment.utc().format('x'));
cy.approveRequest(0, 'I approve this message!');

cy.cdVisit('/');
cy.cdClickSubj(0);
cy.cdClickSkill(0);

cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(0)
.should('contain.text', 'Approved')
.should('contain.text', 'a few seconds ago');
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(0)
.find('[data-cy="toggleShowMessageBtn"]')
.should('contain.text', 'Show Message');
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(0)
.find('[data-cy="toggleShowMessageBtn"]')
.click();
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(0)
.get('[data-cy="approvalEventMessage"]')
.should('contain.text', 'I approve this message!')
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(0)
.find('[data-cy="toggleShowMessageBtn"]')
.should('contain.text', 'Hide Message');

cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(1)
.should('contain.text', 'Approval Requested')
.should('contain.text', 'a few seconds ago');
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(1)
.find('[data-cy="toggleShowMessageBtn"]')
.should('contain.text', 'Show Justification');
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(1)
.find('[data-cy="toggleShowMessageBtn"]')
.click();
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(1)
.get('[data-cy="approvalEventMessage"]')
.should('contain.text', 'please approve request 2')
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(1)
.find('[data-cy="toggleShowMessageBtn"]')
.should('contain.text', 'Hide Justification');

cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(2)
.should('contain.text', 'Rejected')
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(2)
.find('[data-cy="toggleShowMessageBtn"]')
.should('contain.text', 'Show Message');
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(2)
.find('[data-cy="toggleShowMessageBtn"]')
.click();
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(3)
.get('[data-cy="approvalEventMessage"]')
.should('contain.text', 'Skill was rejected')
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(2)
.find('[data-cy="toggleShowMessageBtn"]')
.should('contain.text', 'Hide Message');

cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(3)
.should('contain.text', 'Approval Requested')
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(3)
.find('[data-cy="toggleShowMessageBtn"]')
.should('contain.text', 'Show Justification');
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(3)
.find('[data-cy="toggleShowMessageBtn"]')
.click();
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(3)
.get('[data-cy="approvalEventMessage"]')
.should('contain.text', 'please approve request 1')
cy.get('[data-cy="approvalHistoryTimeline"]')
.children('.p-timeline-event')
.eq(3)
.find('[data-cy="toggleShowMessageBtn"]')
.should('contain.text', 'Hide Justification');
});
});
2 changes: 1 addition & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"cy:run:oauth": "TZ=UTC cypress run --browser chrome --env oauthMode=true --config video=true",
"cy:run:accessibility": "TZ=UTC cypress run --browser chrome --env enableLighthouse=true,enableAvgLighthouseScore=true --browser chrome --headless --spec \"cypress/e2e/accessibility/*.js\" --config video=true",
"cy:run:dev": "TZ=UTC cypress run --browser chrome --config baseUrl=http://localhost:5173 --env visualRegressionType=base",
"cy:run:dev:specificTest": "TZ=UTC cypress run --browser chrome --config baseUrl=http://localhost:5173 --spec \"cypress/e2e/self-report/selfReport-approveOrReject_spec.js\" --env visualRegressionType=base",
"cy:run:dev:specificTest": "TZ=UTC cypress run --browser chrome --config baseUrl=http://localhost:5173 --spec \"cypress/e2e/client-display/client-display-self_report_skills_spec.js\" --env visualRegressionType=base",
"cy:run:dev:updateSnapshotForSpecificTests": "TZ=UTC cypress run --browser chrome --env visualRegressionType=base --config baseUrl=http://localhost:5173 --spec \"cypress/e2e/metrics/skillMetrics_spec.js\"",
"cy:run:dev:metrics": "TZ=UTC cypress run --browser chrome --config baseUrl=http://localhost:5173 --spec \"cypress/e2e/metrics/projectMetrics_projects_spec.js,cypress/e2e/metrics/projectMetrics_subjects_spec.js,cypress/e2e/metrics/skillMetrics_spec.js,cypress/e2e/metrics/subjectMetrics_spec.js\"",
"cy:run:dev:updateAdminSnapshots": "TZ=UTC cypress run --browser chrome --config baseUrl=http://localhost:5173 --env visualRegressionType=base --spec \"cypress/e2e/markdown_spec.js\"",
Expand Down

0 comments on commit 7111211

Please sign in to comment.