Skip to content

Commit

Permalink
parent 404a3ae
Browse files Browse the repository at this point in the history
author Ping <[email protected]> 1694449778 +0800
committer Daniel Smith <[email protected]> 1695414849 -0700

parent 404a3ae
author Ping <[email protected]> 1694449778 +0800
committer Daniel Smith <[email protected]> 1695414839 -0700

parent 404a3ae
author Ping <[email protected]> 1694449778 +0800
committer Daniel Smith <[email protected]> 1695414831 -0700

parent 404a3ae
author Ping <[email protected]> 1694449778 +0800
committer Daniel Smith <[email protected]> 1695414745 -0700

Documentation for feature links (#3317)

* Add documentation for feature links

* Update documentation for feature links

npm: bump tar from 6.1.15 to 6.2.0 (#3318)

Bumps [tar](https://github.com/isaacs/node-tar) from 6.1.15 to 6.2.0.
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v6.1.15...v6.2.0)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

npm: bump eslint from 8.48.0 to 8.49.0 (#3319)

Bumps [eslint](https://github.com/eslint/eslint) from 8.48.0 to 8.49.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](eslint/eslint@v8.48.0...v8.49.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

npm: bump @babel/register from 7.22.5 to 7.22.15 (#3320)

Bumps [@babel/register](https://github.com/babel/babel/tree/HEAD/packages/babel-register) from 7.22.5 to 7.22.15.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.22.15/packages/babel-register)

---
updated-dependencies:
- dependency-name: "@babel/register"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

npm: bump rollup from 3.28.1 to 3.29.1 (#3321)

Bumps [rollup](https://github.com/rollup/rollup) from 3.28.1 to 3.29.1.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](rollup/rollup@v3.28.1...v3.29.1)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Enforce rollout milestones to have a minimum value of 100 (#3316)

Revert "temporarily remove OT cron" (#3322)

This reverts commit 5da4d25.

Update cron description (#3323)

* Update cron.yaml

* Update cron.yaml

Update chromedash-feature-detail.js (#3324)

Record vote activities with amendments instead of text. (#3314)

* Record vote activities with amendments instead of text.

* Stop checking comments_only

Add support for testing mobile (i.e. narrow window). (#3325)

* Add support for testing mobile (i.e. narrow window).

* Cleanup

Ensure all available features for a release note are fetched (#3328)

- Add new query parameter releaseNotesMilestone to the GET /features route
- Ensure all shipping and enterprise features are returned from the milestone specified in releaseNotesMilestone until the latest available feature
- Update front end logic to wait for a channel to be selected before getting the features for the release notes
- Update front end logic to fetch policies each time the target milestone is changed

Add 3 more fields for OT creation (#3327)

* Add 3 more fields for OT creation

* `stage_description` -> `ot_description`

With a more detailed description of the field and its relation to OT

* remove test line

Add indexes needed for enterprise release notes. (#3329)

Hide enterprise features from /features page (#3330)

Enterprise features were shown on /features when they should never be shown there.
This PR filters out enterprise features from the features sent to /features

Ensure milestone comparison is made between two int types (#3331)

Add `ot_feedback_submission_url` field (#3333)

Add 3 more fields for OT creation

`stage_description` -> `ot_description`

With a more detailed description of the field and its relation to OT

remove test line

Add basic UI for trial creation request

Add `ot_feedback_submission_url` to ot creation

ot button only shows on ot stage details

Update chromedash-feature-detail.js

fix OT button

cancel button returns to feature detail

add ot milestone fields

Update chromedash-feature-detail.js

Add action_requested field for creation/extension

show button disabled if already requested

trial association cron clears ot action requests

`/admin/ot_requests.html`

Fix base.css unix perms. (#3338)

don't write to the same entity multiple times (#3345)

npm: bump @babel/preset-env from 7.22.15 to 7.22.20 (#3340)

Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.22.15 to 7.22.20.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.22.20/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

npm: bump @lit-labs/context from 0.4.0 to 0.4.1 (#3341)

Bumps [@lit-labs/context](https://github.com/lit/lit/tree/HEAD/packages/labs/context) from 0.4.0 to 0.4.1.
- [Release notes](https://github.com/lit/lit/releases)
- [Changelog](https://github.com/lit/lit/blob/main/packages/labs/context/CHANGELOG.md)
- [Commits](https://github.com/lit/lit/commits/@lit-labs/[email protected]/packages/labs/context)

---
updated-dependencies:
- dependency-name: "@lit-labs/context"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

npm: bump sass from 1.66.1 to 1.67.0 (#3342)

Bumps [sass](https://github.com/sass/dart-sass) from 1.66.1 to 1.67.0.
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md)
- [Commits](sass/dart-sass@1.66.1...1.67.0)

---
updated-dependencies:
- dependency-name: sass
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

npm: bump @playwright/test from 1.37.1 to 1.38.0 (#3343)

Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.37.1 to 1.38.0.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](microsoft/playwright@v1.37.1...v1.38.0)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Add test of entering a blink_component name (#3349)

* Add test to enter blink component

* Update the README a bit.

* Change name of test, update images.

* Delete commented out code.

npm: bump @babel/core from 7.22.11 to 7.22.20 (#3344)

Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.22.11 to 7.22.20.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.22.20/packages/babel-core)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Add `ot_owner_email` and `ot_display_name` fields

Add 3 more fields for OT creation

`stage_description` -> `ot_description`

With a more detailed description of the field and its relation to OT

remove test line

Add basic UI for trial creation request

Update chromedash-feature-detail.js

cancel button returns to feature detail

add ot milestone fields

fix test

Add "overdue" to the tooltip on overdue gate chips. (#3350)

* Add "overdue" to the tooltip on overdue gate chips.

* Also remove gate name.

Add `ot_action_requested` field to denote sent requests (#3336)

* Add 3 more fields for OT creation

* `stage_description` -> `ot_description`

With a more detailed description of the field and its relation to OT

* remove test line

* Add basic UI for trial creation request

* Add `ot_feedback_submission_url` to ot creation

* ot button only shows on ot stage details

* Update chromedash-feature-detail.js

* fix OT button

* cancel button returns to feature detail

* add ot milestone fields

* Update chromedash-feature-detail.js

* Add action_requested field for creation/extension
  • Loading branch information
pingren authored and DanielRyanSmith committed Sep 22, 2023
1 parent 404a3ae commit 6502b2f
Show file tree
Hide file tree
Showing 65 changed files with 1,231 additions and 404 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,20 @@ To run the Playwright visual tests (aka end-to-end tests), the command to use is
npm run pwtests --workspace=playwright
```

If there are errors, or if you need to update any of the screeenshot images,
you can update all images for all tests with:
If there are errors, they will be displayed in the console.
If you need to update any of the screenshot images, you will see differences in
the `packages/playwright/test-results` directory, and if they look correct,
then you can update _all_ images for all tests with:
```bash
npm run pwtests-update --workspace=playwright
```

Then check the `packages/playwright/test-results` directory for any changes.
The updated images are also added to the __screenshots__ directory.
If you change test file names, or test names, or screenshot image names, then
you can manually delete the old screenshots, or simply delete all and update all.

There is no way to run just one test or test file yet, but playwright supports
doing that, so we should be able to add a parameter to the test running commands.

There is some additional information for developers in developer-documentation.md.

Expand Down Expand Up @@ -124,7 +130,7 @@ of globals for debugging and running the site locally.

### Deploying

If you have uncommited local changes, the appengine version name will end with `-tainted`.
If you have uncommitted local changes, the appengine version name will end with `-tainted`.
It is OK to test on staging with tainted versions, but everything should be committed
(and thus not tainted) before staging a version that can later be pushed to prod.

Expand Down
6 changes: 6 additions & 0 deletions api/api_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
STAGE_FIELD_DATA_TYPES: FIELD_INFO_DATA_TYPE = [
('announcement_url', 'link'),
('browser', 'str'),
('ot_description', 'str'),
('display_name', 'str'),
('enterprise_policies', 'split_str'),
('finch_url', 'link'),
Expand All @@ -104,10 +105,15 @@
('origin_trial_feedback_url', 'link'),
('origin_trial_id', 'str'),
('ot_chromium_trial_name', 'str'),
('ot_action_requested', 'bool'),
('ot_documentation_url', 'link'),
('ot_emails', 'emails'),
('ot_feedback_submission_url', 'link'),
('ot_has_third_party_support', 'bool'),
('ot_is_critical_trial', 'bool'),
('ot_is_deprecation_trial', 'bool'),
('ot_owner_email', 'str'),
('ot_request_note', 'str'),
('ot_webfeature_use_counter', 'str'),
('rollout_impact', 'int'),
('rollout_milestone', 'int'),
Expand Down
4 changes: 1 addition & 3 deletions api/comments_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ def do_get(self, **kwargs) -> dict[str, list[dict[str, Any]]]:
"""Return a list of all review comments on the given feature."""
feature_id = kwargs['feature_id']
gate_id = kwargs.get('gate_id', None)
comments_only = self.get_bool_arg('comments_only')
# Note: We assume that anyone may view approval comments.
comments = Activity.get_activities(
feature_id, gate_id, comments_only=comments_only)
comments = Activity.get_activities(feature_id, gate_id)
user = self.get_current_user()
is_admin = permissions.can_admin_site(user)

Expand Down
7 changes: 3 additions & 4 deletions api/comments_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,20 @@ def test_get__empty(self):
self.assertEqual({'comments': []}, actual_response)

def test_get__legacy_comments(self):
"""We can get legacy comments."""
"""We no longer return legacy gate comments when gate_id is specified."""
testing_config.sign_out()
testing_config.sign_in('[email protected]', 123567890)

legacy_comment = Activity(
feature_id=self.feature_id, author='[email protected]',
created=NOW, content='nothing')
created=NOW, content='nothing') # no gate_id
legacy_comment.put()

with test_app.test_request_context(self.request_path):
actual_response = self.handler.do_get(
feature_id=self.feature_id, gate_id=self.gate_1_id)
testing_config.sign_out()
actual_comment = actual_response['comments'][0]
self.assertEqual('nothing', actual_comment['content'])
self.assertEqual([], actual_response['comments'])

def test_get__all_some(self):
"""We can get all comments for a given approval."""
Expand Down
7 changes: 7 additions & 0 deletions api/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def stage_to_json_dict(
'created': str(stage.created),
'feature_id': stage.feature_id,
'stage_type': stage.stage_type,
'ot_description': stage.ot_description,
'display_name': stage.display_name,
'intent_stage': INTENT_STAGES_BY_STAGE_TYPE.get(
stage.stage_type, INTENT_NONE),
Expand All @@ -191,11 +192,17 @@ def stage_to_json_dict(
'experiment_risks': stage.experiment_risks,
'origin_trial_id': stage.origin_trial_id,
'origin_trial_feedback_url': stage.origin_trial_feedback_url,
'ot_action_requested': stage.ot_action_requested,
'ot_chromium_trial_name': stage.ot_chromium_trial_name,
'ot_description': stage.ot_description,
'ot_display_name': stage.ot_display_name,
'ot_documentation_url': stage.ot_documentation_url,
'ot_emails': stage.ot_emails,
'ot_feedback_submission_url': stage.ot_feedback_submission_url,
'ot_has_third_party_support': stage.ot_has_third_party_support,
'ot_is_critical_trial': stage.ot_is_critical_trial,
'ot_is_deprecation_trial': stage.ot_is_deprecation_trial,
'ot_owner_email': stage.ot_owner_email,
'ot_webfeature_use_counter': stage.ot_webfeature_use_counter,
'extensions': [],
'experiment_extension_reason': stage.experiment_extension_reason,
Expand Down
10 changes: 10 additions & 0 deletions api/features_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ def do_search(self):
'total_count': total_count,
}

# Query-string parameter 'releaseNotesMilestone' is provided
release_notes_milestone = self.get_int_arg('releaseNotesMilestone')
if release_notes_milestone:
features_in_release_notes = feature_helpers.get_features_in_release_notes(
milestone=release_notes_milestone)
return {
'features': features_in_release_notes,
'total_count': len(features_in_release_notes)
}

user_query = self.request.args.get('q', '')
sort_spec = self.request.args.get('sort')
num = self.get_int_arg('num', search.DEFAULT_RESULTS_PER_PAGE)
Expand Down
7 changes: 5 additions & 2 deletions api/reviews_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ def do_post(self, **kwargs) -> dict[str, str]:
if gate.feature_id != feature_id:
self.abort(400, msg='Mismatched feature and gate')

old_state = gate.state
old_votes = Vote.get_votes(
feature_id=feature_id, gate_id=gate_id, set_by=user.email())
old_state = old_votes[0].state if old_votes else Vote.NO_RESPONSE
self.require_permissions(user, feature, gate, new_state)

# Note: We no longer write Approval entities.
approval_defs.set_vote(feature_id, None, new_state,
user.email(), gate_id)

if new_state == Vote.REVIEW_REQUESTED:
notifier_helpers.notify_approvers_of_reviews(feature, gate)
notifier_helpers.notify_approvers_of_reviews(
feature, gate, user.email())
else:
notifier_helpers.notify_subscribers_of_vote_changes(
feature, gate, user.email(), new_state, old_state)
Expand Down
13 changes: 8 additions & 5 deletions api/reviews_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ def test_post__add_new_vote(self, mock_get_approvers, mock_notifier):
self.assertEqual(vote.set_by, '[email protected]')
self.assertEqual(vote.state, Vote.NEEDS_WORK)

mock_notifier.assert_called_once_with(self.feature_1,
self.gate_1, '[email protected]', Vote.NEEDS_WORK, Vote.NA)
mock_notifier.assert_called_once_with(
self.feature_1, self.gate_1, '[email protected]',
Vote.NEEDS_WORK, Vote.NO_RESPONSE)

@mock.patch('internals.notifier_helpers.notify_subscribers_of_vote_changes')
@mock.patch('internals.approval_defs.get_approvers')
Expand All @@ -254,8 +255,9 @@ def test_post__update_vote(self, mock_get_approvers, mock_notifier):
self.assertEqual(vote.set_by, '[email protected]')
self.assertEqual(vote.state, Vote.DENIED)

mock_notifier.assert_called_once_with(self.feature_1,
self.gate_1, '[email protected]', Vote.DENIED, Vote.NA)
mock_notifier.assert_called_once_with(
self.feature_1, self.gate_1, '[email protected]',
Vote.DENIED, Vote.APPROVED)

@mock.patch('internals.notifier_helpers.notify_approvers_of_reviews')
@mock.patch('internals.approval_defs.get_approvers')
Expand All @@ -278,7 +280,8 @@ def test_post__request_review(self, mock_get_approvers, mock_notifier):
self.assertEqual(vote.set_by, '[email protected]')
self.assertEqual(vote.state, Vote.REVIEW_REQUESTED)

mock_notifier.assert_called_once_with(self.feature_1, self.gate_1)
mock_notifier.assert_called_once_with(
self.feature_1, self.gate_1, '[email protected]')


class GatesAPITest(testing_config.CustomTestCase):
Expand Down
27 changes: 27 additions & 0 deletions api/stages_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,20 @@ def setUp(self):
origin_trial_id='-5269211564023480319',
ux_emails=['[email protected]'],
intent_thread_url='https://example.com/intent',
ot_action_requested=True,
ot_chromium_trial_name='ExampleChromiumTrialName',
ot_description='An origin trial\'s description',
ot_display_name='The Origin Trial Display Name',
ot_documentation_url='https://example.com/ot_docs',
ot_emails=['[email protected]', '[email protected]'],
ot_feedback_submission_url='https://example.com/submit_feedback',
ot_has_third_party_support=True,
ot_is_deprecation_trial=True,
ot_is_critical_trial=True,
# ot_request_note should remain confidential and not be displayed in
# requests obtaining information about the stage.
ot_request_note='Additional info',
ot_owner_email='[email protected]',
ot_webfeature_use_counter='kExampleUseCounter',
milestones=MilestoneSet(desktop_first=100),
experiment_goals='To be the very best.',
Expand All @@ -98,11 +107,17 @@ def setUp(self):
'enterprise_policies': [],
'origin_trial_id': None,
'origin_trial_feedback_url': None,
'ot_action_requested': False,
'ot_chromium_trial_name': None,
'ot_description': None,
'ot_display_name': None,
'ot_documentation_url': None,
'ot_emails': [],
'ot_feedback_submission_url': None,
'ot_has_third_party_support': False,
'ot_is_critical_trial': False,
'ot_is_deprecation_trial': False,
'ot_owner_email': None,
'ot_webfeature_use_counter': None,
'experiment_extension_reason': None,
'experiment_goals': 'To be the very best.',
Expand Down Expand Up @@ -188,11 +203,17 @@ def test_get__valid_with_extension(self):
'experiment_goals': 'To be the very best.',
'experiment_risks': None,
'origin_trial_feedback_url': None,
'ot_action_requested': False,
'ot_chromium_trial_name': None,
'ot_description': None,
'ot_display_name': None,
'ot_documentation_url': None,
'ot_emails': [],
'ot_feedback_submission_url': None,
'ot_has_third_party_support': False,
'ot_is_critical_trial': False,
'ot_is_deprecation_trial': False,
'ot_owner_email': None,
'ot_webfeature_use_counter': None,
'announcement_url': None,
'enterprise_policies': [],
Expand Down Expand Up @@ -235,11 +256,17 @@ def test_get__valid_with_extension(self):
'enterprise_policies': [],
'origin_trial_id': '-5269211564023480319',
'origin_trial_feedback_url': None,
'ot_action_requested': True,
'ot_chromium_trial_name': 'ExampleChromiumTrialName',
'ot_description': 'An origin trial\'s description',
'ot_display_name': 'The Origin Trial Display Name',
'ot_documentation_url': 'https://example.com/ot_docs',
'ot_emails': ['[email protected]', '[email protected]'],
'ot_feedback_submission_url': 'https://example.com/submit_feedback',
'ot_has_third_party_support': True,
'ot_is_critical_trial': True,
'ot_is_deprecation_trial': True,
'ot_owner_email': '[email protected]',
'ot_webfeature_use_counter': 'kExampleUseCounter',
'rollout_details': None,
'rollout_impact': 2,
Expand Down
1 change: 1 addition & 0 deletions client-src/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import './elements/chromedash-legend';
import './elements/chromedash-login-required-page';
import './elements/chromedash-metadata';
import './elements/chromedash-myfeatures-page';
import './elements/chromedash-ot-creation-page';
import './elements/chromedash-preflight-dialog';
import './elements/chromedash-process-overview';
import './elements/chromedash-settings-page';
Expand Down
4 changes: 2 additions & 2 deletions client-src/elements/chromedash-activity-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ChromedashActivityPage extends LitElement {
fetchComments() {
this.loading = true;
Promise.all([
window.csClient.getComments(this.featureId, null, false),
window.csClient.getComments(this.featureId, null),
]).then(([commentRes]) => {
this.comments = commentRes.comments;
this.needsPost = false;
Expand All @@ -85,7 +85,7 @@ export class ChromedashActivityPage extends LitElement {
commentArea.value = '';
this.needsPost = false;
Promise.all([
window.csClient.getComments(this.featureId, null, false),
window.csClient.getComments(this.featureId, null),
]).then(([commentRes]) => {
this.comments = commentRes.comments;
}).catch(() => {
Expand Down
9 changes: 9 additions & 0 deletions client-src/elements/chromedash-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,15 @@ class ChromedashApp extends LitElement {
this.currentPage = ctx.path;
this.hideSidebar();
});
page('/ot_creation_request/:featureId(\\d+)/:stageId(\\d+)', (ctx) => {
if (!this.setupNewPage(ctx, 'chromedash-ot-creation-page')) return;
this.pageComponent.featureId = parseInt(ctx.params.featureId);
this.pageComponent.stageId = parseInt(ctx.params.stageId);
this.pageComponent.nextPage = this.currentPage;
this.pageComponent.appTitle = this.appTitle;
this.currentPage = ctx.path;
this.hideSidebar();
});
page('/guide/stage/:featureId(\\d+)/metadata', (ctx) => {
if (!this.setupNewPage(ctx, 'chromedash-guide-metadata-page')) return;
this.pageComponent.featureId = parseInt(ctx.params.featureId);
Expand Down
43 changes: 23 additions & 20 deletions client-src/elements/chromedash-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class ChromedashDrawer extends LitElement {

connectedCallback() {
super.connectedCallback();

// user is passed in from chromedash-app
if (this.user && this.user.email) return;

Expand All @@ -134,6 +135,8 @@ export class ChromedashDrawer extends LitElement {
this.initializeGoogleSignIn();
}
if (this.devMode == 'True') {
// Insert the testing signin second, so it appears to the left
// of the google signin button, with a large margin on the right.
this.initializeTestingSignIn();
}
}
Expand All @@ -160,36 +163,36 @@ export class ChromedashDrawer extends LitElement {
}

initializeTestingSignIn() {
if (this.devMode != 'True') {
return;
}

// Create DEV_MODE login button for testing
const signInTestingButton = document.createElement('button');
signInTestingButton.innerText = 'Sign in as [email protected]';
signInTestingButton.setAttribute('type', 'button');
signInTestingButton.setAttribute('data-testid', 'dev-mode-sign-in-button');
signInTestingButton.setAttribute('style',
'position:fixed; right:0; z-index:1000; background: lightblue; border: 1px solid blue;');

signInTestingButton.addEventListener('click', () => {
// POST to '/dev/mock_login' to login as example@chromium.
fetch('/dev/mock_login', {method: 'POST'}).then((response) => {
if (!response.ok) {
signInTestingButton.style.color = 'red';
throw new Error('Sign in failed! Response:', response);
}
// Reload the page to display with the logged in user.
const url = window.location.href.split('?')[0];
window.history.replaceState(null, null, url);
window.location = url;
})
fetch('/dev/mock_login', {method: 'POST'})
.then((response) => {
if (!response.ok) {
throw new Error('Sign in failed! Response:', response);
}
})
.then(() => {
setTimeout(() => {
const url = window.location.href.split('?')[0];
window.location = url;
}, 1000);
})
.catch((error) => {
console.error('Sign in failed.', error);
});
});

const appComponent = document.querySelector('chromedash-app');
if (appComponent) {
appComponent.insertAdjacentElement('afterbegin', signInTestingButton); // for SPA
} else {
this.insertAdjacentElement('afterbegin', signInTestingButton); // for MPA
const signInButtonContainer = document.querySelector('body');
if (signInButtonContainer) {
signInButtonContainer.insertAdjacentElement('afterbegin', signInTestingButton); // for SPA
}
}

Expand Down Expand Up @@ -267,7 +270,7 @@ export class ChromedashDrawer extends LitElement {
return html`
<div class="section-header">${this.user.email}</div>
<a href="/settings">Settings</a>
<a href="#" id="sign-out-link" @click=${this.handleSignOutClick}>Sign out</a>
<a href="#" id="sign-out-link" data-testid="sign-out-link" @click=${this.handleSignOutClick}>Sign out</a>
${this.user.can_create_feature && !this.isCurrentPage('/guide/new') ? html`
<sl-button data-testid="create-feature-button"
href="/guide/new" variant="primary" size="small">
Expand Down
Loading

0 comments on commit 6502b2f

Please sign in to comment.