[Pinpoint] Add Simplified tab functionality for New Job Form
This CL will allow the state variables to adjust to the correct
defaulted values for the simplified tab.
Change-Id: I92e630ea94299fac4758fe0db041549f934dd554
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/1042896
Reviewed-by: Tony Seaward <seawardt@google.com>
Commit-Queue: Natnael Alemayehu <natnaelal@google.com>
diff --git a/pinpoint/ui/modules/pinpoint-new-job-sk/pinpoint-new-job-sk.ts b/pinpoint/ui/modules/pinpoint-new-job-sk/pinpoint-new-job-sk.ts
index 2f07e80..82aeac7 100644
--- a/pinpoint/ui/modules/pinpoint-new-job-sk/pinpoint-new-job-sk.ts
+++ b/pinpoint/ui/modules/pinpoint-new-job-sk/pinpoint-new-job-sk.ts
@@ -205,9 +205,24 @@
this._dialog.close();
}
+ private _resetForSimplifiedView() {
+ this._selectedBenchmark = 'speedometer3.crossbench';
+ this._selectedBot = 'mac-m1-pro-perf';
+ this._selectedStory = 'default';
+ this._iterationCount = '20';
+ this._startCommit = '';
+ this._endCommit = '';
+ this._jobName = '';
+ this._bugId = '';
+ this._storyTags = '';
+ }
+
private onTabChanged(e: CustomEvent) {
const tabs = e.target as Tabs;
this._activeTab = tabs.activeTabIndex === 0 ? 'detailed' : 'simplified';
+ if (this._activeTab === 'simplified') {
+ this._resetForSimplifiedView();
+ }
}
private async onBenchmarkChanged(e: Event) {
@@ -445,12 +460,17 @@
<h3>Base Commit</h3>
<md-outlined-text-field
label="Commit Hash"
- placeholder="Commit Hash"></md-outlined-text-field>
+ placeholder="Commit Hash"
+ .value=${this._startCommit}
+ @input=${(e: InputEvent) =>
+ this._onValueChanged(e, '_startCommit')}></md-outlined-text-field>
<h3>Experimental Commit</h3>
<md-outlined-text-field
label="Commit Hash"
- placeholder="Commit Hash"></md-outlined-text-field>
-
+ placeholder="Commit Hash"
+ .value=${this._endCommit}
+ @input=${(e: InputEvent) =>
+ this._onValueChanged(e, '_endCommit')}></md-outlined-text-field>
<h2>2. Review Test Configuration</h2>
<p>
This simplified flow uses a standard test configuration for general performance
diff --git a/pinpoint/ui/modules/pinpoint-new-job-sk/pinpoint-new-job-sk_test.ts b/pinpoint/ui/modules/pinpoint-new-job-sk/pinpoint-new-job-sk_test.ts
index 0e53818..7cc5fbb 100644
--- a/pinpoint/ui/modules/pinpoint-new-job-sk/pinpoint-new-job-sk_test.ts
+++ b/pinpoint/ui/modules/pinpoint-new-job-sk/pinpoint-new-job-sk_test.ts
@@ -72,6 +72,48 @@
expect(h2!.textContent).to.contain('1. Define Commit Range');
});
+ it('sets default values when switching to simplified tab', async () => {
+ await setupElement();
+ const tabs = element.shadowRoot!.querySelector('md-tabs') as Tabs;
+ tabs.activeTabIndex = 1; // Switch to "Simplified"
+ tabs.dispatchEvent(new CustomEvent('change'));
+ await element.updateComplete;
+
+ // Check that the internal state has been updated with default values.
+ expect((element as any)._selectedBenchmark).to.equal('speedometer3.crossbench');
+ expect((element as any)._selectedBot).to.equal('mac-m1-pro-perf');
+ expect((element as any)._selectedStory).to.equal('default');
+ expect((element as any)._iterationCount).to.equal('20');
+ expect((element as any)._startCommit).to.equal('');
+ expect((element as any)._endCommit).to.equal('');
+ expect((element as any)._jobName).to.equal('');
+ expect((element as any)._bugId).to.equal('');
+ expect((element as any)._storyTags).to.equal('');
+ });
+
+ it('updates commit values from simplified view inputs', async () => {
+ await setupElement();
+ const tabs = element.shadowRoot!.querySelector('md-tabs') as Tabs;
+ tabs.activeTabIndex = 1; // Switch to "Simplified"
+ tabs.dispatchEvent(new CustomEvent('change'));
+ await element.updateComplete;
+
+ const textFields = element.shadowRoot!.querySelectorAll('md-outlined-text-field');
+ const baseCommitInput = textFields[0];
+ const expCommitInput = textFields[1];
+
+ baseCommitInput.value = 'commit123';
+ baseCommitInput.dispatchEvent(new Event('input'));
+ await element.updateComplete;
+
+ expCommitInput.value = 'commit456';
+ expCommitInput.dispatchEvent(new Event('input'));
+ await element.updateComplete;
+
+ expect((element as any)._startCommit).to.equal('commit123');
+ expect((element as any)._endCommit).to.equal('commit456');
+ });
+
it('updates bots and stories when a benchmark is selected', async () => {
fetchMock.get('/bots?benchmark=benchmark_a', ['bot_a1', 'bot_a2']);
fetchMock.get('/stories?benchmark=benchmark_a', ['story_a1', 'story_a2']);