Skip to content

Commit

Permalink
Add IT for using pnpm (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis authored Apr 8, 2020
1 parent 35e65c5 commit d81296e
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 3 deletions.
3 changes: 0 additions & 3 deletions vaadin-spring-tests/test-spring-boot-only-prepare/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@
<version>${vaadin.flow.version}</version>
<executions>
<execution>
<configuration>
<pnpmEnable>true</pnpmEnable>
</configuration>
<goals>
<goal>prepare-frontend</goal>
</goals>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
server.port=8888
vaadin.blacklisted-packages=vaadin-spring/target/test-classes
vaadin.pnpm.enable=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2000-2020 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.flow.spring.test;

import java.io.File;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;

import com.vaadin.flow.component.AttachEvent;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.function.DeploymentConfiguration;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.Constants;

@Route("pnpm-enabled")
public class PnpmEnabledView extends Div {

@Autowired
private Environment env;

@Override
protected void onAttach(AttachEvent attachEvent) {
boolean isPnpm = new File("node_modules/.modules.yaml").exists();
String enableProperty = env.getProperty(
"vaadin." + Constants.SERVLET_PARAMETER_ENABLE_PNPM);
DeploymentConfiguration configuration = getUI().get().getSession()
.getService().getDeploymentConfiguration();
Div checkPnpm = new Div();
checkPnpm.setId("check-pnpm");
checkPnpm.setText(
String.valueOf(Boolean.TRUE.toString().equals(enableProperty)
&& !configuration.isProductionMode()));
Div pnpm = new Div();
pnpm.setId("pnpm");
pnpm.setText(String.valueOf(isPnpm));

add(checkPnpm, pnpm);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2000-2020 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.flow.spring.test;

import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class PnpmEnabledIT extends AbstractSpringTest {

@Override
protected String getTestPath() {
return "/pnpm-enabled";
}

@Test
public void checkPnpm() throws Exception {
open();

WebElement checkPnpm = findElement(By.id("check-pnpm"));
Assume.assumeTrue(Boolean.TRUE.toString().equals(checkPnpm.getText()));

WebElement isPnpm = findElement(By.id("pnpm"));
Assert.assertEquals(Boolean.TRUE.toString(), isPnpm.getText());
}
}
3 changes: 3 additions & 0 deletions vaadin-spring-tests/test-spring-white-list/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
<version>${vaadin.flow.version}</version>
<executions>
<execution>
<configuration>
<pnpmEnable>true</pnpmEnable>
</configuration>
<goals>
<goal>prepare-frontend</goal>
</goals>
Expand Down

0 comments on commit d81296e

Please sign in to comment.