Skip to content

Commit 039cc77

Browse files
authored
fix: Resolve failing client and backend testing (#2212)
* Fixes unique search terms for seeded data in `UserQueryTest.php` that are no longer considered valid * Improves error message in `UserQueryTest.php` when no results are returned * Updates Cypress config file * Updates axe-core * Adds missing `title` and `aria-label` attributes on elements * Adds missing `read_at` property in `SubmissionsPage.vitest.spec.js` * Increases duration of notifications for improved accessibility to those with cognitive disabilities * Adds element exceptions to Cypress tests with comment explanations
1 parent 849e94f commit 039cc77

24 files changed

+232
-77
lines changed

backend/tests/Api/UserQueryTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testThatUserDetailsCanBeQueried(array $profile_metadata): void
5151
{
5252
$user = User::factory()->create([
5353
'name' => 'Regular User',
54-
'email' => 'regularuser@gmail.com',
54+
'email' => 'regularuser@meshresearch.net',
5555
'username' => 'regularuser',
5656
'profile_metadata' => $profile_metadata,
5757
]);
@@ -87,7 +87,7 @@ public function testThatUserDetailsCanBeQueried(array $profile_metadata): void
8787
'data' => [
8888
'user' => [
8989
'name' => 'Regular User',
90-
'email' => 'regularuser@gmail.com',
90+
'email' => 'regularuser@meshresearch.net',
9191
'username' => 'regularuser',
9292
'profile_metadata' => $profile_metadata,
9393
],
@@ -102,18 +102,18 @@ public static function searchUserTermsProvider(): array
102102
{
103103
return [
104104
[
105-
'searchTerm' => 'abcdef',
106-
'shouldFind' => 'ghijkl@gmail.com',
105+
'searchTerm' => 'Rotated Building Assembly',
106+
'shouldFind' => 'freshoxygenlake@meshresearch.net',
107107
'count' => 1,
108108
],
109109
[
110-
'searchTerm' => 'ghijkl@gmail.com',
111-
'shouldFind' => 'ghijkl@gmail.com',
110+
'searchTerm' => 'freshoxygenlake@meshresearch.net',
111+
'shouldFind' => 'freshoxygenlake@meshresearch.net',
112112
'count' => 1,
113113
],
114114
[
115-
'searchTerm' => 'mnopqr',
116-
'shouldFind' => 'ghijkl@gmail.com',
115+
'searchTerm' => 'ScrumptiousPlatePile',
116+
'shouldFind' => 'freshoxygenlake@meshresearch.net',
117117
'count' => 1,
118118
],
119119
[
@@ -160,9 +160,9 @@ public function testSearchingForUsers(mixed $searchTerm = null, ?string $shouldF
160160
{
161161
User::factory()->createManyQuietly(20);
162162
User::factory()->create([
163-
'name' => 'abcdef',
164-
'email' => 'ghijkl@gmail.com',
165-
'username' => 'mnopqr',
163+
'name' => 'Rotated Building Assembly',
164+
'email' => 'freshoxygenlake@meshresearch.net',
165+
'username' => 'ScrumptiousPlatePile',
166166
]);
167167

168168
$response = $this->graphQL(
@@ -182,9 +182,10 @@ public function testSearchingForUsers(mixed $searchTerm = null, ?string $shouldF
182182
$collection = collect($data);
183183

184184
if ($shouldFind !== null) {
185+
$results = $collection->implode('email', ', ') != '' ? $collection->implode('email', ', ') : 'nothing';
185186
$this->assertTrue(
186187
$collection->contains('email', $shouldFind),
187-
"Search term '{$searchTerm}' should return user with email '{$shouldFind}', but returned: " . $collection->implode('email', ', ')
188+
"Search term '{$searchTerm}' should return user with email '{$shouldFind}', but returned " . $results
188189
);
189190
}
190191
$this->assertCount(

client/cypress.config.cjs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* eslint-env node */
2+
const { defineConfig } = require("cypress")
3+
4+
module.exports = defineConfig({
5+
fixturesFolder: "test/cypress/fixtures",
6+
screenshotsFolder: "test/cypress/screenshots",
7+
videosFolder: "test/cypress/videos",
8+
video: true,
9+
e2e: {
10+
baseUrl: "https://pilcrow.lndo.site",
11+
specPattern: "test/cypress/integration/**/*.cy.{js,jsx,ts,tsx}",
12+
supportFile: "test/cypress/support/index.js",
13+
setupNodeEvents(on, config) {
14+
const axiosImport = require("axios")
15+
const https = require("https")
16+
const axios = axiosImport.create({
17+
httpsAgent: new https.Agent({
18+
rejectUnauthorized: false
19+
})
20+
})
21+
on("task", {
22+
"before:browser:launch"(browser = {}, launchOptions) {
23+
const REDUCE = 1
24+
if (browser.family === "firefox") {
25+
launchOptions.preferences["ui.prefersReducedMotion"] = REDUCE
26+
}
27+
if (browser.family === "chromium" && browser.name !== "electron") {
28+
launchOptions.args.push("--force-prefers-reduced-motion")
29+
}
30+
return launchOptions
31+
},
32+
log(message) {
33+
console.log(message)
34+
return null
35+
},
36+
table(message) {
37+
console.table(message)
38+
return null
39+
},
40+
resetDb() {
41+
return new Promise((resolve, reject) => {
42+
axios({
43+
url: `${config.baseUrl}/graphql`,
44+
method: "POST",
45+
data: {
46+
query:
47+
'mutation { artisanCommand(command: "migrate:fresh" parameters: [{key: "--seed" value: "true"}])}'
48+
}
49+
}).then((response) => {
50+
const {
51+
data: { data, errors }
52+
} = response
53+
if (!data) {
54+
console.log(response)
55+
}
56+
if (errors) {
57+
console.log(errors)
58+
reject()
59+
}
60+
resolve(data.artisanCommand)
61+
})
62+
})
63+
}
64+
})
65+
}
66+
}
67+
})

client/cypress.config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@vue/eslint-config-prettier": "^10.2.0",
6060
"@vue/test-utils": "^2.0.0",
6161
"autoprefixer": "^10.4.2",
62-
"axe-core": "^4.6.3",
62+
"axe-core": "4.11.0",
6363
"axios": "^1.3.4",
6464
"cypress": "^13.0.0",
6565
"cypress-axe": "^1.4.0",

client/src/components/AssignedSubmissionUsers.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ const acceptMore = computed(() => {
157157
})
158158
159159
const editor = useEditor({
160+
editorProps: {
161+
attributes: {
162+
title: t("submissions.invite_user.message.placeholder")
163+
}
164+
},
160165
content: "",
161166
extensions: [
162167
StarterKit,

client/src/components/PublicationStyleCriteria.vitest.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ describe("PublicationStyleCriteria", () => {
141141
})
142142
const items = () => wrapper.findAllComponents('[data-cy="listItem"]')
143143
await items().at(0).findComponent('[data-cy="editBtn"]').trigger("click")
144-
await items().at(0).vm.$emit("delete", { id: "1" })
144+
const form = () => wrapper.findAllComponents('[data-cy="criteriaEditForm"]')
145+
await form().at(0).vm.$emit("delete", { id: "1" })
145146

146147
expect(deleteCriteriaHandler).toHaveBeenCalledTimes(1)
147148
expect(deleteCriteriaHandler).toHaveBeenCalledWith({

client/src/components/PublicationStyleCriteria.vue

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,30 @@
22
<q-card flat>
33
<q-card-section>
44
<q-list separator>
5-
<component
6-
:is="editId === criteria.id ? StyleCriteriaForm : StyleCriteriaItem"
5+
<q-item
76
v-for="criteria in publication.style_criterias"
87
:key="criteria.id"
98
data-cy="listItem"
10-
class="criteria-card"
11-
:criteria="criteria"
12-
:edit-id="editId"
13-
@edit="editItem(criteria.id)"
14-
@cancel="cancelEdit"
15-
@save="saveEdit"
16-
@delete="onDelete"
17-
/>
18-
<style-criteria-form
19-
v-if="editId == ''"
20-
ref="addForm"
21-
@cancel="cancelEdit"
22-
@save="saveEdit"
23-
/>
9+
>
10+
<component
11+
:is="editId === criteria.id ? StyleCriteriaForm : StyleCriteriaItem"
12+
class="criteria-card"
13+
:criteria="criteria"
14+
:edit-id="editId"
15+
data-cy="criteriaEditForm"
16+
@edit="editItem(criteria.id)"
17+
@cancel="cancelEdit"
18+
@save="saveEdit"
19+
@delete="onDelete"
20+
/>
21+
</q-item>
22+
<q-item v-if="editId == ''">
23+
<style-criteria-form
24+
ref="addForm"
25+
@cancel="cancelEdit"
26+
@save="saveEdit"
27+
/>
28+
</q-item>
2429
</q-list>
2530
</q-card-section>
2631
<q-card-actions v-if="editId === null" align="right">

client/src/components/dialogs/BypassStyleCriteriaDialog.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<template>
2-
<q-dialog ref="dialogRef" @hide="onDialogHide">
2+
<q-dialog
3+
ref="dialogRef"
4+
:aria-label="$t(`dialog.bypassStyleCriteria.aria_label`)"
5+
@hide="onDialogHide"
6+
>
37
<q-card>
48
<q-card-section class="row no-wrap">
59
<div class="q-pa-sm q-pr-md column">

client/src/components/dialogs/ConfirmCommentDeletion.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<template>
2-
<q-dialog ref="dialogRef" @hide="onDialogHide">
2+
<q-dialog
3+
ref="dialogRef"
4+
:aria-label="$t(`dialog.deleteComment.aria_label`)"
5+
@hide="onDialogHide"
6+
>
37
<q-card>
48
<q-card-section class="row items-center">
59
<div class="q-pa-sm q-pr-md column">

client/src/components/dialogs/ConfirmStatusChangeDialog.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<template>
2-
<q-dialog ref="dialogRef" @hide="onDialogHide">
2+
<q-dialog
3+
ref="dialogRef"
4+
:aria-label="$t(`dialog.confirmStatusChange.aria_label`)"
5+
@hide="onDialogHide"
6+
>
37
<q-card>
48
<q-card-section class="row no-wrap">
59
<div class="q-pa-sm q-pr-md column">

0 commit comments

Comments
 (0)