Commit 8fcafe0e authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Add tests for sharing and managing items in team drives.

Bug: 903637
Change-Id: Ic9f49f7de59210e400a578060eb611fafebe193f
Reviewed-on: https://chromium-review.googlesource.com/c/1341287
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609191}
parent 0014b454
...@@ -544,12 +544,19 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -544,12 +544,19 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("shareFileDrive").EnableDriveFs(), TestCase("shareFileDrive").EnableDriveFs(),
TestCase("shareDirectoryDrive").DisableDriveFs(), TestCase("shareDirectoryDrive").DisableDriveFs(),
TestCase("shareDirectoryDrive").EnableDriveFs(), TestCase("shareDirectoryDrive").EnableDriveFs(),
TestCase("shareHostedFileDrive"),
TestCase("manageHostedFileDrive").DisableDriveFs(), TestCase("manageHostedFileDrive").DisableDriveFs(),
TestCase("manageHostedFileDrive").EnableDriveFs(), TestCase("manageHostedFileDrive").EnableDriveFs(),
TestCase("manageFileDrive").DisableDriveFs(), TestCase("manageFileDrive").DisableDriveFs(),
TestCase("manageFileDrive").EnableDriveFs(), TestCase("manageFileDrive").EnableDriveFs(),
TestCase("manageDirectoryDrive").DisableDriveFs(), TestCase("manageDirectoryDrive").DisableDriveFs(),
TestCase("manageDirectoryDrive").EnableDriveFs())); TestCase("manageDirectoryDrive").EnableDriveFs(),
TestCase("shareFileTeamDrive"),
TestCase("shareDirectoryTeamDrive"),
TestCase("shareHostedFileTeamDrive"),
TestCase("manageHostedFileTeamDrive"),
TestCase("manageFileTeamDrive"),
TestCase("manageDirectoryTeamDrive")));
WRAPPED_INSTANTIATE_TEST_CASE_P( WRAPPED_INSTANTIATE_TEST_CASE_P(
SuggestAppDialog, /* suggest_app_dialog.js */ SuggestAppDialog, /* suggest_app_dialog.js */
......
...@@ -91,6 +91,7 @@ test.util.sync.getFileList = function(contentWindow) { ...@@ -91,6 +91,7 @@ test.util.sync.getFileList = function(contentWindow) {
*/ */
test.util.sync.selectFile = function(contentWindow, filename) { test.util.sync.selectFile = function(contentWindow, filename) {
var rows = contentWindow.document.querySelectorAll('#detail-table li'); var rows = contentWindow.document.querySelectorAll('#detail-table li');
test.util.sync.focus(contentWindow, '#file-list');
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#file-list', 'Home', false, false, false); contentWindow, '#file-list', 'Home', false, false, false);
for (var index = 0; index < rows.length; ++index) { for (var index = 0; index < rows.length; ++index) {
......
...@@ -246,6 +246,7 @@ var TEAM_DRIVE_ENTRY_SET = [ ...@@ -246,6 +246,7 @@ var TEAM_DRIVE_ENTRY_SET = [
ENTRIES.hello, ENTRIES.hello,
ENTRIES.teamDriveA, ENTRIES.teamDriveA,
ENTRIES.teamDriveAFile, ENTRIES.teamDriveAFile,
ENTRIES.teamDriveADirectory,
ENTRIES.teamDriveAHostedFile, ENTRIES.teamDriveAHostedFile,
ENTRIES.teamDriveB, ENTRIES.teamDriveB,
ENTRIES.teamDriveBFile, ENTRIES.teamDriveBFile,
......
...@@ -9,19 +9,32 @@ ...@@ -9,19 +9,32 @@
* *
* @param {!string} path Path of the file or directory to be shared. * @param {!string} path Path of the file or directory to be shared.
* @param {!string} url Expected URL for the browser to visit. * @param {!string} url Expected URL for the browser to visit.
* @param {!string|undefined} teamDrive If set, the team drive to switch to.
*/ */
function shareWithOthersExpectBrowserURL(path, url) { function shareWithOthersExpectBrowserURL(path, url, teamDrive = undefined) {
let appId; let appId;
StepsRunner.run([ StepsRunner.run([
// Open Files app on Drive. // Open Files app on Drive.
function() { function() {
setupAndWaitUntilReady( setupAndWaitUntilReady(
null, RootPath.DRIVE, this.next, [], BASIC_DRIVE_ENTRY_SET); null, RootPath.DRIVE, this.next, [],
BASIC_DRIVE_ENTRY_SET.concat(TEAM_DRIVE_ENTRY_SET));
}, },
// Select the given |path|. // Navigate to the specified team drive if one is specified.
function(results) { function(results) {
appId = results.windowId; appId = results.windowId;
if (!teamDrive) {
this.next();
return;
}
remoteCall
.navigateWithDirectoryTree(
appId, `/team_drives/${teamDrive}`, 'Team Drives', 'drive')
.then(this.next);
},
// Select the given |path|.
function() {
remoteCall.callRemoteTestUtil('selectFile', appId, [path], this.next); remoteCall.callRemoteTestUtil('selectFile', appId, [path], this.next);
}, },
// Wait for the entry to be selected. // Wait for the entry to be selected.
...@@ -80,19 +93,32 @@ function shareWithOthersExpectBrowserURL(path, url) { ...@@ -80,19 +93,32 @@ function shareWithOthersExpectBrowserURL(path, url) {
* *
* @param {!string} path Path of the file or directory to be managed. * @param {!string} path Path of the file or directory to be managed.
* @param {!string} url Expected URL for the browser to visit. * @param {!string} url Expected URL for the browser to visit.
* @param {!string|undefined} teamDrive If set, the team drive to switch to.
*/ */
function manageWithDriveExpectBrowserURL(path, url) { function manageWithDriveExpectBrowserURL(path, url, teamDrive = undefined) {
let appId; let appId;
StepsRunner.run([ StepsRunner.run([
// Open Files app on Drive. // Open Files app on Drive.
function() { function() {
setupAndWaitUntilReady( setupAndWaitUntilReady(
null, RootPath.DRIVE, this.next, [], BASIC_DRIVE_ENTRY_SET); null, RootPath.DRIVE, this.next, [],
BASIC_DRIVE_ENTRY_SET.concat(TEAM_DRIVE_ENTRY_SET));
}, },
// Select the given |path|. // Navigate to the specified team drive if one is specified.
function(results) { function(results) {
appId = results.windowId; appId = results.windowId;
if (!teamDrive) {
this.next();
return;
}
remoteCall
.navigateWithDirectoryTree(
appId, `/team_drives/${teamDrive}`, 'Team Drives', 'drive')
.then(this.next);
},
// Select the given |path|.
function() {
remoteCall.callRemoteTestUtil('selectFile', appId, [path], this.next); remoteCall.callRemoteTestUtil('selectFile', appId, [path], this.next);
}, },
// Wait for the entry to be selected. // Wait for the entry to be selected.
...@@ -167,6 +193,15 @@ testcase.shareDirectoryDrive = function() { ...@@ -167,6 +193,15 @@ testcase.shareDirectoryDrive = function() {
shareWithOthersExpectBrowserURL('photos', URL); shareWithOthersExpectBrowserURL('photos', URL);
}; };
/**
* Tests sharing a hosted file (gdoc) on Drive.
*/
testcase.shareHostedFileDrive = function() {
const URL =
'https://document_alternate_link/Test%20Document?userstoinvite=%22%22';
shareWithOthersExpectBrowserURL('Test Document.gdoc', URL);
};
/** /**
* Tests managing a file on Drive. * Tests managing a file on Drive.
*/ */
...@@ -191,4 +226,103 @@ testcase.manageHostedFileDrive = function() { ...@@ -191,4 +226,103 @@ testcase.manageHostedFileDrive = function() {
manageWithDriveExpectBrowserURL('Test Document.gdoc', URL); manageWithDriveExpectBrowserURL('Test Document.gdoc', URL);
}; };
// TODO(903637): Add tests for sharing a file on Team Drives. /**
* Tests sharing a file in a team drive.
*/
testcase.shareFileTeamDrive = function() {
const URL =
'https://file_alternate_link/teamDriveAFile.txt?userstoinvite=%22%22';
shareWithOthersExpectBrowserURL('teamDriveAFile.txt', URL, 'Team Drive A');
};
/**
* Tests that sharing a directory in a team drive is not allowed.
*/
testcase.shareDirectoryTeamDrive = function() {
let appId;
const teamDrive = 'Team Drive A';
const path = 'teamDriveADirectory';
StepsRunner.run([
// Open Files app on Drive.
function() {
setupAndWaitUntilReady(
null, RootPath.DRIVE, this.next, [],
BASIC_DRIVE_ENTRY_SET.concat(TEAM_DRIVE_ENTRY_SET));
},
// Navigate to the team drive.
function(results) {
appId = results.windowId;
remoteCall
.navigateWithDirectoryTree(
appId, `/team_drives/${teamDrive}`, 'Team Drives', 'drive')
.then(this.next);
},
// Select the given |path|.
function() {
remoteCall.callRemoteTestUtil('selectFile', appId, [path], this.next);
},
// Wait for the entry to be selected.
function(result) {
chrome.test.assertTrue(!!result, 'selectFile failed');
remoteCall.waitForElement(appId, '.table-row[selected]').then(this.next);
},
// Right-click the selected entry.
function(result) {
chrome.test.assertTrue(!!result);
remoteCall.callRemoteTestUtil(
'fakeMouseRightClick', appId, ['.table-row[selected]'], this.next);
},
// Wait for the context menu to appear.
function(result) {
chrome.test.assertTrue(!!result, 'fakeMouseClick failed');
remoteCall.waitForElement(appId, '#file-context-menu:not([hidden])')
.then(this.next);
},
// Wait for the "Share" menu item to appear.
function(result) {
chrome.test.assertTrue(!!result);
remoteCall
.waitForElement(appId, '[command="#share"]:not([hidden])[disabled]')
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
}
]);
};
/**
* Tests sharing a hosted file (gdoc) in a team drive.
*/
testcase.shareHostedFileTeamDrive = function() {
const URL =
'https://document_alternate_link/teamDriveAHostedDoc?userstoinvite=%22%22';
shareWithOthersExpectBrowserURL(
'teamDriveAHostedDoc.gdoc', URL, 'Team Drive A');
};
/**
* Tests managing a file in a team drive.
*/
testcase.manageFileTeamDrive = function() {
const URL = 'https://file_alternate_link/teamDriveAFile.txt';
manageWithDriveExpectBrowserURL('teamDriveAFile.txt', URL, 'Team Drive A');
};
/**
* Tests managing a directory in a team drive.
*/
testcase.manageDirectoryTeamDrive = function() {
const URL = 'https://folder_alternate_link/teamDriveADirectory';
manageWithDriveExpectBrowserURL('teamDriveADirectory', URL, 'Team Drive A');
};
/**
* Tests managing a hosted file (gdoc) in a team drive.
*/
testcase.manageHostedFileTeamDrive = function() {
const URL = 'https://document_alternate_link/teamDriveAHostedDoc';
manageWithDriveExpectBrowserURL(
'teamDriveAHostedDoc.gdoc', URL, 'Team Drive A');
};
...@@ -758,6 +758,23 @@ var ENTRIES = { ...@@ -758,6 +758,23 @@ var ENTRIES = {
}, },
}), }),
teamDriveADirectory: new TestEntryInfo({
type: EntryType.DIRECTORY,
targetPath: 'teamDriveADirectory',
lastModifiedTime: 'Jan 1, 2000, 1:00 AM',
nameText: 'teamDriveADirectory',
sizeText: '--',
typeText: 'Folder',
teamDriveName: 'Team Drive A',
capabilities: {
canCopy: true,
canDelete: true,
canRename: true,
canAddChildren: true,
canShare: false,
},
}),
teamDriveAHostedFile: new TestEntryInfo({ teamDriveAHostedFile: new TestEntryInfo({
type: EntryType.FILE, type: EntryType.FILE,
targetPath: 'teamDriveAHostedDoc', targetPath: 'teamDriveAHostedDoc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment