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() { ...@@ -77,7 +77,7 @@ suite('CrComponentsEsimFlowUiTest', function() {
eSimPage.selectedESimPageName_ === finalPage.id); eSimPage.selectedESimPageName_ === finalPage.id);
}); });
test('Single eSIM profile flow', async function() { test('Single eSIM profile flow successful install', async function() {
eSimManagerRemote.addEuiccForTest(1); eSimManagerRemote.addEuiccForTest(1);
const profileLoadingPage = eSimPage.$$('#profileLoadingPage'); const profileLoadingPage = eSimPage.$$('#profileLoadingPage');
...@@ -98,6 +98,35 @@ suite('CrComponentsEsimFlowUiTest', function() { ...@@ -98,6 +98,35 @@ suite('CrComponentsEsimFlowUiTest', function() {
assertTrue( assertTrue(
eSimPage.selectedESimPageName_ === cellular_setup.ESimPageName.FINAL && eSimPage.selectedESimPageName_ === cellular_setup.ESimPageName.FINAL &&
eSimPage.selectedESimPageName_ === finalPage.id); 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() { test('Multiple eSIM profiles skip discovery flow', async function() {
......
...@@ -24,12 +24,31 @@ cr.define('cellular_setup', function() { ...@@ -24,12 +24,31 @@ cr.define('cellular_setup', function() {
* chromeos.cellularSetup.mojom.ESimProfileProperties},}>} * chromeos.cellularSetup.mojom.ESimProfileProperties},}>}
*/ */
getProperties() { getProperties() {
return new Promise((res) => { return Promise.resolve({
res({
properties: this.properties_, 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} */ /** @implements {chromeos.cellularSetup.mojom.Euicc} */
...@@ -47,10 +66,8 @@ cr.define('cellular_setup', function() { ...@@ -47,10 +66,8 @@ cr.define('cellular_setup', function() {
* chromeos.cellularSetup.mojom.ESimOperationResult},}>} * chromeos.cellularSetup.mojom.ESimOperationResult},}>}
*/ */
requestPendingProfiles() { requestPendingProfiles() {
return new Promise((res) => { return Promise.resolve({
res({ result: chromeos.cellularSetup.mojom.ESimOperationResult.kSuccess,
result: chromeos.cellularSetup.mojom.ESimOperationResult.kSuccess
});
}); });
} }
...@@ -59,11 +76,9 @@ cr.define('cellular_setup', function() { ...@@ -59,11 +76,9 @@ cr.define('cellular_setup', function() {
* @return {!Promise<{profiles: Array<!ESimProfile>,}>} * @return {!Promise<{profiles: Array<!ESimProfile>,}>}
*/ */
getProfileList() { getProfileList() {
return new Promise((res) => { return Promise.resolve({
res({
profiles: this.profiles_, profiles: this.profiles_,
}); });
});
} }
/** @private */ /** @private */
...@@ -84,8 +99,8 @@ cr.define('cellular_setup', function() { ...@@ -84,8 +99,8 @@ cr.define('cellular_setup', function() {
* @return {!Promise<{euiccs: !Array<!Euicc>,}>} * @return {!Promise<{euiccs: !Array<!Euicc>,}>}
*/ */
getAvailableEuiccs() { getAvailableEuiccs() {
return new Promise((res) => { return Promise.resolve({
res({euiccs: this.euiccs_}); euiccs: this.euiccs_,
}); });
} }
......
...@@ -16,8 +16,7 @@ cr.define('cellular_setup', function() { ...@@ -16,8 +16,7 @@ cr.define('cellular_setup', function() {
PROFILE_SEARCH: 'profile-search', PROFILE_SEARCH: 'profile-search',
ACTIVATION_CODE_ENTRY: 'activation-code-entry', ACTIVATION_CODE_ENTRY: 'activation-code-entry',
MULTI_PROFILE_SELECTION: 'multi-profile-selection', MULTI_PROFILE_SELECTION: 'multi-profile-selection',
SETUP_SUCCESS: 'setup-success', SETUP_FINISH: 'setup-finish',
SETUP_FAILURE: 'setup-failure',
}; };
/** /**
...@@ -124,10 +123,10 @@ cr.define('cellular_setup', function() { ...@@ -124,10 +123,10 @@ cr.define('cellular_setup', function() {
this.state_ = ESimUiState.ACTIVATION_CODE_ENTRY; this.state_ = ESimUiState.ACTIVATION_CODE_ENTRY;
break; break;
case 1: case 1:
// TODO(crbug.com/1093185) Install the // Assume installing the profile doesn't require a confirmation
// profile. Handle error state. Handle // code, send an empty string.
// confirmation code if needed. profiles[0].installProfile('').then(
this.state_ = ESimUiState.SETUP_SUCCESS; this.handleProfileInstallResponse_.bind(this));
break; break;
default: default:
// TODO(crbug.com/1093185) Populate the profile discovery with // TODO(crbug.com/1093185) Populate the profile discovery with
...@@ -160,6 +159,19 @@ cr.define('cellular_setup', function() { ...@@ -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 */ /** @private */
updateSelectedPage_() { updateSelectedPage_() {
switch (this.state_) { switch (this.state_) {
...@@ -172,7 +184,7 @@ cr.define('cellular_setup', function() { ...@@ -172,7 +184,7 @@ cr.define('cellular_setup', function() {
case ESimUiState.MULTI_PROFILE_SELECTION: case ESimUiState.MULTI_PROFILE_SELECTION:
this.selectedESimPageName_ = ESimPageName.PROFILE_DISCOVERY; this.selectedESimPageName_ = ESimPageName.PROFILE_DISCOVERY;
break; break;
case ESimUiState.SETUP_SUCCESS: case ESimUiState.SETUP_FINISH:
this.selectedESimPageName_ = ESimPageName.FINAL; this.selectedESimPageName_ = ESimPageName.FINAL;
break; break;
default: default:
...@@ -210,7 +222,7 @@ cr.define('cellular_setup', function() { ...@@ -210,7 +222,7 @@ cr.define('cellular_setup', function() {
skipDiscovery: cellularSetup.ButtonState.SHOWN_AND_ENABLED, skipDiscovery: cellularSetup.ButtonState.SHOWN_AND_ENABLED,
}; };
break; break;
case ESimUiState.SETUP_SUCCESS: case ESimUiState.SETUP_FINISH:
buttonState = { buttonState = {
backward: cellularSetup.ButtonState.HIDDEN, backward: cellularSetup.ButtonState.HIDDEN,
cancel: cellularSetup.ButtonState.HIDDEN, cancel: cellularSetup.ButtonState.HIDDEN,
...@@ -258,7 +270,7 @@ cr.define('cellular_setup', function() { ...@@ -258,7 +270,7 @@ cr.define('cellular_setup', function() {
case ESimUiState.ACTIVATION_CODE_ENTRY: case ESimUiState.ACTIVATION_CODE_ENTRY:
// TODO(crbug.com/1093185) Install the profile. Handle error state. // TODO(crbug.com/1093185) Install the profile. Handle error state.
// Handle confirmation code if needed. // Handle confirmation code if needed.
this.state_ = ESimUiState.SETUP_SUCCESS; this.state_ = ESimUiState.SETUP_FINISH;
break; break;
case ESimUiState.MULTI_PROFILE_SELECTION: case ESimUiState.MULTI_PROFILE_SELECTION:
this.state_ = ESimUiState.ACTIVATION_CODE_ENTRY; 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