Skip to content

Commit

Permalink
fix: view information tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LinaYahya committed Jan 26, 2024
1 parent ec96e0e commit 12421e5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 28 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/item/thumbnails/uploadThumbnail.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { buildItemPath } from '../../../../src/config/paths';
import {
CROP_MODAL_CONFIRM_BUTTON_CLASSNAME,
ITEM_SETTINGS_BUTTON_CLASS,
ITEM_INFORMATION_BUTTON_ID,
THUMBNAIL_SETTING_UPLOAD_BUTTON_CLASSNAME,
} from '../../../../src/config/selectors';
import {
Expand All @@ -18,7 +18,7 @@ describe('Upload Thumbnails', () => {
it(`upload item thumbnail`, () => {
const { items } = SAMPLE_ITEMS_WITH_THUMBNAILS;
cy.visit(buildItemPath(items[0].id));
cy.get(`.${ITEM_SETTINGS_BUTTON_CLASS}`).click();
cy.get(`#${ITEM_INFORMATION_BUTTON_ID}`).click();

// change item thumbnail
// selectFile ???
Expand Down
7 changes: 2 additions & 5 deletions cypress/e2e/item/view/viewFolder.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ describe('View Folder', () => {
// should get current item
cy.wait('@getItem');

expectFolderViewScreenLayout({ item: SAMPLE_ITEMS.items[0] });

// should get children
cy.wait('@getChildren').then(({ response: { body } }) => {
// check all children are created and displayed
for (const item of body) {
cy.get(`#${buildItemCard(item.id)}`).should('exist');
}
});
expectFolderViewScreenLayout({ item: SAMPLE_ITEMS.items[0] });

// visit home
cy.get(`#${NAVIGATION_ROOT_ID} [href="${HOME_PATH}"]`).click();
Expand Down Expand Up @@ -81,9 +80,6 @@ describe('View Folder', () => {

// should get current item
cy.wait('@getItem');

expectFolderViewScreenLayout({ item: SAMPLE_ITEMS.items[0] });

// should get children
cy.wait('@getChildren').then(({ response: { body } }) => {
// check all children are created and displayed
Expand All @@ -92,6 +88,7 @@ describe('View Folder', () => {
}
});

expectFolderViewScreenLayout({ item: SAMPLE_ITEMS.items[0] });
// visit home
cy.get(`#${NAVIGATION_ROOT_ID} [href="${HOME_PATH}"]`).click();

Expand Down
8 changes: 1 addition & 7 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import 'cypress-localstorage-commands';
import { DEFAULT_ITEM_LAYOUT_MODE } from '../../src/config/constants';
import {
ITEM_INFORMATION_BUTTON_ID,
ITEM_INFORMATION_ICON_IS_OPEN_CLASS,
ITEM_PANEL_ID,
MODE_GRID_BUTTON_ID,
MODE_LIST_BUTTON_ID,
} from '../../src/config/selectors';
Expand Down Expand Up @@ -398,11 +396,7 @@ Cypress.Commands.add(
);

Cypress.Commands.add('openMetadataPanel', () => {
cy.get(`#${ITEM_PANEL_ID}`).then(($itemPanel) => {
if (!$itemPanel.hasClass(ITEM_INFORMATION_ICON_IS_OPEN_CLASS)) {
cy.get(`#${ITEM_INFORMATION_BUTTON_ID}`).click();
}
});
cy.get(`#${ITEM_INFORMATION_BUTTON_ID}`).click();
});

Cypress.Commands.add('attachFile', (selector, file, options = {}) => {
Expand Down
22 changes: 8 additions & 14 deletions cypress/support/viewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
import {
DOCUMENT_ITEM_TEXT_EDITOR_SELECTOR,
ITEM_HEADER_ID,
ITEM_PANEL_ID,
ITEM_PANEL_NAME_ID,
ITEM_PANEL_TABLE_ID,
TEXT_EDITOR_CLASS,
Expand All @@ -36,21 +35,20 @@ const expectPanelLayout = ({ item }: { item: ItemForTest }) => {

const { name, creator } = item;

const panel = cy.get(`#${ITEM_PANEL_ID}`);
panel.get(`#${ITEM_PANEL_NAME_ID}`).contains(name);
cy.get(`#${ITEM_PANEL_NAME_ID}`).contains(name);

const creatorName = getMemberById(Object.values(MEMBERS), creator?.id).name;

panel.get(`#${ITEM_PANEL_TABLE_ID}`).should('exist').contains(creatorName);
cy.get(`#${ITEM_PANEL_TABLE_ID}`).should('exist').contains(creatorName);

if (item.type === ItemType.LOCAL_FILE || item.type === ItemType.S3_FILE) {
const { mimetype = 'invalid-mimetype', size = 'invalid-size' } =
item.type === ItemType.LOCAL_FILE
? getFileExtra(item.extra) || {}
: getS3FileExtra(item.extra) || {};
panel.get(`#${ITEM_PANEL_TABLE_ID}`).contains(mimetype);
cy.get(`#${ITEM_PANEL_TABLE_ID}`).contains(mimetype);

panel.get(`#${ITEM_PANEL_TABLE_ID}`).contains(size);
cy.get(`#${ITEM_PANEL_TABLE_ID}`).contains(size);
}
};

Expand Down Expand Up @@ -89,11 +87,10 @@ export const expectDocumentViewScreenLayout = ({
expect(editor.html()).to.contain(getDocumentExtra(item.extra)?.content);
});

expectItemHeaderLayout({ item, currentMember });
expectPanelLayout({
item,
});

expectItemHeaderLayout({ item, currentMember });
};

export const expectFileViewScreenLayout = ({
Expand All @@ -108,10 +105,9 @@ export const expectFileViewScreenLayout = ({

cy.get(`.${TEXT_EDITOR_CLASS}`).should('contain', item.description);

expectItemHeaderLayout({ item, currentMember });
// table
expectPanelLayout({ item });

expectItemHeaderLayout({ item, currentMember });
};

export const expectLinkViewScreenLayout = ({
Expand Down Expand Up @@ -143,10 +139,9 @@ export const expectLinkViewScreenLayout = ({
cy.get(`.${TEXT_EDITOR_CLASS}`).should('contain', description);
}

expectItemHeaderLayout({ item, currentMember });
// table
expectPanelLayout({ item });

expectItemHeaderLayout({ item, currentMember });
};

export const expectFolderViewScreenLayout = ({
Expand All @@ -157,7 +152,6 @@ export const expectFolderViewScreenLayout = ({
currentMember?: MemberForTest | null;
}): void => {
// table
expectPanelLayout({ item });

expectItemHeaderLayout({ item, currentMember });
expectPanelLayout({ item });
};

0 comments on commit 12421e5

Please sign in to comment.