Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip/Test All Open Administrations #434

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const timeout = Cypress.env('timeout');
const today = new Date().getDate();
const variant = 'morphology-default';

function typeAdministrationName() {
cy.get('[data-cy="input-administration-name"]', { timeout: Cypress.env('timeout') }).type(
Expand All @@ -19,11 +21,40 @@ function selectDate() {
// cy.get('[data-cy="button-refresh-assessments"]', { timeout: Cypress.env('timeout') }).click();
// }

function dragVariantCard(variant, x, y) {
cy.get('div')
.contains(variant)
.trigger('mousedown', { which: 1 })
.trigger('mousemove', { clientX: 1200, clientY: 0 })
.trigger('mouseup', { force: true });
// // get draggable element, then
// cy.get("div").contains(variant).then(($el) => {
// cy.get("[data-cy='panel-droppable-zone']").then(($target) => {
//
// // x and y positions of draggable object
// const dragX = $el[0].getBoundingClientRect().left
// const dragY = $el[0].getBoundingClientRect().top
//
// // x and y positions of droppable object
// const dropX = $target[0].getBoundingClientRect().left
// const dropY = $target[0].getBoundingClientRect().top
//
// cy.get("div").contains(variant).trigger("mousedown", { which: 0})
// cy.get("[data-cy='panel-droppable-zone']").trigger("mouseup")
// })
// })
// // get the droppable element, then
// // get the x and y positions of each element
// // wrap the draggable element, trigger mousedown
// // mousemove on the draggable element
// // mousemove to the droppable element
// // mouseup on the droppable element
}

function selectAndAssignAdministration(variant) {
cy.get('span')
.contains(variant, { timeout: 2 * Cypress.env('timeout') })
.dblclick();
cy.get('[data-cy="button-create-administration"]', { timeout: 2 * Cypress.env('timeout') }).click();
cy.get('[data-cy="input-variant-name"]', { timeout: Cypress.env('timeout') }).type(variant);
cy.wait(0.3 * timeout);
dragVariantCard(variant);
}

function checkAdministrationCreated() {
Expand All @@ -50,9 +81,8 @@ describe('The admin user can create an administration and assign it to a distric
typeAdministrationName();
selectDate();
cy.selectTestOrgs();
// refreshAssessments();
selectAndAssignAdministration('morphology-default');
checkAdministrationCreated();
selectAndAssignAdministration(variant);
// checkAdministrationCreated();
},
);
});
14 changes: 10 additions & 4 deletions src/components/TaskPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="flex flex-row mb-2">
<div class="flex flex-column flex-grow-1 p-input-icon-left">
<i class="pi pi-search" />
<PvInputText v-model="searchTerm" placeholder="Variant name, ID, or Task ID" />
<PvInputText v-model="searchTerm" placeholder="Variant name, ID, or Task ID" data-cy="input-variant-name" />
</div>
<PvButton v-if="searchTerm" style="margin-right: 0" @click="clearSearch">
<i class="pi pi-times" />
Expand Down Expand Up @@ -42,7 +42,7 @@
:data-task-id="element.task.id"
style="cursor: grab"
>
<VariantCard :variant="element" @select="selectCard" />
<VariantCard :variant="element" data-cy="card-variant" @select="selectCard" />
</div>
</transition-group>
</VueDraggableNext>
Expand Down Expand Up @@ -79,7 +79,12 @@
:data-task-id="element.task.id"
style="cursor: grab"
>
<VariantCard :variant="element" :update-variant="updateVariant" @select="selectCard" />
<VariantCard
:variant="element"
:update-variant="updateVariant"
data-cy="card-variant"
@select="selectCard"
/>
</div>
</transition-group>
</VueDraggableNext>
Expand All @@ -90,7 +95,7 @@
<i class="pi pi-angle-double-right" />
</div>
<div class="divider"></div>
<div class="w-full lg:w-6">
<div class="w-full lg:w-6" data-cy="panel-droppable-zone">
<div class="panel-title mb-2">Selected Variants</div>
<PvScrollPanel style="height: 32rem; width: 100%; overflow-y: auto">
<!-- Draggable Zone 2 -->
Expand Down Expand Up @@ -122,6 +127,7 @@
@remove="removeCard"
@move-up="moveCardUp"
@move-down="moveCardDown"
data-cy="card-variant"
/>
</div>
</transition-group>
Expand Down
Loading