[Files app] Support for hardening pooled storage tast
The pooled storage tast test currently relies on
hardcoded i18n strings. Add ARIA roles and special
classes so the tast test can rely on a more stable
UI selector.
Test: Manual && crrev.com/c/3875645
Bug: 1355708
Change-Id: I1c6745996221600bd0af74c5483102e8968d2e2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3875623
Reviewed-by: Ben Reich <benreich@chromium.org>
Commit-Queue: Marcello Salomao <msalomao@google.com>
Cr-Commit-Position: refs/heads/main@{#1044905}
diff --git a/ui/file_manager/file_manager/foreground/js/ui/banners/drive_low_individual_space_banner.html b/ui/file_manager/file_manager/foreground/js/ui/banners/drive_low_individual_space_banner.html
index 423e7ca..1ca6317 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/banners/drive_low_individual_space_banner.html
+++ b/ui/file_manager/file_manager/foreground/js/ui/banners/drive_low_individual_space_banner.html
@@ -1,4 +1,4 @@
-<warning-banner>
+<warning-banner role="banner" class="tast-drive-low-individual-space">
<span slot="text"></span>
<cr-button slot="extra-button" href="$i18n{GOOGLE_DRIVE_MANAGE_STORAGE_URL}">
$i18n{LEARN_MORE_LABEL}
diff --git a/ui/file_manager/file_manager/foreground/js/ui/banners/drive_out_of_individual_space_banner.html b/ui/file_manager/file_manager/foreground/js/ui/banners/drive_out_of_individual_space_banner.html
index 2a0b813..69a7b3c 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/banners/drive_out_of_individual_space_banner.html
+++ b/ui/file_manager/file_manager/foreground/js/ui/banners/drive_out_of_individual_space_banner.html
@@ -3,7 +3,7 @@
--icon-src: url(/foreground/images/files/ui/error_banner_icon.svg);
}
</style>
-<warning-banner>
+<warning-banner role="banner" class="tast-drive-out-of-individual-space">
<span slot="text" aria-label="$i18n{DRIVE_WARNING_QUOTA_OVER}: $i18n{DRIVE_INDIVIDUAL_QUOTA_OVER}">
<span aria-hidden="true">
$i18n{DRIVE_INDIVIDUAL_QUOTA_OVER}
diff --git a/ui/file_manager/file_manager/foreground/js/ui/banners/drive_out_of_organization_space_banner.html b/ui/file_manager/file_manager/foreground/js/ui/banners/drive_out_of_organization_space_banner.html
index ef7f702..31f1b68 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/banners/drive_out_of_organization_space_banner.html
+++ b/ui/file_manager/file_manager/foreground/js/ui/banners/drive_out_of_organization_space_banner.html
@@ -3,7 +3,7 @@
--icon-src: url(/foreground/images/files/ui/error_banner_icon.svg);
}
</style>
-<warning-banner>
+<warning-banner role="banner" class="tast-drive-out-of-organization-space">
<span slot="text"></span>
<cr-button slot="extra-button" href="$i18n{GOOGLE_DRIVE_MANAGE_STORAGE_URL}">
$i18n{LEARN_MORE_LABEL}
diff --git a/ui/file_manager/file_manager/foreground/js/ui/gear_menu.js b/ui/file_manager/file_manager/foreground/js/ui/gear_menu.js
index bb683a8..d4b5f736 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/gear_menu.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/gear_menu.js
@@ -8,6 +8,11 @@
import {str, strf, util} from '../../../common/js/util.js';
/**
+ * Selector used by tast tests to identify when the storage meter is empty.
+ */
+const tastEmptySpaceId = 'tast-storage-meter-empty';
+
+/**
* @typedef {{totalSize: number, usedSize: number, warningMessage: string}}
*/
export let SpaceInfo;
@@ -119,6 +124,8 @@
this.volumeSpaceInnerBar_.style.width = '100%';
}
+ this.volumeSpaceInfo.classList.remove(tastEmptySpaceId);
+
spaceInfoPromise.then(
spaceInfo => {
if (this.spaceInfoPromise_ != spaceInfoPromise) {
@@ -134,17 +141,22 @@
return;
}
+ const remainingSize = spaceInfo.totalSize - spaceInfo.usedSize;
+
if (spaceInfo.totalSize >= 0) {
- const usedSpace = spaceInfo.usedSize;
+ if (remainingSize <= 0) {
+ this.volumeSpaceInfo.classList.add(tastEmptySpaceId);
+ }
+
this.volumeSpaceInnerBar_.style.width =
- Math.min(100, 100 * usedSpace / spaceInfo.totalSize) + '%';
+ Math.min(100, 100 * spaceInfo.usedSize / spaceInfo.totalSize) +
+ '%';
this.volumeSpaceOuterBar_.hidden = false;
this.volumeSpaceInfoLabel_.textContent = strf(
'SPACE_AVAILABLE',
- util.bytesToString(
- Math.max(0, spaceInfo.totalSize - spaceInfo.usedSize)));
+ util.bytesToString(Math.max(0, remainingSize)));
} else {
// User has unlimited individual storage.
this.volumeSpaceInfoLabel_.textContent =