Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-Torrent committed Jan 12, 2022
1 parent 6dc568a commit b5703c2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
22 changes: 12 additions & 10 deletions cypress/integration/item/hide/hideItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import {
import { TABLE_ITEM_RENDER_TIME } from '../../../support/constants';
import { ITEM_LAYOUT_MODES } from '../../../../src/enums';

const togglePinButton = (itemId) => {
const HiddenTagId = 'hiddenTagId';

const toggleHideButton = (itemId) => {
cy.wait(TABLE_ITEM_RENDER_TIME);
cy.get(
`${buildItemsTableRowIdAttribute(itemId)} .${HIDDEN_ITEM_BUTTON_CLASS}`,
).click();
};

const togglePinButtonCard = (itemId) => {
const toggleHideButtonCard = (itemId) => {
cy.wait(TABLE_ITEM_RENDER_TIME);
cy.get(`#${buildItemCard(itemId)} .${HIDDEN_ITEM_BUTTON_CLASS}`).click();
};
Expand All @@ -30,15 +32,15 @@ describe('Hiding Item', () => {
it('Hide an item', () => {
const item = ITEMS_SETTINGS.items[1];

togglePinButton(item.id);
toggleHideButton(item.id);

cy.wait(`@postItemTag`).then(
({
request: {
body: { tagId },
},
}) => {
expect(tagId).to.equals('b5373e38-e89b-4dc7-b4b9-fd3601504467');
expect(tagId).to.equals(HiddenTagId);
},
);
});
Expand All @@ -47,7 +49,7 @@ describe('Hiding Item', () => {
const item = HIDDEN_ITEM;

cy.wait(5000);
togglePinButton(item.id);
toggleHideButton(item.id);

cy.wait('@deleteItemTag').then(({ request: { url } }) => {
expect(url).to.contain(item.tags[1].id);
Expand All @@ -62,26 +64,26 @@ describe('Hiding Item', () => {
cy.switchMode(ITEM_LAYOUT_MODES.GRID);
});

it('Pin an item', () => {
it('Hide an item', () => {
const item = ITEMS_SETTINGS.items[1];

togglePinButtonCard(item.id);
toggleHideButtonCard(item.id);

cy.wait(`@postItemTag`).then(
({
request: {
body: { tagId },
},
}) => {
expect(tagId).to.equals('b5373e38-e89b-4dc7-b4b9-fd3601504467');
expect(tagId).to.equals(HiddenTagId);
},
);
});

it('Unpin Item', () => {
it('Show an Item', () => {
const item = ITEMS_SETTINGS.items[0];

togglePinButtonCard(item.id);
toggleHideButtonCard(item.id);

cy.wait('@deleteItemTag').then(({ request: { url } }) => {
expect(url).to.contain(item.tags[1].id);
Expand Down
32 changes: 15 additions & 17 deletions cypress/integration/item/pin/pinItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ const togglePinButton = (itemId) => {

const togglePinButtonCard = (itemId) => {
cy.wait(TABLE_ITEM_RENDER_TIME);
cy.get(
`#${buildItemCard(itemId)} .${PIN_ITEM_BUTTON_CLASS}`,
).click();
cy.get(`#${buildItemCard(itemId)} .${PIN_ITEM_BUTTON_CLASS}`).click();
};

describe('Pinning Item', () => {

describe('Successfully pinning item in List', () => {
beforeEach(() => {
cy.setUpApi(ITEMS_SETTINGS);
Expand All @@ -37,16 +34,17 @@ describe('Pinning Item', () => {

cy.wait(`@editItem`).then(
({
request: {
body : { settings }
}
request: {
body: { settings },
},
}) => {
expect(settings.isPinned).to.equals(true);
});
expect(settings.isPinned).to.equals(true);
},
);
});

it('Unpin Item', () => {
const item = ITEMS_SETTINGS.items[0];
const item = ITEMS_SETTINGS.items[1];

togglePinButton(item.id);

Expand All @@ -62,7 +60,6 @@ describe('Pinning Item', () => {
});
});


describe('Successfully pinning item in Grid', () => {
beforeEach(() => {
cy.setUpApi(ITEMS_SETTINGS);
Expand All @@ -77,16 +74,17 @@ describe('Pinning Item', () => {

cy.wait(`@editItem`).then(
({
request: {
body : { settings }
}
request: {
body: { settings },
},
}) => {
expect(settings.isPinned).to.equals(true);
});
expect(settings.isPinned).to.equals(true);
},
);
});

it('Unpin Item', () => {
const item = ITEMS_SETTINGS.items[0];
const item = ITEMS_SETTINGS.items[1];

togglePinButtonCard(item.id);

Expand Down
36 changes: 18 additions & 18 deletions cypress/integration/item/settings/itemSettings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { EDIT_ITEM_PAUSE } from '../../../support/constants';

describe('Item Settings', () => {
beforeEach(() => {
cy.setUpApi({...ITEMS_SETTINGS});
cy.setUpApi({ ...ITEMS_SETTINGS });
});

describe('Chatbox Settings', () => {
it('Disabling Chatbox', () => {
const itemId = ITEMS_SETTINGS.items[0].id;
const itemId = ITEMS_SETTINGS.items[1].id;

cy.visit(buildItemPath(itemId));
cy.get(`.${ITEM_SETTINGS_BUTTON_CLASS}`).click();
Expand All @@ -25,9 +25,9 @@ describe('Item Settings', () => {

cy.wait('@editItem').then(
({
response: {
body: { settings },
}
response: {
body: { settings },
},
}) => {
expect(settings.showChatbox).equals(false);
cy.wait(EDIT_ITEM_PAUSE);
Expand All @@ -37,20 +37,20 @@ describe('Item Settings', () => {
});

it('Enabling Chatbox', () => {
const itemId = ITEMS_SETTINGS.items[1].id;
const itemId = ITEMS_SETTINGS.items[2].id;

cy.visit(buildItemPath(itemId));
cy.get(`.${ITEM_SETTINGS_BUTTON_CLASS}`).click();

cy.get(`#${SETTINGS_CHATBOX_TOGGLE_ID}`).should('not.be.checked');

cy.get(`#${SETTINGS_CHATBOX_TOGGLE_ID}`).click();

cy.wait('@editItem').then(
({
response: {
body: { settings },
}
response: {
body: { settings },
},
}) => {
expect(settings.showChatbox).equals(true);
cy.wait(EDIT_ITEM_PAUSE);
Expand All @@ -62,7 +62,7 @@ describe('Item Settings', () => {

describe('Pinned Settings', () => {
it('Unpin Items', () => {
const itemId = ITEMS_SETTINGS.items[0].id;
const itemId = ITEMS_SETTINGS.items[1].id;

cy.visit(buildItemPath(itemId));
cy.get(`.${ITEM_SETTINGS_BUTTON_CLASS}`).click();
Expand All @@ -73,9 +73,9 @@ describe('Item Settings', () => {

cy.wait('@editItem').then(
({
response: {
body: { settings },
}
response: {
body: { settings },
},
}) => {
expect(settings.isPinned).equals(false);
cy.wait(EDIT_ITEM_PAUSE);
Expand All @@ -85,7 +85,7 @@ describe('Item Settings', () => {
});

it('Pin Item', () => {
const itemId = ITEMS_SETTINGS.items[1].id;
const itemId = ITEMS_SETTINGS.items[2].id;
cy.visit(buildItemPath(itemId));
cy.get(`.${ITEM_SETTINGS_BUTTON_CLASS}`).click();

Expand All @@ -95,9 +95,9 @@ describe('Item Settings', () => {

cy.wait('@editItem').then(
({
response: {
body: { settings },
}
response: {
body: { settings },
},
}) => {
expect(settings.isPinned).equals(true);
cy.wait(EDIT_ITEM_PAUSE);
Expand Down

0 comments on commit b5703c2

Please sign in to comment.