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

feat: drawing tile navigator panel (PT-185987214) #2416

Merged
merged 26 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e134304
feat: drawing tile navigator panel (PT-185987214)
emcelroy Sep 24, 2024
c12a82e
chore: move toolbar button component to shared location
emcelroy Sep 30, 2024
8bb86f2
Merge branch 'master' into 185987214-drawing-tile-navigator-panel
emcelroy Sep 30, 2024
37cf963
Merge branch 'master' into 185987214-drawing-tile-navigator-panel
emcelroy Oct 1, 2024
cdc1641
chore: refactor drawing tile tests
emcelroy Oct 2, 2024
dd41f05
refactor: add navigatable tile model, save navigator position, use re…
emcelroy Oct 2, 2024
afe2666
fix: drawing elements clipped by viewport boundaries
emcelroy Oct 3, 2024
0598cc9
update class users in place
scytacki Sep 27, 2024
40f0c20
Switch to using the MST environment for the groups store
scytacki Sep 27, 2024
d7d950b
Sync the group membership
scytacki Sep 27, 2024
ab627ff
look up users instead of copying full name and initials
scytacki Sep 29, 2024
c000b36
switch authAndConnect to async await
scytacki Sep 29, 2024
670d5cd
add support for removed users
scytacki Sep 30, 2024
25ab4e3
portal service object and refresh class info
scytacki Sep 30, 2024
fa18fa6
hide users removed from the class
scytacki Oct 1, 2024
bac6d5b
kick removed users out of groups first
scytacki Oct 1, 2024
9fc990c
add test of removed users
scytacki Oct 2, 2024
d00a822
chore: update drawing test snapshots
emcelroy Oct 4, 2024
d3f4af9
fix: increase wait for animation
emcelroy Oct 4, 2024
2b8f966
Merge branch 'master' into 185987214-drawing-tile-navigator-panel
emcelroy Oct 4, 2024
1c688a6
chore: update non-legacy drawing test snapshots
emcelroy Oct 4, 2024
bf64e8a
refactor: simplify showing elements outside viewport
emcelroy Oct 7, 2024
58c7e68
Merge branch 'master' into 185987214-drawing-tile-navigator-panel
emcelroy Oct 7, 2024
8f1ffcf
chore: remove plugin dependencies,
emcelroy Oct 8, 2024
953cef8
Merge branch 'master' into 185987214-drawing-tile-navigator-panel
emcelroy Oct 8, 2024
e50c2a4
chore: remove IDrawingTileProps import
emcelroy Oct 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function testTilesNotReadOnly(tab, position) {
cy.get('.'+tab).find(position + ' .text-tool').should('not.have.class', 'read-only');
cy.get('.'+tab).find(position + ' .table-tool-tile').should('not.have.class', 'readonly');
cy.get('.'+tab).find(position + ' .geometry-tool-tile').should('not.have.class', 'readonly');
cy.get('.'+tab).find(position + ' .drawing-tool').should('not.have.class', 'read-only');
cy.get('.'+tab).find(position + ' .drawing-tool').not('[data-testid="tile-navigator"] .drawing-tool').should('not.have.class', 'read-only');
cy.get('.'+tab).find(position + ' .image-tool').should('not.have.class', 'read-only');
cy.get('.'+tab).find(position + ' .numberline-tool-tile').should('not.have.class', 'readonly');
cy.get('.'+tab).find(position + ' .data-card-tool-tile').should('not.have.class', 'readonly');
Expand All @@ -46,7 +46,7 @@ function testTilesReadOnly(tab, position) {
cy.get('.'+tab).find(position + ' .text-tool').should('have.class', 'read-only');
cy.get('.'+tab).find(position + ' .table-tool-tile').should('have.class', 'readonly');
cy.get('.'+tab).find(position + ' .geometry-tool-tile').should('have.class', 'readonly');
cy.get('.'+tab).find(position + ' .drawing-tool').should('have.class', 'read-only');
cy.get('.'+tab).find(position + ' .drawing-tool').not('[data-testid="tile-navigator"] .drawing-tool').should('have.class', 'read-only');
cy.get('.'+tab).find(position + ' .image-tool').should('have.class', 'read-only');
cy.get('.'+tab).find(position + ' .numberline-tool-tile').should('have.class', 'readonly');
cy.get('.'+tab).find(position + ' .data-card-tool-tile').should('have.class', 'readonly');
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/functional/tile_tests/diagram_tool_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ context('Diagram Tool Tile', function () {

// Draw tile and toolbar buttons render
drawTile.getDrawTile().should("exist");
drawTile.getDrawTile().click();
drawTile.getDrawTile().first().click();
drawTile.getDrawToolNewVariable().should("exist").should("be.enabled");
drawTile.getDrawToolEditVariable().should("exist").should("be.disabled");
drawTile.getDrawToolInsertVariable().should("exist").should("be.disabled");
Expand Down
10 changes: 6 additions & 4 deletions cypress/e2e/functional/tile_tests/drawing_tool_spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import ClueCanvas from '../../../support/elements/common/cCanvas';
import DrawToolTile from '../../../support/elements/tile/DrawToolTile';
import ImageToolTile from '../../../support/elements/tile/ImageToolTile';
import TileNavigator from "../../../support/elements/tile/TileNavigator";
import { LogEventName } from '../../../../src/lib/logger-types';

let clueCanvas = new ClueCanvas,
drawToolTile = new DrawToolTile;
const clueCanvas = new ClueCanvas;
const drawToolTile = new DrawToolTile;
const imageToolTile = new ImageToolTile;
const tileNavigator = new TileNavigator;

function beforeTest() {
const queryParams = `${Cypress.config("qaUnitStudent5")}`;
Expand Down Expand Up @@ -563,8 +565,8 @@ context('Draw Tool Tile', function () {
drawToolTile.getDrawTile()
.trigger("pointerdown", 150, 150)
.trigger("pointerup", 150, 150);
drawToolTile.getTextDrawing().get('textarea').type("The five boxing wizards jump quickly.{enter}");
drawToolTile.getTextDrawing().get('text tspan').should("exist").and("have.length", 7);
drawToolTile.getTextDrawing().find('textarea').type("The five boxing wizards jump quickly.{enter}");
drawToolTile.getTextDrawing().find('text tspan').should("exist").and("have.length", 5);

cy.log("deletes text object");
drawToolTile.getDrawToolSelect().click();
Expand Down
73 changes: 73 additions & 0 deletions cypress/e2e/functional/tile_tests/tile_navigator_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import ClueCanvas from "../../../support/elements/common/cCanvas";
import TileNavigator from "../../../support/elements/tile/TileNavigator";
import DrawToolTile from "../../../support/elements/tile/DrawToolTile";
import { LogEventName } from "../../../../src/lib/logger-types";

let clueCanvas = new ClueCanvas,
drawToolTile = new DrawToolTile,
tileNavigator = new TileNavigator;

function beforeTest() {
const queryParams = `${Cypress.config("qaUnitStudent5")}`;
cy.visit(queryParams);
cy.waitForLoad();
cy.showOnlyDocumentWorkspace();
}

context("Tile Navigator", () => {
it("renders with a draw tool tile by default", () => {
beforeTest();

clueCanvas.addTile("drawing");
drawToolTile.getDrawTile().should("exist");
tileNavigator.getTileNavigator().should("exist");

clueCanvas.toolbarButtonIsEnabled("drawing", "navigator");
clueCanvas.getToolbarButtonToolTip("drawing", "navigator").should("exist");
clueCanvas.getToolbarButtonToolTipText("drawing", "navigator").should("eq", "Hide Navigator");

cy.log("Draw a rectangle");
drawToolTile.drawRectangle(100, 50, 20, 20);
tileNavigator.getRectangleDrawing().should("exist").and("have.length", 1);
});
it("can be hidden and shown", () => {
beforeTest();

cy.window().then(win => {
cy.stub(win.ccLogger, "log").as("log");
});

clueCanvas.addTile("drawing");
cy.log("Hide tile navigator");
clueCanvas.clickToolbarButton("drawing", "navigator");
clueCanvas.getToolbarButtonToolTipText("drawing", "navigator").should("eq", "Show Navigator");
tileNavigator.getTileNavigator().should("not.exist");
cy.get("@log")
.should("have.been.been.calledWith", LogEventName.DRAWING_TOOL_CHANGE, Cypress.sinon.match.object)
.its("lastCall.args.1").should("deep.include", { operation: "hideNavigator" });

cy.log("Show tile navigator");
clueCanvas.clickToolbarButton("drawing", "navigator");
clueCanvas.getToolbarButtonToolTipText("drawing", "navigator").should("eq", "Hide Navigator");
tileNavigator.getTileNavigator().should("exist");
cy.get("@log")
.should("have.been.been.calledWith", LogEventName.DRAWING_TOOL_CHANGE, Cypress.sinon.match.object)
.its("lastCall.args.1").should("deep.include", { operation: "showNavigator" });
});
it("is at the bottom of the drawing tile by default but can be moved to the top", () => {
beforeTest();

clueCanvas.addTile("drawing");
tileNavigator.getTileNavigator().should("exist").and("not.have.class", "top");

cy.log("Move tile navigator to the top of the drawing tile in a quick animation");
tileNavigator.getTileNavigatorPlacementButton().click();
cy.wait(300);
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need the explicit wait here (or in line 70), since Cypress will automatically wait up to its timeout for a condition to become true.

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 know that's true generally, but found these were required to make the test pass consistently. I believe it has something to do with how the component waits for the animation to complete before updating the model which is what causes the class name to change. I'm not sure why explicitly setting a wait makes it always work. I did spend some time looking into it but wasn't able to figure out a way to make them unnecessary. For now at least I'd like to leave them so I can complete the main task.

tileNavigator.getTileNavigatorContainer().should("have.class", "top");

cy.log("Move tile navigator to the bottom of the drawing tile in a quick animation");
tileNavigator.getTileNavigatorPlacementButton().click();
cy.wait(300);
tileNavigator.getTileNavigatorContainer().should("not.have.class", "top");
});
});
19 changes: 19 additions & 0 deletions cypress/support/elements/common/cCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,25 @@ class ClueCanvas {
});
}

/**
* Locate a requested toolbar button's tooltip element.
* @param {*} tileType string name of the tile
* @param {*} buttonName string name of the button
*/
getToolbarButtonToolTip(tileType, buttonName) {
return cy.root().find(`[data-test=canvas] .tile-toolbar.${tileType}-toolbar .toolbar-button.${buttonName}`)
.parent()
.filter('[data-tooltipped]');
}

/**
* Locate a requested toolbar button's tooltip element and return its text value
* @param {*} tileType string name of the tile
* @param {*} buttonName string name of the button
*/
getToolbarButtonToolTipText(tileType, buttonName) {
return this.getToolbarButtonToolTip(tileType, buttonName).invoke('attr', 'data-original-title');
}
}

export default ClueCanvas;
28 changes: 15 additions & 13 deletions cypress/support/elements/tile/DrawToolTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ class DrawToolTile{
return cy.get(`${workspaceClass || ".primary-workspace"} .editable-tile-title-text`);
}
getDrawTileComponent(){
return cy.get('.primary-workspace [data-testid=drawing-tool]');
return cy.get('.primary-workspace [data-testid=drawing-tool]')
.not('[data-testid=tile-navigator] [data-testid=drawing-tool]');
}
getDrawTileObjectCanvas(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .object-canvas');
return this.getDrawTileComponent().find('.object-canvas');
}
getDrawTileShowSortPanel(){
return cy.get('.primary-workspace .drawing-tool .object-list');
Expand Down Expand Up @@ -79,37 +80,38 @@ class DrawToolTile{
}

getFreehandDrawing(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg path');
return this.getDrawTileComponent().find('.drawing-layer svg path');
}
getVectorDrawing(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg g.vector');
return this.getDrawTileComponent().find('.drawing-layer svg g.vector');
}
getRectangleDrawing(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg rect.rectangle');
return this.getDrawTileComponent().find('.drawing-layer svg rect.rectangle');
}
getEllipseDrawing(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg ellipse');
return this.getDrawTileComponent().find('.drawing-layer svg ellipse');
}
getImageDrawing(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg image');
return this.getDrawTileComponent().find('.drawing-layer svg image');
}
getTextDrawing(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg g.text');
return this.getDrawTileComponent().find('.drawing-layer svg g.text');
}
getSelectionBox(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg [data-testid=selection-box]');
return this.getDrawTileComponent().find('.drawing-layer svg [data-testid=selection-box]');
}
getHighlightBox(){
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg [data-testid=highlight-box]');
return this.getDrawTileComponent().find('.drawing-layer svg [data-testid=highlight-box]');
}
getVariableChip() {
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer .drawing-variable.variable-chip');
return this.getDrawTileComponent().find('.drawing-layer .drawing-variable.variable-chip');
}
getGhostGroup() {
return cy.get('.primary-workspace [data-testid=drawing-tool] .drawing-layer svg g.ghost');
return this.getDrawTileComponent().find('.drawing-layer svg g.ghost');
}
getDrawTileTitle(workspaceClass){
return cy.get(`${workspaceClass || ".primary-workspace"} .drawing-tool-tile .editable-tile-title`);
return cy.get(`${workspaceClass || ".primary-workspace"} .drawing-tool-tile .editable-tile-title`)
.not('[data-testid=tile-navigator] .editable-tile-title');
}
drawRectangle(x, y, width=25, height=25) {
this.getDrawToolRectangle().last().click();
Expand Down
16 changes: 16 additions & 0 deletions cypress/support/elements/tile/TileNavigator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class TileNavigator {
getTileNavigator() {
return cy.get('.primary-workspace [data-testid=tile-navigator]');
}
getTileNavigatorContainer() {
return cy.get('.primary-workspace [data-testid=tile-navigator-container]');
}
getTileNavigatorPlacementButton() {
return cy.get('.primary-workspace [data-testid=tile-navigator-placement-button]');
}
getRectangleDrawing(){
return cy.get('.primary-workspace [data-testid=tile-navigator-container] .drawing-layer svg rect.rectangle');
}
}

export default TileNavigator;
9 changes: 9 additions & 0 deletions src/assets/icons/hide-navigator-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/assets/icons/navigator-move-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/assets/icons/navigator-scroll-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/icons/show-navigator-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/clue/app-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@
"zoom-in",
"zoom-out",
"fit-all",
"navigator",
"|",
"duplicate",
"delete"
Expand Down
1 change: 1 addition & 0 deletions src/components/tiles/tile-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface IRegisterTileApiProps {

export interface ITileProps extends ITileBaseProps, IRegisterTileApiProps {
tileElt: HTMLElement | null;
navigatorAllowed?: boolean;
}

interface IProps extends ITileBaseProps {
Expand Down
Loading
Loading