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

test: add tests of single select mode for the variants feature #479

Merged
merged 5 commits into from
Oct 2, 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
19 changes: 0 additions & 19 deletions src/components/annotations/variants/VariantsTopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import colors from "tailwindcss/colors";
import BaseDialog from "@/components/base/BaseDialog.vue";
import ActiveVariantsDetails from "@/components/annotations/variants/ActiveVariantsDetails.vue";
import BaseButton from "@/components/base/BaseButton.vue";
import WitnessesDetails from "@/components/annotations/variants/WitnessesDetails.vue";
import BaseDropdown from "@/components/base/BaseDropdown.vue";
import BaseCheckbox from "@/components/base/BaseCheckbox.vue";
Expand Down Expand Up @@ -67,27 +66,9 @@
</div>
</div>
</BaseDropdown>
<BaseButton
class="t-ml-auto"
:text="$t('witnesses_details')"
display="outline"
icon="popup"
icon-position="right"
size="small"
@click="witnessesDetailsDialogOpen = true"
/>
</div>
<div class="t-mt-4 t-flex t-items-center" v-show="Object.keys(annotationsStore.activeAnnotations).length > 0">

Check warning on line 70 in src/components/annotations/variants/VariantsTopBar.vue

View workflow job for this annotation

GitHub Actions / build (18)

Attribute "v-show" should go before "class"

Check warning on line 70 in src/components/annotations/variants/VariantsTopBar.vue

View workflow job for this annotation

GitHub Actions / build (18)

'v-show' should be on a new line

Check warning on line 70 in src/components/annotations/variants/VariantsTopBar.vue

View workflow job for this annotation

GitHub Actions / build (20)

Attribute "v-show" should go before "class"

Check warning on line 70 in src/components/annotations/variants/VariantsTopBar.vue

View workflow job for this annotation

GitHub Actions / build (20)

'v-show' should be on a new line
<span class="t-text-sm t-font-bold">{{ Object.keys(annotationsStore.activeAnnotations).length }} Variants selected</span>
<BaseButton
class="t-ml-auto"
:text="$t('variants_details')"
display="outline"
size="small"
icon="popup"
icon-position="right"
@click="variantsDetailsDialogOpen = true"
/>
</div>
</div>
<BaseDialog
Expand Down
112 changes: 99 additions & 13 deletions tests/cypress/e2e/variants.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const selectors = {
})

Cypress.Commands.add('clickTarget', () => {
// click witness of the drop down having button named 'buttonName'
cy
.get('div#text-content div#MD12675N1l4l2l6l4l42')
.children()
Expand All @@ -33,13 +32,39 @@ const selectors = {
.contains('p',description).parent()
})


Cypress.Commands.add('clickSingleSelectButton', () => {

cy
.get('.panels-wrapper .panel:nth-child(4)')
.find('.panel-header')
.find('.actions')
.children().eq(2)
.find('input[type="checkbox"]')
.click()
})

Cypress.Commands.add('checkNoAnnotationsAvailable', () => {
cy
.get('.panels-wrapper .panel:nth-child(4) .panel-body')
.find('div[id="pv_id_6_2_content"]')
.children().eq(0)
.children().eq(1) // annotation content
.children().eq(0).should('not.have.class', 'annotations-list')
.find('span').contains('No Annotations available')
})




describe('VariantsAnnotation', () => {

beforeEach(() => {
cy
.visit(`/ahiqar-arabic-karshuni-with-variants-local.html?tido=m20_i1_p0.0-1.0-2.0-3.2`)
.get('#text-content')
.should('be.visible')
.get(selectors.list)
.should('be.visible')
})

describe('Variants items selection', () => {
Expand Down Expand Up @@ -181,6 +206,8 @@ const selectors = {
.should('eq', 'http://ahikar.uni-goettingen.de/ns/annotations/3r14z/annotation-variants-t_Brit_Mus_Add_7209_N1l5l3l5l5l29l4_w_3_0')
})

/*
Commented out this test, since we hide the witnesses details dialog box
it('Should show a dialog box containing a list of a witnesses and a description of them', () => {
// the witnesses are the unique set of the ones which appear in the variants list
cy
Expand All @@ -201,11 +228,12 @@ const selectors = {
.checkTextInWitnessItemDescription('Ming. syr. 258', 'test')
.checkTextInWitnessItemDescription('Sach. 339', 'test')
})
*/
})

describe('Highlighted Text selection', () => {
it('should click at a highlighted text, show its witnesses and select all related variant items in variants tab', () => {
cy
cy
// click at one target
.clickTarget()

Expand All @@ -223,17 +251,17 @@ const selectors = {
.get(selectors.list)
.children()
.eq(2)
.should('not.have.class', 't-bg-gray-300')
.should('not.have.class', 'active')
.next()
.should('have.class', 't-bg-gray-300')
.should('have.class', 'active')
.next()
.should('have.class', 't-bg-gray-300')
.should('have.class', 'active')
.next()
.should('have.class', 't-bg-gray-300')
.should('have.class', 'active')
.next()
.should('have.class', 't-bg-gray-300')
.should('have.class', 'active')
.next()
.should('not.have.class', 't-bg-gray-300')
.should('not.have.class', 'active')
})

//
Expand All @@ -252,14 +280,72 @@ const selectors = {
.get(selectors.list)
.children()
.eq(3)
.should('not.have.class', 't-bg-gray-300')
.should('not.have.class', 'active')
.next()
.should('not.have.class', 't-bg-gray-300')
.should('not.have.class', 'active')
.next()
.should('not.have.class', 't-bg-gray-300')
.should('not.have.class', 'active')
.next()
.should('not.have.class', 't-bg-gray-300')
.should('not.have.class', 'active')
})
})


describe('Single select mode', () => {

it('should hide the variant items when single select mode is on', () => {
cy.wait(500).then(() => {
// we wait till the text panel and annotations panel are fully loaded
cy
.clickSingleSelectButton().then(() => {
cy.checkNoAnnotationsAvailable()
})
})
})

it('should show variant items of the target as selected when clicking the target in single select mode', () => {

cy.wait(500).then(() => {
cy
.clickSingleSelectButton().then(() => {
cy.clickTarget()
cy.get('.panels-wrapper .panel:nth-child(4) .panel-body div#pv_id_6_2_content')
.find('.annotations-list')
.children().should('have.length', 4)
.each(($li) => {
expect($li).to.have.class('active')
})
})
})
})

it('should hide the selected variant items after unclicking the target in single select mode', () => {
cy.wait(500).then(() => {
cy.clickSingleSelectButton()
cy.clickTarget()
// below we unclick the target
cy
.get('div#text-content div#MD12675N1l4l2l6l4l42')
.children()
.eq(2) // target becomes the third child element, since 'witnesses' span was added in the text
.click()
// we expect the selected annotations to be hidden from the tab
cy.checkNoAnnotationsAvailable()
})
})

it('should show again all the variant item when we switch off the single select mode', () => {
cy.wait(500).then(() => {
cy
.clickSingleSelectButton() // set the single select mode
cy
.clickSingleSelectButton() // switch off the single select mode
cy
.get(selectors.list)
.should('be.visible')
.children()
.should("have.length", 11) // we have 11 variant items as in the normal mode - no single select mode
})
})
})
});
Loading