Commit 042d3094 authored by Gordon Seto's avatar Gordon Seto Committed by Commit Bot

[CrOS Settings] Install single discovered eSIM profile

Add new tests for each profile install result

Bug: 1093185
Change-Id: Ie15c3b7eb78aa69a791bd05e07b0b68594636d19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2547841
Commit-Queue: Gordon Seto <gordonseto@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830270}
parent 1c8c8696
......@@ -77,7 +77,7 @@ suite('CrComponentsEsimFlowUiTest', function() {
eSimPage.selectedESimPageName_ === finalPage.id);
});
test('Single eSIM profile flow', async function() {
test('Single eSIM profile flow successful install', async function() {
eSimManagerRemote.addEuiccForTest(1);
const profileLoadingPage = eSimPage.$$('#profileLoadingPage');
......@@ -98,6 +98,35 @@ suite('CrComponentsEsimFlowUiTest', function() {
assertTrue(
eSimPage.selectedESimPageName_ === cellular_setup.ESimPageName.FINAL &&
eSimPage.selectedESimPageName_ === finalPage.id);
assertFalse(!!finalPage.$$('.error'));
});
test('Single eSIM profile flow unsuccessful install', async function() {
eSimManagerRemote.addEuiccForTest(1);
const availableEuiccs = await eSimManagerRemote.getAvailableEuiccs();
const profileList = await availableEuiccs.euiccs[0].getProfileList();
profileList.profiles[0].setProfileInstallResultForTest(
chromeos.cellularSetup.mojom.ProfileInstallResult.kFailure);
const profileLoadingPage = eSimPage.$$('#profileLoadingPage');
const finalPage = eSimPage.$$('#finalPage');
assertTrue(!!profileLoadingPage);
assertTrue(!!finalPage);
// Loading page should be showing.
assertTrue(
eSimPage.selectedESimPageName_ ===
cellular_setup.ESimPageName.PROFILE_LOADING &&
eSimPage.selectedESimPageName_ === profileLoadingPage.id);
await flushAsync();
// Should go directly to final page.
assertTrue(
eSimPage.selectedESimPageName_ === cellular_setup.ESimPageName.FINAL &&
eSimPage.selectedESimPageName_ === finalPage.id);
assertTrue(!!finalPage.$$('.error'));
});
test('Multiple eSIM profiles skip discovery flow', async function() {
......
......@@ -24,12 +24,31 @@ cr.define('cellular_setup', function() {
* chromeos.cellularSetup.mojom.ESimProfileProperties},}>}
*/
getProperties() {
return new Promise((res) => {
res({
properties: this.properties_,
});
return Promise.resolve({
properties: this.properties_,
});
}
/**
* @override
* @param {string} confirmationCode
* @return {!Promise<{result:
* chromeos.cellularSetup.mojom.ProfileInstallResult},}>}
*/
installProfile(confirmationCode) {
return Promise.resolve({
result: this.profileInstallResult_ ?
this.profileInstallResult_ :
chromeos.cellularSetup.mojom.ProfileInstallResult.kSuccess
});
}
/**
* @param {chromeos.cellularSetup.mojom.ProfileInstallResult} result
*/
setProfileInstallResultForTest(result) {
this.profileInstallResult_ = result;
}
}
/** @implements {chromeos.cellularSetup.mojom.Euicc} */
......@@ -47,10 +66,8 @@ cr.define('cellular_setup', function() {
* chromeos.cellularSetup.mojom.ESimOperationResult},}>}
*/
requestPendingProfiles() {
return new Promise((res) => {
res({
result: chromeos.cellularSetup.mojom.ESimOperationResult.kSuccess
});
return Promise.resolve({
result: chromeos.cellularSetup.mojom.ESimOperationResult.kSuccess,
});
}
......@@ -59,10 +76,8 @@ cr.define('cellular_setup', function() {
* @return {!Promise<{profiles: Array<!ESimProfile>,}>}
*/
getProfileList() {
return new Promise((res) => {
res({
profiles: this.profiles_,
});
return Promise.resolve({
profiles: this.profiles_,
});
}
......@@ -84,8 +99,8 @@ cr.define('cellular_setup', function() {
* @return {!Promise<{euiccs: !Array<!Euicc>,}>}
*/
getAvailableEuiccs() {
return new Promise((res) => {
res({euiccs: this.euiccs_});
return Promise.resolve({
euiccs: this.euiccs_,
});
}
......
......@@ -16,8 +16,7 @@ cr.define('cellular_setup', function() {
PROFILE_SEARCH: 'profile-search',
ACTIVATION_CODE_ENTRY: 'activation-code-entry',
MULTI_PROFILE_SELECTION: 'multi-profile-selection',
SETUP_SUCCESS: 'setup-success',
SETUP_FAILURE: 'setup-failure',
SETUP_FINISH: 'setup-finish',
};
/**
......@@ -124,10 +123,10 @@ cr.define('cellular_setup', function() {
this.state_ = ESimUiState.ACTIVATION_CODE_ENTRY;
break;
case 1:
// TODO(crbug.com/1093185) Install the
// profile. Handle error state. Handle
// confirmation code if needed.
this.state_ = ESimUiState.SETUP_SUCCESS;
// Assume installing the profile doesn't require a confirmation
// code, send an empty string.
profiles[0].installProfile('').then(
this.handleProfileInstallResponse_.bind(this));
break;
default:
// TODO(crbug.com/1093185) Populate the profile discovery with
......@@ -160,6 +159,19 @@ cr.define('cellular_setup', function() {
});
},
/**
* @private
* @param {{result: chromeos.cellularSetup.mojom.ProfileInstallResult}}
* response
*/
handleProfileInstallResponse_(response) {
// TODO(crbug.com/1093185) Handle
// confirmation code if needed.
this.showError_ = response.result !==
chromeos.cellularSetup.mojom.ProfileInstallResult.kSuccess;
this.state_ = ESimUiState.SETUP_FINISH;
},
/** @private */
updateSelectedPage_() {
switch (this.state_) {
......@@ -172,7 +184,7 @@ cr.define('cellular_setup', function() {
case ESimUiState.MULTI_PROFILE_SELECTION:
this.selectedESimPageName_ = ESimPageName.PROFILE_DISCOVERY;
break;
case ESimUiState.SETUP_SUCCESS:
case ESimUiState.SETUP_FINISH:
this.selectedESimPageName_ = ESimPageName.FINAL;
break;
default:
......@@ -210,7 +222,7 @@ cr.define('cellular_setup', function() {
skipDiscovery: cellularSetup.ButtonState.SHOWN_AND_ENABLED,
};
break;
case ESimUiState.SETUP_SUCCESS:
case ESimUiState.SETUP_FINISH:
buttonState = {
backward: cellularSetup.ButtonState.HIDDEN,
cancel: cellularSetup.ButtonState.HIDDEN,
......@@ -258,7 +270,7 @@ cr.define('cellular_setup', function() {
case ESimUiState.ACTIVATION_CODE_ENTRY:
// TODO(crbug.com/1093185) Install the profile. Handle error state.
// Handle confirmation code if needed.
this.state_ = ESimUiState.SETUP_SUCCESS;
this.state_ = ESimUiState.SETUP_FINISH;
break;
case ESimUiState.MULTI_PROFILE_SELECTION:
this.state_ = ESimUiState.ACTIVATION_CODE_ENTRY;
......
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