Skip to content

Commit

Permalink
fix: fix variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
louisewang1 committed Jan 18, 2022
1 parent d3999d9 commit 578ea8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
16 changes: 10 additions & 6 deletions cypress/integration/item/share/categories.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ const openShareItemTab = (id) => {
const findCategoryNameById = (id) =>
SAMPLE_CATEGORIES.find((entry) => entry.id === id)?.name;

export const deleteFirstOption = () => {
export const deleteOption = (index) => {
cy.get(`#${SHARE_ITEM_CATEGORY_LEVEL}`).click();
cy.get(`#${SHARE_ITEM_CATEGORY_LEVEL}-popup li[data-option-index="0"]`).click();
cy.get(
`#${SHARE_ITEM_CATEGORY_LEVEL}-popup li[data-option-index="${index}"]`,
).click();
};

export const addFirstOption = () => {
export const addOption = (index) => {
cy.get(`#${SHARE_ITEM_CATEGORY_DISCIPLINE}`).click();
cy.get(`#${SHARE_ITEM_CATEGORY_DISCIPLINE}-popup li[data-option-index="0"]`).click();
cy.get(
`#${SHARE_ITEM_CATEGORY_DISCIPLINE}-popup li[data-option-index="${index}"]`,
).click();
};

describe('Categories', () => {
Expand All @@ -54,7 +58,7 @@ describe('Categories', () => {

it('Delete a category option', () => {
// delete selection
deleteFirstOption();
deleteOption(0);
cy.wait('@deleteItemCategory').then((data) => {
const entryId = item.categories[0].id;
const {
Expand All @@ -65,7 +69,7 @@ describe('Categories', () => {
});

it('Add a category option', () => {
addFirstOption();
addOption(0);
cy.wait('@postItemCategory').then((data) => {
const {
request: { url },
Expand Down
24 changes: 15 additions & 9 deletions cypress/integration/item/share/tags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
ITEM_TAGS_EDIT_SUBMIT_BUTTON_ID,
} from '../../../../src/config/selectors';
import { buildItemPath } from '../../../../src/config/paths';
import { ITEM_WITH_CATEGORIES, NEW_CUSTOMIZED_TAG } from '../../../fixtures/categories';
import {
ITEM_WITH_CATEGORIES,
NEW_CUSTOMIZED_TAG,
} from '../../../fixtures/categories';
import { ITEM_LOGIN_ITEMS, PUBLISHED_ITEM } from '../../../fixtures/items';
import { DEFAULT_TAGS } from '../../../fixtures/itemTags';
import { MEMBERS, SIGNED_OUT_MEMBER } from '../../../fixtures/members';
Expand All @@ -18,7 +21,7 @@ const visitItemPage = (item) => {
cy.setUpApi({ items: [item], tags: DEFAULT_TAGS });
cy.visit(buildItemPath(item.id));
openShareItemTab(item.id);
}
};

describe('Customized Tags', () => {
it('Display tags', () => {
Expand All @@ -37,18 +40,21 @@ describe('Customized Tags', () => {
cy.get(`#${ITEM_TAGS_EDIT_INPUT_ID}`).should('have.text', '');
});

it('Change tags', () => {
it('Edit tags', () => {
const item = ITEM_WITH_CATEGORIES;
visitItemPage(item);
cy.get(`#${ITEM_TAGS_EDIT_INPUT_ID}`).clear().type(NEW_CUSTOMIZED_TAG).should('have.text', NEW_CUSTOMIZED_TAG);
cy.get(`#${ITEM_TAGS_EDIT_INPUT_ID}`)
.clear()
.type(NEW_CUSTOMIZED_TAG)
.should('have.text', NEW_CUSTOMIZED_TAG);
cy.get(`#${ITEM_TAGS_EDIT_SUBMIT_BUTTON_ID}`).click();
cy.wait('@editItem').then((data) => {
const {
request: { url, body },
} = data;
expect(url.split('/')).contains(item.id);
expect(body.settings.tags).contains(NEW_CUSTOMIZED_TAG);
})
});
});
});

Expand All @@ -58,8 +64,8 @@ describe('Tags permissions', () => {
cy.setUpApi({ items: [item], currentMember: SIGNED_OUT_MEMBER });
cy.visit(buildItemPath(item.id));
openShareItemTab(item.id);
const levelValue = cy.get(`#${ITEM_TAGS_EDIT_INPUT_ID}`);
levelValue.should('be.disabled');
const tagsEdit = cy.get(`#${ITEM_TAGS_EDIT_INPUT_ID}`);
tagsEdit.should('be.disabled');
});

it('Read-only user cannot edit tags', () => {
Expand All @@ -70,7 +76,7 @@ describe('Tags permissions', () => {
});
cy.visit(buildItemPath(item.id));
openShareItemTab(item.id);
const levelValue = cy.get(`#${ITEM_TAGS_EDIT_INPUT_ID}`);
levelValue.should('be.disabled');
const tagsEdit = cy.get(`#${ITEM_TAGS_EDIT_INPUT_ID}`);
tagsEdit.should('be.disabled');
});
});

0 comments on commit 578ea8f

Please sign in to comment.