Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: dashboard acceptance tests for quick actions, client count, replication #22475

Merged
merged 42 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
cb1506c
Add acceptance tests
kiannaquach Aug 21, 2023
8d67aa8
Put back vault configuration tests
kiannaquach Aug 21, 2023
40105ea
Add selectors of quick actions and get quick actions set up in accept…
kiannaquach Aug 21, 2023
47f3c4c
Fix wrong test helper names
kiannaquach Aug 21, 2023
c6c4cdd
CC card tests
kiannaquach Aug 22, 2023
f9e9dfe
Write replication card tests
kiannaquach Aug 22, 2023
b4c4ebe
Update to async/await
kiannaquach Aug 22, 2023
e4c244e
Add a login
kiannaquach Aug 22, 2023
1156b4e
Skip test to see why it its not working..
kiannaquach Aug 22, 2023
9e4e506
Replication card test
kiannaquach Aug 22, 2023
0776fbc
Update period in feedback form and test
kiannaquach Aug 22, 2023
96ae11e
Fix tests...maybe?
kiannaquach Aug 22, 2023
1cf435f
Put things back
kiannaquach Aug 22, 2023
f38f863
Put setupMirage in individual modules
kiannaquach Aug 22, 2023
c3f8529
Remove duplication setupMirage
kiannaquach Aug 22, 2023
f6159d9
Remove some clicks and fillins that are not needed
kiannaquach Aug 22, 2023
610a87d
Only test replication
kiannaquach Aug 22, 2023
1684eff
Add a pollCluster
kiannaquach Aug 22, 2023
ba3c97a
Skip replication tests for now
kiannaquach Aug 22, 2023
d01be32
Put client count test back
kiannaquach Aug 22, 2023
e1f2ce3
Fix url
kiannaquach Aug 22, 2023
56423e3
Add license start time
kiannaquach Aug 22, 2023
623e77d
Make sure it is enterprise
kiannaquach Aug 22, 2023
e051a56
Get version after the get request
kiannaquach Aug 22, 2023
4224d43
Passing tests locally
kiannaquach Aug 22, 2023
e3996ba
Make some edits to replication
kiannaquach Aug 22, 2023
9ede4d4
Update setupMirage locations
kiannaquach Aug 23, 2023
b32a297
Run client card test
kiannaquach Aug 23, 2023
97c8233
Use modifypassthrough helper
kiannaquach Aug 23, 2023
c70a823
Put enterprise keyword in test name
kiannaquach Aug 23, 2023
31f9909
Put correct assertions for correct versions
kiannaquach Aug 23, 2023
a6e098f
Fix empty states
kiannaquach Aug 23, 2023
bd1976d
Add db quick action role set up and update enterprise vs community
kiannaquach Aug 23, 2023
73f0e49
Remove extra comment
kiannaquach Aug 23, 2023
e14b01e
Fix kv runcommand
kiannaquach Aug 23, 2023
a94b65a
Delete engine after each test
kiannaquach Aug 23, 2023
f312018
Fix enterprise test
kiannaquach Aug 23, 2023
cb495c0
VAULT-19311 hide show all in secret engine and use right models for kv
kiannaquach Aug 23, 2023
2f13d7f
Fix quick actions bug
kiannaquach Aug 23, 2023
2cc3185
Add v1 kv test
kiannaquach Aug 23, 2023
b90837f
Fix kv tests
kiannaquach Aug 23, 2023
7433036
Only show this view if either license or root exists and isEnterprise
kiannaquach Aug 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/app/components/dashboard/client-count-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export default class DashboardClientCountCard extends Component {

@task
@waitFor
*fetchClientActivity() {
*fetchClientActivity(e) {
if (e) e.preventDefault();
this.updatedAt = timestamp.now().toISOString();
// only make the network request if we have a start_time
if (!this.licenseStartTime) return {};
Expand Down
23 changes: 12 additions & 11 deletions ui/app/components/dashboard/quick-actions-card.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do all of the getters and things update as expected? I know sometimes ember has trouble tracking nested values if tracked properties are objects. It looks like tests would account for that, but just wanted to check 😄

Copy link
Contributor Author

@kiannaquach kiannaquach Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hellobontempo I was concerned about that too! Do you think I should move it back to individual tracked properties? From my manual qa and my acceptance tests, everything works as intended, but I'm paranoid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly - all of your getters recompute because of the selected engine 🤔

I think as long as you're not expecting the view to change based just the key value of the object, then we should be good!

Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ export default class DashboardQuickActionsCard extends Component {

@tracked selectedEngine;
@tracked selectedAction;
@tracked mountPath;
@tracked paramValue;

get actionOptions() {
switch (this.selectedEngine) {
case 'kv':
switch (this.selectedEngine.type) {
case `kv version ${this.selectedEngine?.version}`:
return ['Find KV secrets'];
case 'database':
return ['Generate credentials for database'];
Expand All @@ -49,8 +48,9 @@ export default class DashboardQuickActionsCard extends Component {
title: 'Secret path',
subText: 'Path of the secret you want to read, including the mount. E.g., secret/data/foo.',
buttonText: 'Read secrets',
model: 'secret-v2',
route: 'vault.cluster.secrets.backends.show',
// check kv version to figure out which model to use
model: this.selectedEngine.version === 2 ? 'secret-v2' : 'secret',
route: 'vault.cluster.secrets.backend.show',
};
case 'Generate credentials for database':
return {
Expand Down Expand Up @@ -99,15 +99,16 @@ export default class DashboardQuickActionsCard extends Component {

get mountOptions() {
return this.filteredSecretEngines.map((engine) => {
const { id, type } = engine;
return { name: id, type, id };
let { id, type, version } = engine;
if (type === 'kv') type = `kv version ${version}`;

return { name: id, type, id, version };
});
}

@action
handleSearchEngineSelect([selection]) {
this.selectedEngine = selection?.type;
this.mountPath = selection?.id;
this.selectedEngine = selection;
// reset tracked properties
this.selectedAction = null;
this.paramValue = null;
Expand All @@ -134,13 +135,13 @@ export default class DashboardQuickActionsCard extends Component {

// kv has a special use case where if the paramValue ends in a '/' you should
// link to different route
if (this.selectedEngine === 'kv') {
if (this.selectedEngine.type === 'kv') {
searchSelectParamRoute =
this.paramValue && this.paramValue[this.paramValue?.length - 1] === '/'
? 'vault.cluster.secrets.backend.list'
: 'vault.cluster.secrets.backend.show';
}

this.router.transitionTo(searchSelectParamRoute, this.mountPath, this.paramValue);
this.router.transitionTo(searchSelectParamRoute, this.selectedEngine.id, this.paramValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Component from '@glimmer/component';

export default class DashboardSecretsEnginesCard extends Component {
get tlsDisabled() {
const tlsDisableConfig = this.args.vaultConfiguration.listeners.find((listener) => {
const tlsDisableConfig = this.args.vaultConfiguration?.listeners.find((listener) => {
if (listener.config && listener.config.tls_disable) return listener.config.tls_disable;
});

Expand Down
3 changes: 2 additions & 1 deletion ui/app/controllers/vault/cluster/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default class DashboardController extends Controller {
@tracked replicationUpdatedAt = timestamp.now().toISOString();

@action
refreshModel() {
refreshModel(e) {
if (e) e.preventDefault();
this.replicationUpdatedAt = timestamp.now().toISOString();
this.send('refreshRoute');
}
Expand Down
16 changes: 7 additions & 9 deletions ui/app/templates/components/dashboard/client-count-card.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Hds::Card::Container @hasBorder={{true}} class="has-padding-l has-bottom-padding-m">
<Hds::Card::Container @hasBorder={{true}} class="has-padding-l has-bottom-padding-m" data-test-client-count-card>
<div class="is-flex-between">
<h3 class="title is-4 has-bottom-margin-xxs" data-test-client-count-title>
Client count
Expand All @@ -14,10 +14,10 @@
would return no activity data. Adding this empty state here to match the current client count behavior }}
<Clients::NoData @config={{this.clientConfig}} />
{{else}}
<div class="is-grid grid-2-columns grid-gap-2 has-top-margin-m grid-align-items-start is-flex-v-centered">
{{#if this.fetchClientActivity.isRunning}}
<VaultLogoSpinner />
{{else}}
{{#if this.fetchClientActivity.isRunning}}
<VaultLogoSpinner />
{{else}}
<div class="is-grid grid-2-columns grid-gap-2 has-top-margin-m grid-align-items-start is-flex-v-centered">
<StatText
@label="Total"
@value={{this.activityData.total.clients}}
Expand All @@ -35,10 +35,8 @@
@subText="The number of clients new to Vault in the current month."
data-test-stat-text="new-clients"
/>
{{/if}}
</div>
</div>

{{#unless this.fetchClientActivity.isRunning}}
<div class="has-top-margin-l is-flex-center">
<Hds::Button
@text="Refresh"
Expand All @@ -55,6 +53,6 @@
{{date-format this.updatedAt "MMM dd, yyyy HH:mm:SS"}}
</small>
</div>
{{/unless}}
{{/if}}
{{/if}}
</Hds::Card::Container>
11 changes: 8 additions & 3 deletions ui/app/templates/components/dashboard/quick-actions-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@displayInherit={{true}}
@shouldRenderName={{true}}
@passObject={{true}}
@objectKeys={{array "type"}}
@objectKeys={{array "type" "version"}}
class="is-marginless"
data-test-secrets-engines-select
/>
Expand All @@ -38,13 +38,14 @@
class="is-flex-grow-1"
@selectLimit="1"
@models={{array this.searchSelectParams.model}}
@backend={{this.mountPath}}
@backend={{this.selectedEngine.id}}
@placeholder={{this.searchSelectParams.placeholder}}
@disallowNewItems={{true}}
@onChange={{this.handleActionSelect}}
@fallbackComponent="input-search"
@nameKey={{this.searchSelectParams.nameKey}}
@disabled={{not this.searchSelectParams.model}}
data-test-param-select
/>

<div>
Expand All @@ -60,6 +61,10 @@
</div>
{{/if}}
{{else}}
<EmptyState @title="No mount selected" @message="Select a mount above to get started." />
<EmptyState
@title="No mount selected"
@message="Select a mount above to get started."
data-test-no-mount-selected-empty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you could use the empty state component test selectors and just reuse those in your test file?

/>
{{/if}}
</Hds::Card::Container>
2 changes: 1 addition & 1 deletion ui/app/templates/components/dashboard/replication-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}
<Hds::Card::Container @hasBorder={{true}} class="has-padding-l has-bottom-padding-m">
<Hds::Card::Container @hasBorder={{true}} class="has-padding-l has-bottom-padding-m" data-test-replication-card>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this selector is something like data-test-card="replication" the same selector could be reused for your other cards in tests

SELECTORS = {
...
card: (name) => `[data-test-card="${name}"]`
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out and great idea! I will make a follow up ticket!


<div class="is-flex-between">
<h3 class="title is-4 has-bottom-margin-xxs" data-test-client-count-title>
Expand Down
20 changes: 11 additions & 9 deletions ui/app/templates/components/dashboard/secrets-engines-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@
{{/each}}
</:body>
</Hds::Table>
<div class="is-flex-end has-top-margin-s">
<Hds::Link::Standalone
class="has-text-weight-semibold is-no-underline"
@icon="arrow-right"
@iconPosition="trailing"
@text="Show all"
@route="vault.cluster.secrets.backends"
/>
</div>
{{#if (gt this.filteredSecretsEngines.length 4)}}
<div class="is-flex-end has-top-margin-s" data-test-secrets-engines-card-show-all>
<Hds::Link::Standalone
class="has-text-weight-semibold is-no-underline"
@icon="arrow-right"
@iconPosition="trailing"
@text="Show all"
@route="vault.cluster.secrets.backends"
/>
</div>
{{/if}}
</Hds::Card::Container>
3 changes: 2 additions & 1 deletion ui/app/templates/components/dashboard/survey-link-text.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<small>
Don't see what you're looking for on this page? Let us know via our
<Hds::Link::Inline @icon="external-link" @href="https://hashicorp.sjc1.qualtrics.com/jfe/form/SV_1SNUsZLdWHpfw0e">
feedback form.
feedback form
</Hds::Link::Inline>
.
</small>
</div>
2 changes: 1 addition & 1 deletion ui/app/templates/vault/cluster/dashboard.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="has-bottom-margin-xl">
<div class="is-flex-row has-gap-l">
{{#if @model.version.isEnterprise}}
{{#if (and @model.version.isEnterprise (or @model.license @model.isRootNamespace))}}

<div class="is-flex-column is-flex-1 has-gap-l">
{{#if @model.license}}
Expand Down
Loading