Skip to content

Commit

Permalink
[#12647] Fix accessibility tests (#12648)
Browse files Browse the repository at this point in the history
* change to class...

* fix axe tests

* e2e test fix

* add role

* test e2e fix

* e2e

* add assertion debug

* test

* cleanup

* update snapshots and lint

* linkt
  • Loading branch information
weiquu authored Nov 29, 2023
1 parent a9292bb commit 87472fb
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 59 deletions.
29 changes: 12 additions & 17 deletions src/e2e/java/teammates/e2e/pageobjects/FeedbackResultsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private void verifyAnonymousResponseView(FeedbackQuestionAttributes question,
List<FeedbackResponseAttributes> expectedResponses,
boolean isGiverVisible) {
List<WebElement> anonymousViews = getAllResponseViews(question.getQuestionNumber()).stream()
.filter(v -> isAnonymous(v.findElement(By.id("response-recipient")).getText()))
.filter(v -> isAnonymous(v.findElement(By.className("response-recipient")).getText()))
.collect(Collectors.toList());
if (anonymousViews.isEmpty()) {
fail("No anonymous views found");
Expand Down Expand Up @@ -309,7 +309,7 @@ private boolean isAnonymous(String identifier) {

private boolean isAnyAnonymousResponseEqual(FeedbackQuestionAttributes question, WebElement responseView,
FeedbackResponseAttributes response) {
List<WebElement> giverNames = responseView.findElements(By.id("response-giver"));
List<WebElement> giverNames = responseView.findElements(By.className("response-giver"));
List<WebElement> responseFields = getAllResponseFields(responseView);
for (int i = 0; i < giverNames.size(); i++) {
if (isAnonymous(giverNames.get(i).getText()) && isResponseEqual(question, responseFields.get(i), response)) {
Expand Down Expand Up @@ -466,21 +466,15 @@ private String getAdditionalInfo(int questionNum) {
}

private WebElement getGivenResponseField(int questionNum, String receiver) {
int recipientIndex = getGivenRecipientIndex(questionNum, receiver);
return getQuestionResponsesSection(questionNum)
.findElements(By.cssSelector("#given-responses tm-single-response"))
.get(recipientIndex);
}

private int getGivenRecipientIndex(int questionNum, String recipient) {
List<WebElement> recipients = getQuestionResponsesSection(questionNum)
.findElements(By.cssSelector("#given-responses #response-recipient"));
WebElement questionResponsesSection = getQuestionResponsesSection(questionNum);
WebElement givenResponses = questionResponsesSection.findElement(By.className("given-responses"));
List<WebElement> recipients = givenResponses.findElements(By.className("response-recipient"));
for (int i = 0; i < recipients.size(); i++) {
if (recipients.get(i).getText().split("To: ")[1].equals(recipient)) {
return i;
if (recipients.get(i).getText().split("To: ")[1].equals(receiver)) {
return givenResponses.findElements(By.tagName("tm-single-response")).get(i);
}
}
throw new AssertionError("Recipient not found: " + recipient);
throw new AssertionError("Recipient not found: " + receiver);
}

private String getAdditionalInfoString(FeedbackQuestionAttributes question) {
Expand Down Expand Up @@ -584,7 +578,7 @@ private boolean isCommentByResponseGiver(WebElement commentField) {
}

private String getCommentGiver(WebElement commentField) {
String commentGiverDescription = commentField.findElement(By.id("comment-giver-name")).getText();
String commentGiverDescription = commentField.findElement(By.className("comment-giver-name")).getText();
return commentGiverDescription.split(" commented")[0];
}

Expand All @@ -608,7 +602,7 @@ private WebElement getCommentField(int questionNum, String commentString) {
}

private int getGiverIndex(WebElement response, String giver) {
List<WebElement> givers = response.findElements(By.id("response-giver"));
List<WebElement> givers = response.findElements(By.className("response-giver"));
for (int i = 0; i < givers.size(); i++) {
if (givers.get(i).getText().contains(giver)) {
return i;
Expand All @@ -618,7 +612,8 @@ private int getGiverIndex(WebElement response, String giver) {
}

private int getRecipientIndex(int questionNum, String recipient) {
List<WebElement> recipients = getQuestionResponsesSection(questionNum).findElements(By.id("response-recipient"));
List<WebElement> recipients =
getQuestionResponsesSection(questionNum).findElements(By.className("response-recipient"));
for (int i = 0; i < recipients.size(); i++) {
if (recipients.get(i).getText().split("To: ")[1].equals(recipient)) {
return i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ private WebElement getTeamStats(WebElement parentPanel, int qnNum) {
}

private String getCommentGiver(WebElement commentField) {
String commentGiverDescription = commentField.findElement(By.id("comment-giver-name")).getText();
String commentGiverDescription = commentField.findElement(By.className("comment-giver-name")).getText();
return commentGiverDescription.split(" commented")[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Comment by response giver.
</span>
<span class="text-secondary" *ngIf="!isFeedbackParticipantComment">
<span id="comment-giver-name">{{ model.commentGiverName ? model.commentGiverName : model.originalComment.commentGiver }} commented at </span>
<span class="comment-giver-name">{{ model.commentGiverName ? model.commentGiverName : model.originalComment.commentGiver }} commented at </span>
<span class="ngb-tooltip-class" style="margin-right: .25rem;" [ngbTooltip]="model.originalComment.createdAt | formatDateDetail: model.timezone!">
{{ model.originalComment.createdAt | formatDateBrief: model.timezone! }}</span>
<ng-container *ngIf="model.originalComment.lastEditedAt && model.originalComment.lastEditedAt !== model.originalComment.createdAt">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
Responses are not visible to you.
</div>
<div
class="mt-4"
id="given-responses"
class="given-responses mt-4"
>
<strong>
Your own responses (to others):
Expand All @@ -74,7 +73,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -92,7 +91,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -164,8 +163,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
Responses are not visible to you.
</div>
<div
class="mt-4"
id="given-responses"
class="given-responses mt-4"
>
<strong>
Your own responses (to others):
Expand All @@ -179,7 +177,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -197,7 +195,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -226,7 +224,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -244,7 +242,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -316,8 +314,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
Responses are not visible to you.
</div>
<div
class="mt-4"
id="given-responses"
class="given-responses mt-4"
>
<strong>
Your own responses (to others):
Expand All @@ -331,7 +328,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -349,7 +346,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -392,7 +389,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="text-secondary"
>
<span
id="comment-giver-name"
class="comment-giver-name"
>
comment-giver-1 commented at
</span>
Expand Down Expand Up @@ -496,8 +493,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
Responses are not visible to you.
</div>
<div
class="mt-4"
id="given-responses"
class="given-responses mt-4"
>
<strong>
Your own responses (to others):
Expand All @@ -511,7 +507,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -529,7 +525,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -558,7 +554,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -576,7 +572,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -605,7 +601,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -623,7 +619,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -690,8 +686,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
Responses are not visible to you.
</div>
<div
class="mt-4"
id="given-responses"
class="given-responses mt-4"
>
<strong>
Your own responses (to others):
Expand All @@ -705,7 +700,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -723,7 +718,7 @@ exports[`QuestionResponsePanelComponent should snap with feedback session with q
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -867,8 +862,7 @@ exports[`QuestionResponsePanelComponent should snap with questions and responses
Responses are not visible to you.
</div>
<div
class="mt-4"
id="given-responses"
class="given-responses mt-4"
>
<strong>
Your own responses (to others):
Expand All @@ -882,7 +876,7 @@ exports[`QuestionResponsePanelComponent should snap with questions and responses
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -900,7 +894,7 @@ exports[`QuestionResponsePanelComponent should snap with questions and responses
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down Expand Up @@ -943,7 +937,7 @@ exports[`QuestionResponsePanelComponent should snap with questions and responses
class="text-secondary"
>
<span
id="comment-giver-name"
class="comment-giver-name"
>
comment-giver-1 commented at
</span>
Expand Down Expand Up @@ -1032,8 +1026,7 @@ exports[`QuestionResponsePanelComponent should snap with questions and responses
</div>
</div>
<div
class="mt-4"
id="given-responses"
class="given-responses mt-4"
>
<strong>
Your own responses (to others):
Expand All @@ -1047,7 +1040,7 @@ exports[`QuestionResponsePanelComponent should snap with questions and responses
class="card-header bg-info"
>
<span
id="response-recipient"
class="response-recipient"
>
<b>
To:
Expand All @@ -1065,7 +1058,7 @@ exports[`QuestionResponsePanelComponent should snap with questions and responses
<tbody>
<tr>
<td
id="response-giver"
class="response-giver"
>
<strong>
From:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<strong>Other responses (to you): </strong>Responses are not visible to you.
</div>
</ng-template>
<div id="given-responses" class="mt-4" *ngIf="question.responsesFromSelf.length">
<div class="given-responses mt-4" *ngIf="question.responsesFromSelf.length">
<strong>Your own responses (to others):</strong>
<div *ngFor="let responseFromSelf of question.responsesFromSelf">
<tm-student-view-responses [responses]="[responseFromSelf]" [isSelfResponses]="true" [feedbackQuestion]="question.feedbackQuestion" [timezone]="session.timeZone" [statistics]="question.questionStatistics"></tm-student-view-responses>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="card border-{{ isSelfResponses ? 'info' : 'primary' }} mt-4">
<div class="card-header bg-{{ isSelfResponses ? 'info' : 'primary' }}" [ngClass]="{ 'text-white': !isSelfResponses }">
<span id="response-recipient"><b>To:</b> {{ recipient }}</span>
<span class="response-recipient"><b>To:</b> {{ recipient }}</span>
</div>
<div class="card-body table-responsive" style="padding: 0;">
<table class="table">
<tbody>
<ng-container *ngFor="let response of responses">
<tr>
<td id="response-giver">
<td class="response-giver">
<strong>From:</strong> {{ response.giver }}
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<tr *ngFor="let answer of answers; let i = index">
<td>{{ questionDetails.rubricSubQuestions[i] }}</td>
<td class="text-center" *ngFor="let choice of questionDetails.rubricChoices">
<i *ngIf="answer.answer === choice" aria-label="selected" class="fas fa-check"></i>
<span [attr.aria-label]="answer.answer === choice ? 'selected' : 'unselected'" role="img">
<i *ngIf="answer.answer === choice" class="fas fa-check"></i>
</span>
</td>
</tr>
</tbody>
Expand Down

0 comments on commit 87472fb

Please sign in to comment.