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

fix: Hide example feature again #12197

Merged
merged 2 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions flow-server/src/main/java/com/vaadin/experimental/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.vaadin.experimental;

import java.io.Serializable;
import java.util.Objects;

import com.vaadin.flow.internal.UsageStatistics;

Expand Down Expand Up @@ -44,8 +45,8 @@ public class Feature implements Serializable {
*/
public Feature(String title, String id, String moreInfoLink,
boolean requiresServerRestart) {
this.title = title;
this.id = id;
this.title = Objects.requireNonNull(title);
this.id = Objects.requireNonNull(id);
this.moreInfoLink = moreInfoLink;
this.requiresServerRestart = requiresServerRestart;
}
Expand Down Expand Up @@ -90,4 +91,25 @@ public void setEnabled(boolean enabled) {

this.enabled = enabled;
}

@Override
public int hashCode() {
return id.hashCode();
}

@Override
public boolean equals(Object obj) {
Artur- marked this conversation as resolved.
Show resolved Hide resolved
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Feature other = (Feature) obj;
return (id.equals(other.id));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,13 @@ private void showTab(String id) {
$("button").attributeContains("class", "tab").id(id).click();
}

public void showExperimentalFeatures() {
showTab("features");
}

public List<String> listExperimentalFeatures() {
return (List<String>) executeScript(
"return Array.from(arguments[0].shadowRoot.querySelectorAll('.features-tray .feature label')).map(e => e.textContent.trim())",
this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.vaadin.flow.uitest.ui;

import java.util.List;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.testutil.ChromeBrowserTest;
import com.vaadin.flow.testutil.DevModeGizmoElement;

import org.junit.Assert;
import org.junit.Test;

public class DebugWindowFeatureFlagsIT extends ChromeBrowserTest {
@Override
protected Class<? extends Component> getViewClass() {
return DebugWindowErrorHandlingView.class;
}

@Test
public void exampleFeatureFlagNotShown() {
open();
DevModeGizmoElement debugWindow = $(DevModeGizmoElement.class).first();
debugWindow.expand();
debugWindow.showExperimentalFeatures();
List<String> features = debugWindow.listExperimentalFeatures();
for (String feature : features) {
Assert.assertFalse(
"Example feature should not be shown in the debug window",
feature.contains("Example feature"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ public void onConnect(AtmosphereResource resource) {
resource);

send(resource, "serverInfo", new ServerInfo());
send(resource, "featureFlags",
new FeatureFlagMessage(FeatureFlags.get(context).getFeatures()
.stream()
.filter(feature -> feature != FeatureFlags.EXAMPLE)
.collect(Collectors.toList())));
send(resource, "featureFlags", new FeatureFlagMessage(FeatureFlags
.get(context).getFeatures().stream()
.filter(feature -> !feature.equals(FeatureFlags.EXAMPLE))
.collect(Collectors.toList())));
}

private void send(AtmosphereResource resource, String command,
Expand Down