Skip to content

Commit

Permalink
test(dropzone): add dropzone tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ztlee042 committed Mar 7, 2024
1 parent 2c25512 commit 0f2550a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions cypress/e2e/item/upload/dropzoneUpload.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { buildItemPath } from '@/config/paths';
import { DROPZONE_HELPER_ID } from '@/config/selectors';

import { SAMPLE_ITEMS, SAMPLE_PUBLIC_ITEMS } from '../../../fixtures/items';

describe('home screen - dropzone helper visibility', () => {
beforeEach(() => {
cy.setUpApi();
});

it('should display dropzone helper on the home screen when no items', () => {
cy.visit('/');
cy.get(`#${DROPZONE_HELPER_ID}`).should('be.visible');
});
});

describe('empty folder - dropzone helper visibility', () => {
it('user logs in - show dropzone helper when no items', () => {
cy.setUpApi(SAMPLE_ITEMS);
cy.visit(buildItemPath(SAMPLE_ITEMS.items[1].id));
cy.get(`#${DROPZONE_HELPER_ID}`).should('be.visible');
});

it('user logs out - hide dropzone helper', () => {
cy.setUpApi({ ...SAMPLE_PUBLIC_ITEMS, currentMember: null });
cy.visit(buildItemPath(SAMPLE_PUBLIC_ITEMS.items[2].id));
cy.get(`#${DROPZONE_HELPER_ID}`).should('not.exist');
});
});
2 changes: 1 addition & 1 deletion src/components/main/ItemsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const ItemsTable = ({
showOnlyMe={showOnlyMe}
/>
{itemId && <FolderDescription itemId={itemId} />}
{shouldShowDropzoneHelper && canEditItem ? (
{shouldShowDropzoneHelper && (!parentItem || canEditItem) ? (
<DropzoneHelper />
) : (
<GraaspTable
Expand Down

0 comments on commit 0f2550a

Please sign in to comment.