Skip to content

Commit

Permalink
#3104: fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-may committed Feb 7, 2025
1 parent 153e4d4 commit 02a77ca
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
4 changes: 2 additions & 2 deletions dashboard/src/components/access/RoleManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ defineExpose({
<template #body="slotProps">
<div v-if="!slotProps.data.adminGroupId || props.adminGroupId">
<div class="float-right mr-1 flex flex-col gap-2" :data-cy="`controlsCell_${slotProps.data.userId}`">
<div v-if="notCurrentUser(slotProps.data.userId)" class="flex items-center">
<ButtonGroup v-if="notCurrentUser(slotProps.data.userId)">
<SkillsButton v-if="!isOnlyOneRole" @click="editItem(slotProps.data)"
:disabled="!notCurrentUser(slotProps.data.userId)"
:aria-label="`edit access role from user ${getUserDisplay(slotProps.data)}`"
Expand All @@ -571,7 +571,7 @@ defineExpose({
:aria-label="`remove access role from user ${getUserDisplay(slotProps.data)}`"
data-cy="removeUserBtn" icon="fas fa-trash" label="Delete" size="small">
</SkillsButton>
</div>
</ButtonGroup>
<InlineMessage v-if="!notCurrentUser(slotProps.data.userId)" class="mt-1" severity="info" size="small"
aria-live="polite" data-cy="cannotRemoveWarning">
Cannot modify yourself
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/cypress/e2e/contact/contact_users_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ describe('Contact Project Users Specs', () => {
cy.get('[data-cy="emailUsers_body"] [data-cy="markdownEditorInput"]').type('{selectall}{backspace}')
cy.get('[data-cy="emailUsers_body"]').type('test');
cy.get('[data-cy="previewUsersEmail"]').should('be.enabled');
cy.get('[data-cy="descriptionError"]').should('be.empty');
cy.get('[data-cy="descriptionError"]').should('be.not.visible');
});

it('email body and subject validation for community-protected project still uses non-community validator', () => {
Expand Down
24 changes: 12 additions & 12 deletions e2e-tests/cypress/e2e/quiz/survey_question_def_management_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Survey Question CRUD Tests', () => {
cy.get('[data-cy="btn_Questions"]').should('be.enabled')
cy.get('[data-cy="btn_Questions"]').click()
cy.get('[data-cy="btn_Questions"]').click({force: true})
cy.get('[data-cy="questionText"]').type('What is 2 + 2?')
cy.typeQuestion('What is 2 + 2?')
cy.get('[data-cy="answerTypeSelector"]').click()
cy.get('[data-cy="selectionItem_SingleChoice"]').click()
cy.get('[data-cy="answer-0"] [data-cy="answerText"]').type('1')
Expand All @@ -68,7 +68,7 @@ describe('Survey Question CRUD Tests', () => {

// single choice question
cy.get('[data-cy="newQuestionOnBottomBtn"]').click()
cy.get('[data-cy="questionText"]').type('What is 1 + 2?')
cy.typeQuestion('What is 1 + 2?')
cy.get('[data-cy="answer-0"] [data-cy="answerText"]').type('3')
cy.get('[data-cy="answer-1"] [data-cy="answerText"]').type('1')
cy.get('[data-cy="answer-1"] [data-cy="addNewAnswer"]').click()
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('Survey Question CRUD Tests', () => {

// q3 - text input question
cy.get('[data-cy="newQuestionOnBottomBtn"]').click()
cy.get('[data-cy="questionText"]').type('Enter Text Here Please')
cy.typeQuestion('Enter Text Here Please')
cy.get('[data-cy="answerTypeSelector"]').click()
cy.get('[data-cy="answer-0"] [data-cy="answerText"]')
cy.get('[data-cy="answer-1"] [data-cy="answerText"]')
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('Survey Question CRUD Tests', () => {

// rating choice question
cy.get('[data-cy="btn_Questions"]').click()
cy.get('[data-cy="questionText"]').type('How is this quiz?')
cy.typeQuestion('How is this quiz?')
cy.get('[data-cy="answerTypeSelector"]').click()
cy.get('[data-cy="selectionItem_Rating"]').click()

Expand Down Expand Up @@ -178,7 +178,7 @@ describe('Survey Question CRUD Tests', () => {
cy.get('[data-cy="btn_Questions"]').click()
cy.get('[data-cy="descriptionError"]').should('not.be.visible')

cy.get('[data-cy="questionText"]').type('a')
cy.typeQuestion('a')

cy.get('[data-cy="answer-0"] [data-cy="selectCorrectAnswer"]').should('not.exist')
cy.get('[data-cy="answer-0"] [data-cy="answerText"]').type('1')
Expand All @@ -196,7 +196,7 @@ describe('Survey Question CRUD Tests', () => {
cy.get('[data-cy="btn_Questions"]').click()
cy.get('[data-cy="descriptionError"]').should('not.be.visible')

cy.get('[data-cy="questionText"]').type('What is 2 + 2?')
cy.typeQuestion('What is 2 + 2?')

cy.get(`[data-cy="answer-0"] [data-cy="addNewAnswer"]`).click()
cy.get(`[data-cy="answer-2"] [data-cy="addNewAnswer"]`).click()
Expand All @@ -219,7 +219,7 @@ describe('Survey Question CRUD Tests', () => {
cy.get('[data-cy="btn_Questions"]').click()
cy.get('[data-cy="descriptionError"]').should('not.be.visible')

cy.get('[data-cy="questionText"]').type('What is 2 + 2?')
cy.typeQuestion('What is 2 + 2?')

cy.get('[data-cy="answer-0"] [data-cy="answerText"]').type('1')
cy.get('[data-cy="answer-1"] [data-cy="answerText"]').type('2')
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('Survey Question CRUD Tests', () => {
// multiple choice question
cy.get('[data-cy="btn_Questions"]').click()

cy.get('[data-cy="questionText"]').type('How is this quiz?')
cy.typeQuestion('How is this quiz?')
cy.get('[data-cy="answerTypeSelector"]').click()
cy.get('[data-cy="selectionItem_Rating"]').click()

Expand All @@ -310,7 +310,7 @@ describe('Survey Question CRUD Tests', () => {
cy.get('[data-cy="questionDisplayCard-1"] [data-pc-name="rating"] [data-pc-section="option"]').should('have.length', 5)

cy.get('[data-cy="editQuestionButton_1"]').click();
cy.get('[data-cy="questionText"]').type(' With more description')
cy.typeQuestion(' With more description')
cy.get('[data-cy="ratingScaleSelect"]').click()
cy.get('[data-pc-section="overlay"] [data-pc-section="option"]').contains('8').click();
// cy.get('[data-cy="saveDialogBtn"]').click()
Expand Down Expand Up @@ -542,7 +542,7 @@ describe('Survey Question CRUD Tests', () => {
const q2Card = '[data-cy="questionDisplayCard-2"] [data-cy="sortControlHandle"]';

cy.get('[data-cy="newQuestionOnBottomBtn"]').click()
cy.get('[data-cy="questionText"]').type('question # 1')
cy.typeQuestion('question # 1')
cy.get('[data-cy="answer-0"] [data-cy="answerText"]').type('3')
cy.get('[data-cy="answer-1"] [data-cy="answerText"]').type('4')
cy.get('[data-cy="saveDialogBtn"]').click()
Expand All @@ -552,7 +552,7 @@ describe('Survey Question CRUD Tests', () => {

cy.get('[data-cy="newQuestionOnBottomBtn"]').click()
cy.get('[data-cy="answerTypeSelector"]').should('exist')
cy.get('[data-cy="questionText"]').type('question # 2')
cy.typeQuestion('question # 2')
cy.get('[data-cy="answerTypeSelector"]').click()
cy.get('[data-cy="selectionItem_TextInput"]').click()
cy.get('[data-cy="saveDialogBtn"]').click()
Expand Down Expand Up @@ -665,7 +665,7 @@ describe('Survey Question CRUD Tests', () => {
// multiple choice question
cy.get('[data-cy="btn_Questions"]').click()

cy.get('[data-cy="questionText"]').type('How is this quiz?')
cy.typeQuestion('How is this quiz?')
cy.get('[data-cy="answerTypeSelector"]').click()
cy.get('[data-cy="selectionItem_Rating"]').click()

Expand Down
15 changes: 4 additions & 11 deletions e2e-tests/cypress/e2e/rootUser_pinUnpin_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,19 +404,12 @@ describe('Root Pin and Unpin Tests', () => {
const tableSelector = '[data-cy=roleManagerTable]';
const rowSelector = `${tableSelector} tbody tr`;
cy.log('removing user');
if (!Cypress.env('oauthMode')) {
cy.get(`${tableSelector} [data-cy="removeUserBtn"]`)
.eq(0)
.click();
} else {
// in oauth mode the default user name is different which affects how the users are sorted
cy.get(`${tableSelector} [data-cy="removeUserBtn"]`)
.eq(1)
.click();
}
cy.get(`${tableSelector} [data-cy="removeUserBtn"]`)
.eq(0)
.click();

cy.get('[data-cy="removalSafetyCheckMsg"]').contains('This will remove')
cy.get('[data-cy="currentValidationText"]').fill('Delete Me')
cy.get('[data-cy="currentValidationText"]').type('Delete Me', {delay: 0})
cy.get('[data-cy="saveDialogBtn"]').click()
cy.wait('@loadProjectAdmins');
cy.get(rowSelector)
Expand Down
10 changes: 10 additions & 0 deletions e2e-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -1594,4 +1594,14 @@ Cypress.Commands.add('approveAllRequests', () => {

Cypress.Commands.add('assignUserAsAdmin', (projId, userId) => {
cy.request('PUT', `/admin/projects/${projId}/users/${userId}/roles/ROLE_PROJECT_ADMIN`)
})

Cypress.Commands.add('typeInMarkdownEditor', (selector, text) => {
const fullSelector = `${selector} .toastui-editor-ww-container`
cy.get(fullSelector).should('be.visible')
cy.get(fullSelector).type(text, {delay:0 })
})

Cypress.Commands.add('typeQuestion', (text) => {
cy.typeInMarkdownEditor('[data-cy="questionText"]', text)
})

0 comments on commit 02a77ca

Please sign in to comment.