cy.clearLocalStorage()
})
- it('shows a collection by URL', function() {
+ it('shows collection by URL', function() {
cy.loginAs(activeUser);
- cy.createCollection(adminUser.token, {
- name: 'Test collection',
- owner_uuid: activeUser.user.uuid,
- manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
- .as('testCollection').then(function() {
- cy.visit(`/collections/${this.testCollection.uuid}`);
- cy.get('[data-cy=collection-info-panel]')
- .should('contain', this.testCollection.name)
- .and('contain', this.testCollection.uuid);
- cy.get('[data-cy=collection-files-panel]')
- .should('contain', 'bar');
+ [true, false].map(function(isWritable) {
+ // Creates the collection using the admin token so we can set up
+ // a bogus manifest text without block signatures.
+ cy.createCollection(adminUser.token, {
+ name: 'Test collection',
+ owner_uuid: isWritable
+ ? activeUser.user.uuid
+ : adminUser.user.uuid,
+ properties: {someKey: 'someValue'},
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
+ .as('testCollection').then(function() {
+ if (isWritable === false) {
+ // Share collection as read-only
+ cy.do_request('POST', '/arvados/v1/links', {
+ link: JSON.stringify({
+ name: 'can_read',
+ link_class: 'permission',
+ head_uuid: this.testCollection.uuid,
+ tail_uuid: activeUser.user.uuid
+ })
+ }, null, adminUser.token, null);
+ }
+ cy.visit(`/collections/${this.testCollection.uuid}`);
+ // Check that name & uuid are correct.
+ cy.get('[data-cy=collection-info-panel]')
+ .should('contain', this.testCollection.name)
+ .and(`${isWritable ? 'not.': ''}contain`, 'Read-only')
+ .and('contain', this.testCollection.uuid);
+ // Check that both read and write operations are available on
+ // the 'More options' menu.
+ cy.get('[data-cy=collection-panel-options-btn]')
+ .click()
+ cy.get('[data-cy=context-menu]')
+ .should('contain', 'Add to favorites')
+ .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection')
+ .type('{esc}'); // Collapse the options menu
+ cy.get('[data-cy=collection-properties-panel]')
+ .should('contain', 'someKey')
+ .and('contain', 'someValue')
+ .and('not.contain', 'anotherKey')
+ .and('not.contain', 'anotherValue')
+ // Check that properties can be added.
+ if (isWritable === true) {
+ cy.get('[data-cy=collection-properties-form]').within(() => {
+ cy.get('[data-cy=property-field-key]').within(() => {
+ cy.get('input').type('anotherKey');
+ });
+ cy.get('[data-cy=property-field-value]').within(() => {
+ cy.get('input').type('anotherValue');
+ });
+ cy.root().submit();
+ })
+ cy.get('[data-cy=collection-properties-panel]')
+ .should('contain', 'anotherKey')
+ .and('contain', 'anotherValue')
+ }
+ // Check that the file listing show both read & write operations
+ cy.get('[data-cy=collection-files-panel]').within(() => {
+ cy.root().should('contain', 'bar');
+ cy.get('[data-cy=upload-button]')
+ .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
+ });
+ // Hamburger 'more options' menu button
+ cy.get('[data-cy=collection-files-panel-options-btn]')
+ .click()
+ cy.get('[data-cy=context-menu]')
+ .should('contain', 'Select all')
+ .click()
+ cy.get('[data-cy=collection-files-panel-options-btn]')
+ .click()
+ cy.get('[data-cy=context-menu]')
+ .should('contain', 'Download selected')
+ .and(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
+ .type('{esc}'); // Collapse the options menu
+ // File item 'more options' button
+ cy.get('[data-cy=file-item-options-btn')
+ .click()
+ cy.get('[data-cy=context-menu]')
+ .should('contain', 'Download')
+ .and(`${isWritable ? '' : 'not.'}contain`, 'Remove')
+ .type('{esc}'); // Collapse
+ })
})
})
-
- // it('')
})
\ No newline at end of file
import { UserResource } from '~/models/user';
import { getUserUuid } from '~/common/getuser';
-type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link' | 'centeredLabel';
+type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link' | 'centeredLabel' | 'readOnlyChip';
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
card: {
'&:hover': {
cursor: 'pointer'
}
+ },
+ readOnlyChip: {
+ marginLeft: theme.spacing.unit
}
});
action={
<Tooltip title="More options" disableFocusListener>
<IconButton
+ data-cy='collection-panel-options-btn'
aria-label="More options"
onClick={this.handleContextMenu}>
<MoreOptionsIcon />
<span>
<IllegalNamingWarning name={item.name}/>
{item.name}
- {isWritable || <Chip variant="outlined" icon={<ReadOnlyIcon />} label="Read-only"/>}
+ {isWritable || <Chip variant="outlined" icon={<ReadOnlyIcon />} label="Read-only" className={classes.readOnlyChip} />}
</span>
}
titleTypographyProps={this.titleProps}
</CardContent>
</Card>
- <Card className={classes.card}>
+ <Card data-cy='collection-properties-panel' className={classes.card}>
<CardHeader title="Properties" />
<CardContent>
<Grid container direction="column">
</Grid>
</CardContent>
</Card>
- <div className={classes.card} data-cy="collection-files-panel">
+ <div className={classes.card}>
<CollectionPanelFiles isWritable={isWritable} />
</div>
</>