Merged in bugfix/VBV-454-fix-cypress-pipelines (pull request #144)

Fix Cypress pipelines

* Update Cypress

* Attempt to change reload logic

* Fix it checkbox cy data

* Fix notification cypress test

* Rework notification settings saving logic
This commit is contained in:
Elia Bieri 2023-06-21 11:28:40 +00:00
parent b4bf838ad7
commit 2db7059461
6 changed files with 27 additions and 23 deletions

View File

@ -33,6 +33,7 @@ const input = (e: Event) => {
'cursor-not-allowed': disabled, 'cursor-not-allowed': disabled,
}" }"
class="inline-flex cursor-pointer" class="inline-flex cursor-pointer"
:data-cy="`it-checkbox-clicktarget-${checkboxItem.value}`"
> >
<label <label
class="cy-checkbox cy-checkbox-checked block flex h-8 items-center bg-contain bg-no-repeat pl-8 disabled:opacity-50" class="cy-checkbox cy-checkbox-checked block flex h-8 items-center bg-contain bg-no-repeat pl-8 disabled:opacity-50"
@ -49,9 +50,9 @@ const input = (e: Event) => {
:checked="checkboxItem.checked" :checked="checkboxItem.checked"
:value="checkboxItem.value" :value="checkboxItem.value"
:disabled="disabled" :disabled="disabled"
:data-cy="`it-checkbox-${checkboxItem.value}`"
class="sr-only" class="sr-only"
type="checkbox" type="checkbox"
:data-cy="`it-checkbox-${checkboxItem.value}`"
@keydown="keydown" @keydown="keydown"
@input="input" @input="input"
/> />

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import ItCheckboxGroup from "@/components/ui/ItCheckboxGroup.vue"; import ItCheckboxGroup from "@/components/ui/ItCheckboxGroup.vue";
import { itGet, itPost } from "@/fetchHelpers"; import { itGet, itPost } from "@/fetchHelpers";
import { onMounted, ref, watch } from "vue"; import { onMounted, ref } from "vue";
// TODO: make translation // TODO: make translation
const items = ref([ const items = ref([
@ -26,17 +26,18 @@ const items = ref([
}, },
]); ]);
watch(items, async (items) => { const updateItems = async (_items: []) => {
items.value = _items;
try { try {
await itPost( await itPost(
"/api/notify/email_notification_settings/", "/api/notify/email_notification_settings/",
items.filter((item) => item.checked).map((item) => item.value) items.value.filter((item) => item.checked).map((item) => item.value)
); );
console.debug("Updated email notification settings"); console.debug("Updated email notification settings");
} catch (e) { } catch (e) {
console.error(`Could not update email notification settings: ${e}`); console.error(`Could not update email notification settings: ${e}`);
} }
}); };
onMounted(async () => { onMounted(async () => {
const response = await itGet("/api/notify/email_notification_settings/"); const response = await itGet("/api/notify/email_notification_settings/");
@ -58,7 +59,7 @@ onMounted(async () => {
<ItCheckboxGroup <ItCheckboxGroup
:items="items" :items="items"
:label="$t('settings.emailNotifications')" :label="$t('settings.emailNotifications')"
@update:items="items = $event" @update:items="updateItems($event)"
></ItCheckboxGroup> ></ItCheckboxGroup>
</div> </div>
</main> </main>

View File

@ -41,7 +41,7 @@ describe("student test", () => {
"Teilaufgabe 1: Beispiel einer Versicherungspolice finden" "Teilaufgabe 1: Beispiel einer Versicherungspolice finden"
); );
// Click confirmation // Click confirmation
cy.get('[data-cy="it-checkbox-confirmation-1"]').click({ force: true }); cy.get('[data-cy="it-checkbox-clicktarget-confirmation-1"]').click();
cy.reload(); cy.reload();
cy.get('[data-cy="it-checkbox-confirmation-1"]').should("be.checked"); cy.get('[data-cy="it-checkbox-confirmation-1"]').should("be.checked");
}); });

View File

@ -93,26 +93,28 @@ describe("email notification settings", () => {
it("can update email notification settings", () => { it("can update email notification settings", () => {
login("admin", "test"); login("admin", "test");
cy.visit("/settings"); cy.visit("/settings");
cy.wait(1000); cy.wait(2000);
// Checking prerequisites // Checking prerequisites
cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked"); cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked");
cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked"); cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked");
cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked"); cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked");
cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').check({ force: true }); cy.get('[data-cy="it-checkbox-clicktarget-INFORMATION"]').click();
cy.get('[data-cy="it-checkbox-INFORMATION"]').check({ force: true }); cy.get('[data-cy="it-checkbox-INFORMATION"]').should("be.checked");
cy.wait(400);
cy.reload(); cy.visit("/settings");
cy.wait(1000); cy.wait(1000);
cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("be.checked"); cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked");
cy.get('[data-cy="it-checkbox-INFORMATION"]').should("be.checked"); cy.get('[data-cy="it-checkbox-INFORMATION"]').should("be.checked");
cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked"); cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked");
cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').uncheck({ force: true }); cy.get('[data-cy="it-checkbox-clicktarget-INFORMATION"]').click();
cy.get('[data-cy="it-checkbox-INFORMATION"]').uncheck({ force: true }); cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked");
cy.wait(400);
cy.reload(); cy.visit("/settings");
cy.wait(1000); cy.wait(1000);
cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked"); cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked");
cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked"); cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked");

14
package-lock.json generated
View File

@ -11,7 +11,7 @@
"pa11y": "^6.2.3" "pa11y": "^6.2.3"
}, },
"devDependencies": { "devDependencies": {
"cypress": "^12.12.0", "cypress": "^12.15.0",
"cypress-cloud": "^1.7.4" "cypress-cloud": "^1.7.4"
} }
}, },
@ -920,9 +920,9 @@
} }
}, },
"node_modules/cypress": { "node_modules/cypress": {
"version": "12.12.0", "version": "12.15.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-12.12.0.tgz", "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.15.0.tgz",
"integrity": "sha512-UU5wFQ7SMVCR/hyKok/KmzG6fpZgBHHfrXcHzDmPHWrT+UUetxFzQgt7cxCszlwfozckzwkd22dxMwl/vNkWRw==", "integrity": "sha512-FqGbxsH+QgjStuTO9onXMIeF44eOrgVwPvlcvuzLIaePQMkl72YgBvpuHlBGRcrw3Q4SvqKfajN8iV5XWShAiQ==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
@ -4089,9 +4089,9 @@
} }
}, },
"cypress": { "cypress": {
"version": "12.12.0", "version": "12.15.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-12.12.0.tgz", "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.15.0.tgz",
"integrity": "sha512-UU5wFQ7SMVCR/hyKok/KmzG6fpZgBHHfrXcHzDmPHWrT+UUetxFzQgt7cxCszlwfozckzwkd22dxMwl/vNkWRw==", "integrity": "sha512-FqGbxsH+QgjStuTO9onXMIeF44eOrgVwPvlcvuzLIaePQMkl72YgBvpuHlBGRcrw3Q4SvqKfajN8iV5XWShAiQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@cypress/request": "^2.88.10", "@cypress/request": "^2.88.10",

View File

@ -10,7 +10,7 @@
"vue-i18n-extract": "npm run vue-i18n-extract --prefix client" "vue-i18n-extract": "npm run vue-i18n-extract --prefix client"
}, },
"devDependencies": { "devDependencies": {
"cypress": "^12.12.0", "cypress": "^12.15.0",
"cypress-cloud": "^1.7.4" "cypress-cloud": "^1.7.4"
}, },
"dependencies": { "dependencies": {