Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMattiussi committed Mar 9, 2020
1 parent 7ede23d commit bb5f7f8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
35 changes: 35 additions & 0 deletions cypress/integration/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,41 @@ describe('Edit Page', () => {
expect(el).to.have.value(date)
);
});

it('should change reference list correctly when changing filter', () => {
const EditPostTagsPage = editPageFactory('/#/posts/13');
EditPostTagsPage.navigate();
EditPostTagsPage.gotoTab(3);

// Music is selected by default
cy.get(
EditPostTagsPage.elements.input('tags', 'reference-array-input')
)
.get(`div[role=button]`)
.contains('Music')
.should('exist');

EditPostTagsPage.clickInput('change-filter');

// Music should not be selected anymore after filter reset
cy.get(
EditPostTagsPage.elements.input('tags', 'reference-array-input')
)
.get(`div[role=button]`)
.contains('Music')
.should('not.exist');

EditPostTagsPage.clickInput('tags', 'reference-array-input');

// Music should not be visible in the list after filter reset
cy.get('div[role=listbox]')
.contains('Music')
.should('not.exist');

cy.get('div[role=listbox]')
.contains('Photo')
.should('exist');
});
});

it('should fill form correctly even when switching from one form type to another', () => {
Expand Down
7 changes: 5 additions & 2 deletions cypress/support/EditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export default url => ({
if (type === 'rich-text-input') {
return `.ra-input-${name} .ql-editor`;
}
if (type === 'reference-array-input') {
return `.ra-input div[role=combobox]`;
}
return `.edit-page [name='${name}']`;
},
inputs: `.ra-input`,
Expand Down Expand Up @@ -37,8 +40,8 @@ export default url => ({
}
},

clickInput(name) {
cy.get(this.elements.input(name)).click();
clickInput(name, type = 'input') {
cy.get(this.elements.input(name, type)).click();
},

gotoTab(index) {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/posts/TagReferenceInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const TagReferenceInput = ({ ...props }) => {
<AutocompleteArrayInput />
</ReferenceArrayInput>
<Button
data-testid="button-add-filter"
name="change-filter"
className={classes.button}
onClick={handleAddFilter}
>
Expand Down

0 comments on commit bb5f7f8

Please sign in to comment.