Skip to content

Commit

Permalink
#2490: working on tests for project admin management and project modal
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-may committed Jun 11, 2024
1 parent 6611e86 commit 77b5163
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
- name: Run Cypress tests
run: |
cd e2e-tests
../.github/scripts/runSubsetOfCypressTests.sh -t 6 -c ${{ matrix.container }} -f 'projects_crud|/skills_table_spec|/skill_reuse_spec|quiz_creation|question_def|metrics-reUsedData_spec|quiz_and_survey|quiz_runs|quiz_skill_assignment|quiz_read|quiz_role|quiz_settings|quiz_skills-in_project_reuse|client-display_quiz_spec|client-display_quiz_theme_spec|client-display_quiz_visual_spec|client-display_run_quiz_spec|run_survey_spec|quiz_skills-catalog_spec|/inception|user_actions|configure-skill-expiration_spec|skill-expiration-table_spec|configure_video_spec|configure_video_features_spec|configure_skill_video_self_report_spec|configure_video_validation_spec|handle_video_without_duration_spec|client_display_video_on_subject_page_spec|client_display_video_on_skill_page_spec|/skills_spec|/users_spec|/subjects_spec|/levels_management_spec|/skills_group_spec|/skills_group_modal_spec|/move-skills/|/badges_spec|/skill-reuse/skill_reuse/|/catalog/|/project_settings_spec|/icon_manager_spec|/not_found_spec|my-usage_spec|/error_pages_spec|/add_skills_to_badge_spec|/tag-skills|/settings_spec|/client-display/|/learning-path/|/copy_project_spec|/project_errors_spec|/selfReport-approvalHistory_spec|/approver|/manage-my-projects_spec|/accessibility|/community/|/metrics/projectMetrics|/metrics/skillMetrics_spec|/metrics/subjectMetrics_spec|/projects_invite_only_spec|/app_features_spec|/breadcrumb_spec|/contact|/cross-project_spec|/discoverable_proj_invite_spec|/login_spec|/markdown_spec/metrics/multipleProjectMetrics_empty_spec|/metrics/multipleProjectMetrics_spec|/my-progress_breadcrumb_spec|/my-progress_spec|/my-progress-badges_spec|/navigation_spec|/progress_and_ranking_disabled_spec|/project_expiration_spec|performedSkills_table_spec'
../.github/scripts/runSubsetOfCypressTests.sh -t 6 -c ${{ matrix.container }} -f 'projects_crud|/skills_table_spec|/skill_reuse_spec|quiz_creation|question_def|metrics-reUsedData_spec|quiz_and_survey|quiz_runs|quiz_skill_assignment|quiz_read|quiz_role|quiz_settings|quiz_skills-in_project_reuse|client-display_quiz_spec|client-display_quiz_theme_spec|client-display_quiz_visual_spec|client-display_run_quiz_spec|run_survey_spec|quiz_skills-catalog_spec|/inception|user_actions|configure-skill-expiration_spec|skill-expiration-table_spec|configure_video_spec|configure_video_features_spec|configure_skill_video_self_report_spec|configure_video_validation_spec|handle_video_without_duration_spec|client_display_video_on_subject_page_spec|client_display_video_on_skill_page_spec|/skills_spec|/users_spec|/subjects_spec|/levels_management_spec|/skills_group_spec|/skills_group_modal_spec|/move-skills/|/badges_spec|/skill-reuse/skill_reuse/|/catalog/|/project_settings_spec|/icon_manager_spec|/not_found_spec|my-usage_spec|/error_pages_spec|/add_skills_to_badge_spec|/tag-skills|/settings_spec|/client-display/|/learning-path/|/copy_project_spec|/project_errors_spec|/selfReport-approvalHistory_spec|/approver|/manage-my-projects_spec|/accessibility|/community/|/metrics/projectMetrics|/metrics/skillMetrics_spec|/metrics/subjectMetrics_spec|/projects_invite_only_spec|/app_features_spec|/breadcrumb_spec|/contact|/cross-project_spec|/discoverable_proj_invite_spec|/login_spec|/markdown_spec/metrics/multipleProjectMetrics_empty_spec|/metrics/multipleProjectMetrics_spec|/my-progress_breadcrumb_spec|/my-progress_spec|/my-progress-badges_spec|/navigation_spec|/progress_and_ranking_disabled_spec|/project_expiration_spec|performedSkills_table_spec|/projects_admin_management_spec|/projects_modal_management_spec'
cd ..
env:
ELECTRON_EXTRA_LAUNCH_ARGS: '--disable-gpu'
Expand Down
43 changes: 25 additions & 18 deletions dashboard-prime/src/components/access/RoleManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,25 @@ onMounted(() => {
loadData();
});
const sortInfo = ref({ sortOrder: 1, sortBy: 'userId' })
const possiblePageSizes = [ 5, 10, 15, 20]
const pageSize = ref(5)
let table = ref({
options: {
busy: true,
sortBy: 'userId',
sortDesc: 1,
pagination: {
hideUnnecessary: true,
server: false,
currentPage: 1,
totalRows: 1,
pageSize: 5,
possiblePageSizes: [5, 10, 15, 20],
},
tableDescription: `${props.roleDescription} table`,
},
});
let data = ref([]);
let userIds = ref([]);
const data = ref([]);
const userIds = computed(() => data.value.map((d) => d.userId));
const selectedUser = ref(null);
const isSaving = ref(false);
const errNotification = ref({
Expand Down Expand Up @@ -130,19 +130,18 @@ function getRoleDisplay(roleName) {
return 'Unknown';
}
function loadData() {
const loadData = () => {
table.value.options.busy = true;
const pageParams = {
limit: 200,
ascending: table.value.options.sortDesc === 1,
page: 1,
orderBy: table.value.options.sortBy,
ascending: sortInfo.value.sortOrder === 1,
orderBy: sortInfo.value.sortBy
};
AccessService.getUserRoles(props.projectId, props.roles, pageParams).then((result) => {
table.value.options.busy = false;
data.value = result.data;
table.value.options.pagination.totalRows = result.totalCount;
// userIds.value = result.data.map((u) => [u.userId, u.userIdForDisplay]).flatten();
});
}
Expand Down Expand Up @@ -225,7 +224,7 @@ function deleteUserRole(row) {
table.value.options.busy = true;
AccessService.deleteUserRole(row.projectId, row.userId, row.roleName).then(() => {
data.value = data.value.filter((item) => item.userId !== row.userId);
userIds.value = userIds.value.filter((userId) => userId !== row.userId && userId !== row.userIdForDisplay);
userIds.value = userIds.value.filter((userId) => userId !== row.userId);
emit('role-deleted', { userId: row.userId, role: row.roleName });
table.value.options.busy = false;
table.value.options.pagination.totalRows = data.value.length;
Expand Down Expand Up @@ -317,13 +316,20 @@ defineExpose({
<strong>Error!</strong> Request could not be completed! {{ errNotification.msg }}
</Message>
</div>
<DataTable :value="data" :rowsPerPageOptions="[5, 10, 15, 20]" data-cy="roleManagerTable" striped-rows
v-model:sort-field="table.options.sortBy"
v-model:sort-order="table.options.sortDesc"
paginator :rows="5">
<SkillsDataTable
:value="data"
:rowsPerPageOptions="possiblePageSizes"
data-cy="roleManagerTable"
tableStoredStateId="roleManagerTableSort"
striped-rows
paginator
v-model:sort-field="sortInfo.sortBy"
v-model:sort-order="sortInfo.sortOrder"
:rows="pageSize">
<Column :header="roleDescription" field="userId" sortable :class="{'flex': responsive.md.value }">
<template #header>
<span class="mr-2"><i class="fas fa-user skills-color-users" :class="colors.getTextClass(0)" aria-hidden="true"></i> </span>
<span class="mr-2"><i class="fas fa-user skills-color-users" :class="colors.getTextClass(0)"
aria-hidden="true"></i> </span>
</template>
<template #body="slotProps">
<div :data-cy="`userCell_${slotProps.data.userId}`">
Expand All @@ -333,7 +339,8 @@ defineExpose({
</Column>
<Column header="Role" field="roleName" sortable :class="{'flex': responsive.md.value }">
<template #header>
<span class="mr-2"><i class="fas fa-id-card text-danger" :class="colors.getTextClass(1)" aria-hidden="true"></i> </span>
<span class="mr-2"><i class="fas fa-id-card text-danger" :class="colors.getTextClass(1)"
aria-hidden="true"></i> </span>
</template>
<template #body="slotProps">
<div v-if="!slotProps.data.isEdited">{{ getRoleDisplay(slotProps.data.roleName) }}</div>
Expand Down Expand Up @@ -383,7 +390,7 @@ defineExpose({
<template #empty>
<span class="flex align-items-center justify-content-center">There are no records to show</span>
</template>
</DataTable>
</SkillsDataTable>
</div>
</template>
</Card>
Expand Down
47 changes: 26 additions & 21 deletions e2e-tests/cypress/e2e/projects_admin_management_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('Projects Admin Management Tests', () => {
.contains('Failed to add User Role');
});

it.skip('Add Admin No Query', () => {
it('Add Admin No Query', () => {
cy.request('POST', '/app/projects/proj1', {
projectId: 'proj1',
name: 'proj1'
Expand All @@ -157,13 +157,12 @@ describe('Projects Admin Management Tests', () => {
cy.wait('@loadUserInfo');
cy.wait('@loadProject');

cy.get('[data-cy="existingUserInput"]')
.type('{enter}');
cy.get('[data-cy="existingUserInputDropdown"] [data-pc-name="dropdownbutton"]').click()
cy.wait('@suggest');
cy.wait(500);
cy.contains('[email protected]')
.click();
cy.get('[data-cy="userRoleSelector"]') .select('Administrator');
cy.get('#existingUserInput_0').contains('[email protected]').click();
cy.get('[data-cy="userRoleSelector"]').click()
cy.get('[data-pc-section="panel"] [aria-label="Administrator"]').click();
cy.get('[data-cy="addUserBtn"]').click();
cy.wait('@addAdmin');

Expand Down Expand Up @@ -205,7 +204,7 @@ describe('Projects Admin Management Tests', () => {
}
});

it.skip('Add and Remove Admin', () => {
it('Add and Remove Admin', () => {
cy.request('POST', '/app/projects/proj1', {
projectId: 'proj1',
name: 'proj1'
Expand All @@ -229,9 +228,9 @@ describe('Projects Admin Management Tests', () => {
.type('root');
cy.wait('@suggest');
cy.wait(500);
cy.get('.vs__dropdown-option').contains('root@skills.org')
.click();
cy.get('[data-cy="userRoleSelector"]') .select('Administrator');
cy.get('#existingUserInput_0').contains('root').click();
cy.get('[data-cy="userRoleSelector"]').click()
cy.get('[data-pc-section="panel"] [aria-label="Administrator"]').click();
cy.get('[data-cy="addUserBtn"]').click();
cy.wait('@addAdmin');

Expand All @@ -254,7 +253,7 @@ describe('Projects Admin Management Tests', () => {
.as('cyRows1');
});

it.skip('Add Admin - forward slash character does not cause error', () => {
it('Add Admin - forward slash character does not cause error', () => {
cy.request('POST', '/app/projects/proj1', {
projectId: 'proj1',
name: 'proj1'
Expand All @@ -280,7 +279,7 @@ describe('Projects Admin Management Tests', () => {
cy.wait('@suggest');
});

it.skip('Add Approver role then upgrade to Admin', () => {
it('Add Approver role then upgrade to Admin', () => {
cy.request('POST', '/app/projects/proj1', {
projectId: 'proj1',
name: 'proj1'
Expand All @@ -306,9 +305,9 @@ describe('Projects Admin Management Tests', () => {
.type('root');
cy.wait('@suggest');
cy.wait(500);
cy.get('.vs__dropdown-menu').contains('root@skills.org')
.click();
cy.get('[data-cy="userRoleSelector"]').select('Approver');
cy.get('#existingUserInput_0').contains('root').click();
cy.get('[data-cy="userRoleSelector"]').click()
cy.get('[data-pc-section="panel"] [aria-label="Approver"]').click();
cy.get('[data-cy="addUserBtn"]').click();
cy.wait('@addApprover');

Expand All @@ -332,15 +331,17 @@ describe('Projects Admin Management Tests', () => {
], 5, true, null, false);

cy.get(`${tableSelector} [data-cy="[email protected]"] [data-cy="editUserBtn"]`).click();
cy.get('[data-cy="[email protected]"]').select('Administrator');
cy.get('[data-cy="[email protected]"]').click()
cy.get('[data-pc-section="panel"] [data-pc-section="itemlabel"]').contains('Administrator').click();
cy.wait('@addAdmin')
cy.get(`${tableSelector} thead th`).contains('User').click();
cy.validateTable(tableSelector, [
[{ colIndex: 0, value: expectedUserName }, { colIndex: 1, value: 'Administrator' }],
[{ colIndex: 0, value: 'root@' }, { colIndex: 1, value: 'Administrator' }],
[{ colIndex: 0, value: expectedUserName }, { colIndex: 1, value: 'Administrator' }],
], 5, true, null, false);
});

it.skip('Existing projects are not suggested', () => {
it('Existing users are not suggested', () => {
cy.register('newuser', 'password', false, 'some display name')
cy.fixture('vars.json').then((vars) => {
cy.logout()
Expand Down Expand Up @@ -370,17 +371,21 @@ describe('Projects Admin Management Tests', () => {
cy.get('[data-cy="existingUserInput"]').type('some');
cy.wait('@suggest');
cy.wait(500);
cy.get('.vs__dropdown-menu').contains('some display name')
cy.get('[data-pc-section="list"] [data-pc-section="item"]').should('have.length', 1)
cy.get('[data-pc-section="list"]').contains('some display name')
.click();
cy.get('[data-cy="userRoleSelector"]').select('Approver');
cy.get('[data-cy="userRoleSelector"]').click()
cy.get('[data-pc-section="panel"] [aria-label="Approver"]').click();
cy.get('[data-cy="addUserBtn"]').click();


cy.wait('@addApprover');

cy.get('[data-cy="userCell_newuser"]').should("exist");
cy.get('[data-cy="existingUserInput"]').type('some');
cy.wait('@suggest');
cy.wait(1500);
cy.get('.vs__dropdown-menu').contains('some display name').should('not.exist')
cy.get('[data-pc-section="list"] [data-pc-section="item"]').should('have.length', 0)
});

})
Loading

0 comments on commit 77b5163

Please sign in to comment.