Skip to content

Commit

Permalink
test: update test, test card and list layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Feb 9, 2021
1 parent 32e246e commit c2c4e2f
Show file tree
Hide file tree
Showing 42 changed files with 1,215 additions and 426 deletions.
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"baseUrl": "http://web.graasp.org:3111"
"baseUrl": "http://web.graasp.org:3111",
"video": false
}
109 changes: 0 additions & 109 deletions cypress/integration/copyItem.spec.js

This file was deleted.

80 changes: 0 additions & 80 deletions cypress/integration/createItem.spec.js

This file was deleted.

103 changes: 103 additions & 0 deletions cypress/integration/item/copy/gridCopyItem.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { MODES, ROOT_ID } from '../../../../src/config/constants';
import { buildItemPath, HOME_PATH } from '../../../../src/config/paths';
import {
buildItemCard,
buildItemMenu,
ITEM_MENU_BUTTON_CLASS,
ITEM_MENU_COPY_BUTTON_CLASS,
} from '../../../../src/config/selectors';
import { SIMPLE_ITEMS } from '../../../fixtures/items';

const copyItem = (id, toItemId) => {
const menuSelector = `#${buildItemCard(id)} .${ITEM_MENU_BUTTON_CLASS}`;
cy.get(menuSelector).click();
cy.get(`#${buildItemMenu(id)} .${ITEM_MENU_COPY_BUTTON_CLASS}`).click();
cy.fillTreeModal(toItemId);
};

describe('Copy Item in Grid', () => {
it('copy item on Home', () => {
cy.setUpApi({ items: SIMPLE_ITEMS });
cy.visit(HOME_PATH);
cy.switchMode(MODES.GRID);

// copy
const { id: copyItemId } = SIMPLE_ITEMS[0];
const { id: toItem } = SIMPLE_ITEMS[1];
copyItem(copyItemId, toItem);

cy.wait('@copyItem').then(({ response: { body } }) => {
cy.get(`#${buildItemCard(copyItemId)}`).should('exist');

// check in new parent
cy.goToItemInGrid(toItem);
cy.get(`#${buildItemCard(body.id)}`).should('exist');
});
});

it('copy item in item', () => {
cy.setUpApi({ items: SIMPLE_ITEMS });
const { id } = SIMPLE_ITEMS[0];

// go to children item
cy.visit(buildItemPath(id));
cy.switchMode(MODES.GRID);

// move
const { id: copyItemId } = SIMPLE_ITEMS[2];
const { id: toItem } = SIMPLE_ITEMS[3];
copyItem(copyItemId, toItem);

cy.wait('@copyItem').then(({ response: { body } }) => {
cy.get(`#${buildItemCard(copyItemId)}`).should('exist');

// check in new parent
cy.goToItemInGrid(toItem);
cy.get(`#${buildItemCard(body.id)}`).should('exist');
});
});

it('copy item to Home', () => {
cy.setUpApi({ items: SIMPLE_ITEMS });
const { id } = SIMPLE_ITEMS[0];

// go to children item
cy.visit(buildItemPath(id));
cy.switchMode(MODES.GRID);

// move
const { id: copyItemId } = SIMPLE_ITEMS[2];
const toItem = ROOT_ID;
copyItem(copyItemId, toItem);

cy.wait('@copyItem').then(({ response: { body } }) => {
cy.get(`#${buildItemCard(copyItemId)}`).should('exist');

// check in new parent
cy.goToHome();
cy.get(`#${buildItemCard(body.id)}`).should('exist');
});
});

describe('Errors handling', () => {
it('error while moving item does not create in interface', () => {
cy.setUpApi({ items: SIMPLE_ITEMS, copyItemError: true });
const { id } = SIMPLE_ITEMS[0];

// go to children item
cy.visit(buildItemPath(id));
cy.switchMode(MODES.GRID);

// move
const { id: copyItemId } = SIMPLE_ITEMS[2];
const { id: toItem } = SIMPLE_ITEMS[0];
copyItem(copyItemId, toItem);

cy.wait('@copyItem').then(({ response: { body } }) => {
// check item is still existing in parent
cy.get(`#${buildItemCard(copyItemId)}`).should('exist');
cy.get(`#${buildItemCard(body.id)}`).should('not.exist');
});
});
});
});
Loading

0 comments on commit c2c4e2f

Please sign in to comment.