Skip to content

Commit

Permalink
fix: add more tests for categories and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
louisewang1 committed Jan 18, 2022
1 parent 87ba089 commit 9d707e6
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions cypress/integration/item/share/categories.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
SAMPLE_CATEGORIES,
} from '../../../fixtures/categories';
import { DEFAULT_TAGS } from '../../../fixtures/itemTags';
import { ITEM_LOGIN_ITEMS } from '../../../fixtures/items';
import { MEMBERS, SIGNED_OUT_MEMBER } from '../../../fixtures/members';

const openShareItemTab = (id) => {
cy.get(`#${buildShareButtonId(id)}`).click();
Expand All @@ -27,25 +29,27 @@ export const addOption = () => {
};

describe('Categories', () => {
it('Item Categories', () => {
const item = ITEM_WITH_CATEGORIES;
const item = ITEM_WITH_CATEGORIES;
beforeEach(() => {
cy.setUpApi({ items: [item], tags: DEFAULT_TAGS });
cy.visit(buildItemPath(item.id));
openShareItemTab(item.id);

});
it('Disply Item Categories', () => {
// check for displaying value
const levelValue = cy.get(
'div.MuiChip-root.MuiAutocomplete-tag.MuiChip-deletable > span',
);
levelValue.first().contains(SAMPLE_CATEGORIES[0].name);
});

it('Display item without category', () => {
// check for not displaying if no categories
const disciplineValue = cy.get(`#${SHARE_ITEM_CATEGORY_DISCIPLINE}`);
disciplineValue.should('be.empty');
});

const displayTags = cy.get('span.MuiChip-label');
displayTags.contains(CUSTOMIZED_TAGS[0]);

it('Delete a category option', () => {
// delete selection
deleteOption();
cy.wait(['@deleteItemCategory']).then((data) => {
Expand All @@ -56,8 +60,9 @@ describe('Categories', () => {
expect(url.split('/')[4]).equal('item-category');
expect(url.split('/')[5]).equal(entryId);
});
});

// add selection
it('Add a category option', () => {
addOption();
cy.wait(['@postItemCategory']).then((data) => {
const {
Expand All @@ -68,3 +73,38 @@ describe('Categories', () => {
});
});
});

describe('Customized Tags', () => {
it('Display tags', () => {
const item = ITEM_WITH_CATEGORIES;
cy.setUpApi({ items: [item], tags: DEFAULT_TAGS });
cy.visit(buildItemPath(item.id));
openShareItemTab(item.id);
const displayTags = cy.get('span.MuiChip-label');
displayTags.contains(CUSTOMIZED_TAGS[0]);
});
});

describe('Permissions', () => {
it('User signed out', () => {
const item = ITEM_LOGIN_ITEMS.items[0];
cy.setUpApi({ ...ITEM_LOGIN_ITEMS, currentMember: SIGNED_OUT_MEMBER });
cy.visit(buildItemPath(item.id));
const signInNotification = cy.get(
`span.MuiTypography-root.MuiFormControlLabel-label.makeStyles-signInWithWrapperLabel-10`,
);
signInNotification.contains('Sign In with');
});

it('Read-only', () => {
const item = ITEM_LOGIN_ITEMS.items[0];
cy.setUpApi({
...ITEM_LOGIN_ITEMS,
currentMember: MEMBERS.BOB,
});
cy.visit(buildItemPath(item.id));
openShareItemTab(item.id);
const levelValue = cy.get(`#${SHARE_ITEM_CATEGORY_LEVEL}`);
levelValue.should('be.disabled');
});
});

0 comments on commit 9d707e6

Please sign in to comment.