Skip to content

Commit

Permalink
fix(cypress): formatFileSize change revert from files library
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Nov 8, 2023
1 parent 50417bc commit 32c1aeb
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 66 deletions.
36 changes: 17 additions & 19 deletions apps/files/src/components/FileEntry/FileEntryActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,23 @@
:open.sync="openedMenu"
@close="openedSubmenu = null">
<!-- Default actions list-->
<template>
<NcActionButton v-for="action in enabledMenuActions"
:key="action.id"
:class="{
[`files-list__row-action-${action.id}`]: true,
[`files-list__row-action--menu`]: isMenu(action.id)
}"
:close-after-click="!isMenu(action.id)"
:data-cy-files-list-row-action="action.id"
:is-menu="isMenu(action.id)"
:title="action.title?.([source], currentView)"
@click="onActionClick(action)">
<template #icon>
<NcLoadingIcon v-if="loading === action.id" :size="18" />
<NcIconSvgWrapper v-else :svg="action.iconSvgInline([source], currentView)" />
</template>
{{ actionDisplayName(action) }}
</NcActionButton>
</template>
<NcActionButton v-for="action in enabledMenuActions"
:key="action.id"
:class="{
[`files-list__row-action-${action.id}`]: true,
[`files-list__row-action--menu`]: isMenu(action.id)
}"
:close-after-click="!isMenu(action.id)"
:data-cy-files-list-row-action="action.id"
:is-menu="isMenu(action.id)"
:title="action.title?.([source], currentView)"
@click="onActionClick(action)">
<template #icon>
<NcLoadingIcon v-if="loading === action.id" :size="18" />
<NcIconSvgWrapper v-else :svg="action.iconSvgInline([source], currentView)" />
</template>
{{ actionDisplayName(action) }}
</NcActionButton>
<!-- Submenu actions list-->
<template v-if="openedSubmenu && enabledSubmenuActions[openedSubmenu?.id]">
Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/components/NavigationQuota.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default {
computed: {
storageStatsTitle() {
const usedQuotaByte = formatFileSize(this.storageStats?.used, false, false)
const quotaByte = formatFileSize(this.storageStats?.quota, false, false)
const usedQuotaByte = formatFileSize(this.storageStats?.used, false, false, true)
const quotaByte = formatFileSize(this.storageStats?.quota, false, false, true)
// If no quota set
if (this.storageStats?.quota < 0) {
Expand Down
6 changes: 3 additions & 3 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.find('.fileinfo').text()).toEqual('2 files');
expect($summary.find('.dirinfo').hasClass('hidden')).toEqual(false);
expect($summary.find('.fileinfo').hasClass('hidden')).toEqual(false);
expect($summary.find('.filesize').text()).toEqual('70 KB');
expect($summary.find('.filesize').text()).toEqual('69 KB');
expect(fileList.isEmpty).toEqual(false);
});
it('Shows empty content when removing last file', function() {
Expand Down Expand Up @@ -609,7 +609,7 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.find('.fileinfo').text()).toEqual('1 file');
expect($summary.find('.dirinfo').hasClass('hidden')).toEqual(false);
expect($summary.find('.fileinfo').hasClass('hidden')).toEqual(false);
expect($summary.find('.filesize').text()).toEqual('58 KB');
expect($summary.find('.filesize').text()).toEqual('57 KB');
expect(fileList.isEmpty).toEqual(false);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(false);
expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(true);
Expand Down Expand Up @@ -1138,7 +1138,7 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.hasClass('hidden')).toEqual(false);
expect($summary.find('.dirinfo').text()).toEqual('1 folder');
expect($summary.find('.fileinfo').text()).toEqual('3 files');
expect($summary.find('.filesize').text()).toEqual('70 KB');
expect($summary.find('.filesize').text()).toEqual('69 KB');
});
it('shows headers, summary and hide empty content message after setting files', function(){
fileList.setFiles(testFiles);
Expand Down
18 changes: 9 additions & 9 deletions apps/files/tests/js/filesummarySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.hasClass('hidden')).toEqual(false);
expect($container.find('.dirinfo').text()).toEqual('5 folders');
expect($container.find('.fileinfo').text()).toEqual('2 files');
expect($container.find('.filesize').text()).toEqual('256 KB');
expect($container.find('.filesize').text()).toEqual('250 KB');
});
it('hides summary when no files or folders', function() {
var s = new FileSummary($container);
Expand All @@ -68,7 +68,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.hasClass('hidden')).toEqual(false);
expect($container.find('.dirinfo').text()).toEqual('6 folders');
expect($container.find('.fileinfo').text()).toEqual('3 files');
expect($container.find('.filesize').text()).toEqual('512 KB');
expect($container.find('.filesize').text()).toEqual('500 KB');
expect(s.summary.totalDirs).toEqual(6);
expect(s.summary.totalFiles).toEqual(3);
expect(s.summary.totalSize).toEqual(512100);
Expand All @@ -86,7 +86,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.hasClass('hidden')).toEqual(false);
expect($container.find('.dirinfo').text()).toEqual('4 folders');
expect($container.find('.fileinfo').text()).toEqual('1 file');
expect($container.find('.filesize').text()).toEqual('128 KB');
expect($container.find('.filesize').text()).toEqual('125 KB');
expect(s.summary.totalDirs).toEqual(4);
expect(s.summary.totalFiles).toEqual(1);
expect(s.summary.totalSize).toEqual(127900);
Expand All @@ -104,7 +104,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.dirinfo').text()).toEqual('5 folders');
expect($container.find('.fileinfo').text()).toEqual('2 files');
expect($container.find('.filter').text()).toEqual(' match "foo"');
expect($container.find('.filesize').text()).toEqual('256 KB');
expect($container.find('.filesize').text()).toEqual('250 KB');
});
it('hides filtered summary when no files or folders', function() {
var s = new FileSummary($container);
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.dirinfo').text()).toEqual('6 folders');
expect($container.find('.fileinfo').text()).toEqual('3 files');
expect($container.find('.filter').text()).toEqual(' match "foo"');
expect($container.find('.filesize').text()).toEqual('512 KB');
expect($container.find('.filesize').text()).toEqual('500 KB');
expect(s.summary.totalDirs).toEqual(6);
expect(s.summary.totalFiles).toEqual(3);
expect(s.summary.totalSize).toEqual(512103);
Expand All @@ -155,7 +155,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.dirinfo').text()).toEqual('4 folders');
expect($container.find('.fileinfo').text()).toEqual('1 file');
expect($container.find('.filter').text()).toEqual(' match "foo"');
expect($container.find('.filesize').text()).toEqual('128 KB');
expect($container.find('.filesize').text()).toEqual('125 KB');
expect(s.summary.totalDirs).toEqual(4);
expect(s.summary.totalFiles).toEqual(1);
expect(s.summary.totalSize).toEqual(127903);
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.fileinfo').text()).toEqual('1 file');
expect($container.find('.hiddeninfo').hasClass('hidden')).toEqual(false);
expect($container.find('.hiddeninfo').text()).toEqual(' (including 1 hidden)');
expect($container.find('.filesize').text()).toEqual('768 KB');
expect($container.find('.filesize').text()).toEqual('750 KB');
});
it('does not render hidden count section when hidden files exist but are visible', function() {
window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: true });
Expand All @@ -228,7 +228,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.dirinfo').text()).toEqual('2 folders');
expect($container.find('.fileinfo').text()).toEqual('1 file');
expect($container.find('.hiddeninfo').hasClass('hidden')).toEqual(true);
expect($container.find('.filesize').text()).toEqual('768 KB');
expect($container.find('.filesize').text()).toEqual('750 KB');
});
it('does not render hidden count section when no hidden files exist', function() {
window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false });
Expand All @@ -240,7 +240,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.dirinfo').text()).toEqual('1 folder');
expect($container.find('.fileinfo').text()).toEqual('1 file');
expect($container.find('.hiddeninfo').hasClass('hidden')).toEqual(true);
expect($container.find('.filesize').text()).toEqual('256 KB');
expect($container.find('.filesize').text()).toEqual('250 KB');
});
});
});
2 changes: 1 addition & 1 deletion apps/files/tests/js/mainfileinfodetailviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
view.setFileInfo(testFileInfo);
expect(view.$el.find('.fileName h3').text()).toEqual('One.txt');
expect(view.$el.find('.fileName h3').attr('title')).toEqual('One.txt');
expect(view.$el.find('.size').text()).toEqual('123.5 MB');
expect(view.$el.find('.size').text()).toEqual('117.7 MB');
expect(view.$el.find('.size').attr('title')).toEqual('123456789 bytes');
expect(view.$el.find('.date').text()).toEqual('seconds ago');
expect(view.$el.find('.date').attr('title')).toEqual(dateExpected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
*/
// TODO: remove when/if the actions API supports a separator
// This the last preset action, so we need to add a separator
.files-list__row-action-set-reminder-3 {
margin-bottom: 13px;
.files-list__row-action-set-reminder-custom {
margin-top: 13px;
position: relative;

&::after {
&::before {
content: "";
margin: 3px 10px 3px 15px;
border-bottom: 1px solid var(--color-border-dark);
Expand All @@ -34,5 +35,6 @@
position: absolute;
left: 0;
right: 0;
top: -10px;
}
}
18 changes: 14 additions & 4 deletions apps/files_reminders/src/actions/setReminderSuggestionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,21 @@ const nextWeek: ReminderOption = {
ariaLabel: t('files_reminders', 'Set reminder for next week'),
}

// Generate the default preset actions
export const actions = [laterToday, tomorrow, thisWeekend, nextWeek].map((option): FileAction|null => {
/**
* Generate a file action for the given option
*
* @param option The option to generate the action for
* @return The file action or null if the option should not be shown
*/
const generateFileAction = (option): FileAction|null => {
const dateTime = getDateTime(option.dateTimePreset)
if (!dateTime) {
return null
}

return new FileAction({
id: `set-reminder-${option.dateTimePreset}`,
displayName: () => `${option.label} - ${getDateString(dateTime)}`,
displayName: () => `${option.label} ${getDateString(dateTime)}`,
title: () => `${option.ariaLabel}${getVerboseDateString(dateTime)}`,

// Empty svg to hide the icon
Expand Down Expand Up @@ -103,4 +108,9 @@ export const actions = [laterToday, tomorrow, thisWeekend, nextWeek].map((option

order: 21,
})
}).filter(Boolean) as FileAction[]
}

// Generate the default preset actions
export const actions = [laterToday, tomorrow, thisWeekend, nextWeek]
.map(generateFileAction)
.filter(Boolean) as FileAction[]
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ export default Vue.extend({
},
async setCustom(): Promise<void> {
// Handle input cleared
if (this.customDueDate === '') {
// Handle input cleared or invalid date
if (!(this.customDueDate instanceof Date) || isNaN(this.customDueDate)) {
showError(t('files_reminders', 'Please choose a valid date & time'))
return
}
Expand Down
2 changes: 0 additions & 2 deletions apps/files_reminders/src/services/customPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ const CustomReminderModal = new View({
})

export const pickCustomDate = async (node: Node): Promise<void> => {
console.debug('CustomReminderModal', mount, CustomReminderModal)

CustomReminderModal.open(node)

// Wait for the modal to close
Expand Down
8 changes: 4 additions & 4 deletions apps/files_reminders/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import moment from '@nextcloud/moment'
import { getCanonicalLocale } from '@nextcloud/l10n'

export enum DateTimePreset {
LaterToday,
Tomorrow,
ThisWeekend,
NextWeek,
LaterToday = 'later-today',
Tomorrow = 'tomorrow',
ThisWeekend = 'this-weekend',
NextWeek = 'next-week',
}

export const getDateTime = (dateTime: DateTimePreset): null | Date => {
Expand Down
4 changes: 2 additions & 2 deletions dist/dav-settings-personal-availability.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dist/dav-settings-personal-availability.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
*
Expand Down
2 changes: 1 addition & 1 deletion dist/dav-settings-personal-availability.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_reminders-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_reminders-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-init.js.map

Large diffs are not rendered by default.

0 comments on commit 32c1aeb

Please sign in to comment.