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

Diagram gui #54

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open

Diagram gui #54

wants to merge 43 commits into from

Conversation

artbez
Copy link
Contributor

@artbez artbez commented Nov 3, 2016

To solve #53 issue.
For diagram creating in GUI-tests we need to analyze html code and manipulate it.
Add some instruments to make it more simple.

1. Add spring framework support
2. Add Opener and Auther services
3. Add PropertySourcesPlaceholderConfigurer
4. Add some auth and open page tests
1. Create Scene service
2. Create Pallete service
3. Add dragAndDrop test
1. Add remove method
2. Add move method
3. Test them
4. Add getPosition method
5. Add JavaDoc
1. Add logging to Scene
2. Add logging to Pallete
1. Now scene can link two elements
2. Add test for it
3. Add JavaDoc
1. Add setProperty
2. Add getProperty
3. Add test of them
1. Add SceneWindow class which describes part of the scene that user see
2. Add moveElement test
1. Code refactor
2. Add moveToCell method in Scene
3. Add focus method in Scene
4. Add tests
1. Add test with 3 nodes and 2 links
2. Add Exception for authorization
1. Fix movement bug
2. Fix remove element bug
@artbez artbez force-pushed the diagram-gui branch 5 times, most recently from 4a0478c to 678afdc Compare November 23, 2016 11:23
1. Change names of nodes to string values, which are shown in browser
2. Add moveSomeNodes test
@artbez artbez force-pushed the diagram-gui branch 2 times, most recently from d8e9f0b to be0e395 Compare November 25, 2016 00:35
1. Make checkbox property working
2. Add fillProperty test
3. Removed unused package
@artbez artbez force-pushed the diagram-gui branch 3 times, most recently from 0eb1692 to 0d8ce72 Compare February 26, 2017 00:39
1. Add Block and Link providers
2. Add Focus and Move helpers
@artbez artbez force-pushed the diagram-gui branch 7 times, most recently from 4e9cbf9 to ffcae07 Compare February 26, 2017 20:36
1. Fix bug with movement
2. Add scrolling by movement on the client side
3. Code refactor
this.scene.getLinkById(cellView.model.id);
var sceneWrapper: HTMLDivElement = <HTMLDivElement> $(".scene-wrapper")[0];
var boundingBox: any = sceneWrapper.getBoundingClientRect();
if (element instanceof DefaultDiagramNode) {
Copy link
Member

Choose a reason for hiding this comment

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

I guess we better move this code to a new method with a nice and understandable name. or even into several methods


class Scroller {

private _scroll: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

why start using underscore prefix here? we haven't used it before, as far as I know

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PageFactory {
Copy link
Member

Choose a reason for hiding this comment

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

javadoc comments are welcome :) at least for classes

Copy link
Member

Choose a reason for hiding this comment

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

these comments should describe not only what a class or a method does, but also what other classes use it and how

public interface Pallete {

/**
* Chose element from Pallete.
Copy link
Member

Choose a reason for hiding this comment

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

"Chooses an element"


public static final int POINT_IN_CELL = 25;

private final int xAbsolute;
Copy link
Member

Choose a reason for hiding this comment

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

I guess final field's name should be in caps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By "5.2.7 Local variable names" of the Style guide we should use lowerCamelCase.


public class SceneElementImpl implements SceneElement {

private By by;
Copy link
Member

Choose a reason for hiding this comment

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

This looks awesome, but I honestly have no clue what it means :)
A comment would be nice.

* @param element element to move
* @param dist position to move
* */
void move(final Block element, final Coordinate dist) throws ElementNotOnTheSceneException;
Copy link
Member

Choose a reason for hiding this comment

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

would not this method make more sense if it was inside a Block? I mean, block.move() instead of scene.move(block)


Actions actions = new Actions(driver);
actions.clickAndHold(element.getInnerSeleniumElement());
if (Math.abs(dist.getXAbsolute() - element.getCoordinateOnScene().getXAbsolute()) < sizeHor / 2
Copy link
Member

Choose a reason for hiding this comment

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

these conditions are very hard to understand, we better move them into separate functions

}
}

private void movement(Actions actions, SceneElement element, OffsetObject offset, Predicate<Coordinate> cond) {
Copy link
Member

Choose a reason for hiding this comment

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

function's name should be a verb

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = AppInit.class, loader = AnnotationConfigContextLoader.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class DiaTest {
Copy link
Member

Choose a reason for hiding this comment

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

does 'dia' means 'diagram'?

artbez added 2 commits March 22, 2017 00:44
# Conflicts:
#	editor-core/src/main/webapp/app/core/editorCore/controller/SceneController.ts
#	ui-testing/ui-testing.iml
# Conflicts:
#	editor-core/src/main/webapp/app/core/editorCore/controller/SceneController.ts
#	ui-testing/ui-testing.iml
@jzuken jzuken assigned jzuken and TanVD and unassigned jzuken Apr 10, 2017
Copy link
Contributor

@TanVD TanVD left a comment

Choose a reason for hiding this comment

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

Changes requested. One more review needed.

.travis.yml Outdated
@@ -68,7 +69,7 @@ script:

- cd ../ui-testing
- mvn test -P travis &
- sleep 30
- sleep 1000
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I understand you can just not to use '&' and you will not need sleep

@@ -0,0 +1,47 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this file? I did not found any call of this script in changed code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This file is needed in case we want to run all services with gui tests.
By this we check that all services are running. You can see that in pom.xml.

@@ -11,7 +11,9 @@

<rule ref="rulesets/java/braces.xml"/>

<rule ref="rulesets/java/codesize.xml"/>
<rule ref="rulesets/java/codesize.xml">
<exclude name="TooManyMethods" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? We do have classes with more than ten business-logic methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I break this rule only if I describe services. For example, service Scene provides more than ten methods for users.


/** Describes WMP pages in browser. */
public enum Page {
Auth("auth"), Dashboard("dashboard"), EditorRobots("robotsEditor"), EditorBPMN("bpmnEditor");
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to have one enum element by line

public enum Page {
Auth("auth"), Dashboard("dashboard"), EditorRobots("robotsEditor"), EditorBPMN("bpmnEditor");

private String identify;
Copy link
Contributor

Choose a reason for hiding this comment

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

'name' sounds better...


import static com.codeborne.selenide.Selenide.$;

/** All Scene elements have selector by which we can clearly define their web instances.
Copy link
Contributor

Choose a reason for hiding this comment

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

Use standard style of doc if it not fits in one line

public void moveToCell(final Block block, final int cellX, final int cellY) {
logger.info("Move element {} to cell ({}, {})", block, cellX, cellY);
try {
sceneWindow.move(block, new Coordinate(cellX * 25, cellY * 25));
Copy link
Contributor

Choose a reason for hiding this comment

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

Use constant you have already defined (POINT_IN_CELL) instead of magic numbers

/** Used for authentication in current browser session. */
public interface Auther {

/** Realizes authentication to the wmp.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say 'Implements'

* An error must be shown.
*/
@Test
public void authWrongTest() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Random test are bad tests. WrongLogin and WrongPassword variable should be equal for every pass of test.

* @return true if it is
*/
private boolean inAuthPage() {
return $(byText("Sign in to continue to Auth")).exists();
Copy link
Contributor

Choose a reason for hiding this comment

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

And what if I will change this text? You can add your unique flags (in comments, for example) to every page of project. I think it is better solution for identification of page.

Copy link
Contributor Author

@artbez artbez Apr 27, 2017

Choose a reason for hiding this comment

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

Yes, I use urls of pages as an identity flag, but only in next pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants