Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2490 - fixed approver only users to have no mutation controls #2608

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const props = defineProps({
required: false,
default: 45,
},
readOnly: {
type: Boolean,
required: false,
default: false,
}
});

const slop = ref(15);
Expand Down Expand Up @@ -65,7 +70,7 @@ const highlightedValue = computed(() => {
<router-link :data-cy="`manageSkillLink_${skill.skillId}`"
tag="span"
:to="{ name:'SkillOverview', params: { projectId: skill.projectId, subjectId: subjectId, skillId: skill.skillId }}"
:aria-label="`Manage skill ${skill.name} via link`">
:aria-label="`${readOnly ? 'View' : 'Manage'} skill ${skill.name} via link`">
<span data-cy="highlightedValue" class="text-lg inline-block" v-html="highlightedValue" />
</router-link>
<a v-if="truncate"
Expand Down
8 changes: 5 additions & 3 deletions dashboard-prime/src/components/skills/SkillsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ const isLoading = computed(() => {
placeholder="Optional Fields"
data-cy="skillsTable-additionalColumns" />
</div>
<div class="w-full lg:w-auto flex mt-3 lg:mt-0">
<div v-if="!projConfig.isReadOnlyProj" class="w-full lg:w-auto flex mt-3 lg:mt-0">
<div class="flex-1 align-items-center flex">
<label for="sortEnabledSwitch" class="lg:ml-3 mr-1">Reorder:</label>
<InputSwitch
Expand Down Expand Up @@ -524,7 +524,7 @@ const isLoading = computed(() => {
</div>
</template>

<Column selectionMode="multiple" :class="{'flex': responsive.lg.value }">
<Column v-if="!projConfig.isReadOnlyProj" selectionMode="multiple" :class="{'flex': responsive.lg.value }">
<template #header>
<span class="mr-1 lg:mr-0 lg:hidden"><i class="fas fa-check-double"
aria-hidden="true"></i> Select Rows:</span>
Expand Down Expand Up @@ -557,7 +557,9 @@ const isLoading = computed(() => {
<div v-if="!slotProps.data.isGroupType" class="flex-1">
<div class="flex">
<SkillNameRouterLink :skill="slotProps.data" :subjectId="subjectId"
:filter-value="filters.global.value"/>
:filter-value="filters.global.value"
:read-only="projConfig.isReadOnlyProj || slotProps.data.isCatalogImportedSkills"
/>
</div>
<div class="flex flex-wrap gap-1">
<Tag
Expand Down
13 changes: 8 additions & 5 deletions dashboard-prime/src/components/users/UserSkillsPerformed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
<script setup>
import { onMounted, onBeforeMount, ref } from 'vue';
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import { useProjectUserState } from '@/stores/UseProjectUserState.js';
import { useConfirm } from 'primevue/useconfirm';
Expand Down Expand Up @@ -100,7 +100,7 @@ const sortField = (column) => {
table.value.options.pagination.currentPage = 1
loadData();
}
onBeforeMount(() => {
const loadTableFields = () => {
const fields = [
{
key: 'skillId',
Expand All @@ -123,10 +123,13 @@ onBeforeMount(() => {
});
}
table.value.options.fields = fields;
})
}
onMounted(() => {
projectUserState.loadUserDetailsState(projectId.value, route.params.userId)
loadData();
projConfig.afterProjConfigStateLoaded().then(() => {
loadTableFields()
projectUserState.loadUserDetailsState(projectId.value, route.params.userId)
loadData();
});
})
const loadData = () => {
UsersService.getUserInfo(projectId.value, userId.value).then((res) => {
Expand Down
29 changes: 16 additions & 13 deletions e2e-tests/cypress/e2e/approver/approver_role_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('Approver Role Tests', () => {
runCheck(1, 'View', 'Approver','not.')
});

it.skip('/subj page - approver role has no mutation controls', function () {
it('/subj page - approver role has no mutation controls', function () {
const runCheck = (projNum, manageButtonTxt = 'Manage', assertChainPrepend = null) => {
const chainerPrepend = assertChainPrepend ? assertChainPrepend : '';
cy.visit(`/administrator/projects/proj${projNum}/subjects/subj1`);
Expand All @@ -185,8 +185,7 @@ describe('Approver Role Tests', () => {
cy.get('[data-cy="newGroupButton"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="newSkillButton"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="skillActionsBtn"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="clearSelectedSkillsBtn"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="selectAllSkillsBtn"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="skillsTable"] [data-pc-name="headercheckbox"] [data-pc-section="input"]').should(`${chainerPrepend}exist`)

cy.get('[data-cy="editSkillButton_skill1"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="editSkillButton_skill2"]').should(`${chainerPrepend}exist`)
Expand All @@ -196,17 +195,21 @@ describe('Approver Role Tests', () => {
cy.get('[data-cy="copySkillButton_skill2"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="copySkillButton_skill3"]').should(`${chainerPrepend}exist`)

cy.get('[data-cy="deleteSkillButton_skill1"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="deleteSkillButton_skill2"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="deleteSkillButton_skill3"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="deleteSkillButton_skill3"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="deleteSkillButton_skill3"]').should(`${chainerPrepend}exist`)

cy.get('[data-cy="manageSkillLink_skill3"]').contains(manageButtonTxt)
cy.get('[data-cy="manageSkillLink_skill3"]').contains(manageButtonTxt)
cy.get('[data-cy="manageSkillLink_skill3"]').contains(manageButtonTxt)
cy.get('[data-cy="manageSkillLink_skill1"]').invoke('attr', 'aria-label').should('contain', manageButtonTxt)
cy.get('[data-cy="manageSkillLink_skill2"]').invoke('attr', 'aria-label').should('contain', manageButtonTxt)
cy.get('[data-cy="manageSkillLink_skill3"]').invoke('attr', 'aria-label').should('contain', manageButtonTxt)

cy.get('[data-cy="skillsTable"] [data-p-index="0"] [data-pc-name="rowcheckbox"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="skillsTable"] [data-p-index="1"] [data-pc-name="rowcheckbox"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="skillsTable"] [data-p-index="2"] [data-pc-name="rowcheckbox"]').should(`${chainerPrepend}exist`)

cy.get('[data-cy="skillSelect-skill1"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="skillSelect-skill2"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="skillSelect-skill3"]').should(`${chainerPrepend}exist`)
if (assertChainPrepend == null) {
cy.get('[data-cy="enableDisplayOrderSort"]').click()
}

cy.get('[data-cy="orderMoveDown_skill1"]').should(`${chainerPrepend}exist`)
cy.get('[data-cy="orderMoveDown_skill2"]').should(`${chainerPrepend}exist`)
Expand Down Expand Up @@ -384,7 +387,7 @@ describe('Approver Role Tests', () => {
runCheck(1, 'View','not.')
});

it.skip('/users/user/skillEvents page - approver role has no mutation controls', function () {
it('/users/user/skillEvents page - approver role has no mutation controls', function () {
const runCheck = (projNum, manageButtonTxt = 'Manage', assertChainPrepend = null) => {
const chainerPrepend = assertChainPrepend ? assertChainPrepend : '';
cy.visit(`/administrator/projects/proj${projNum}/users/user2/skillEvents`);
Expand All @@ -395,7 +398,7 @@ describe('Approver Role Tests', () => {
runCheck(1, 'View','not.')
});

it.skip('/metrics page - approver role has no mutation controls', function () {
it('/metrics page - approver role has no mutation controls', function () {
const runCheck = (projNum, manageButtonTxt = 'Manage', assertChainPrepend = null) => {
const chainerPrepend = assertChainPrepend ? assertChainPrepend : '';
cy.visit(`/administrator/projects/proj${projNum}/metrics`);
Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,16 @@ Cypress.Commands.add("removeFromMyProjects", (projNum) => {
cy.request('DELETE', `/api/myprojects/proj${projNum}`, {});
});

Cypress.Commands.add("register", (user, pass, grantRoot, usernameForDisplay = null) => {
Cypress.Commands.add("register", (user, pass, grantRoot, usernameForDisplay = null, firstName = 'Firstname', lastName = 'LastName') => {
let requestStatus = 0;
cy.request(`/app/users/validExistingDashboardUserId/${user}`)
.then((response) => {
if (response.body !== true) {
if (grantRoot) {
cy.log(`Creating root user [${user}]`)
cy.request('PUT', '/createRootAccount', {
firstName: 'Firstname',
lastName: 'LastName',
firstName,
lastName,
email: user,
password: pass,
usernameForDisplay,
Expand Down
Loading