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

Placemark New Features #1263

Merged
merged 19 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions cypress/e2e/notes-100/share-a-note.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ describe('Notes-100: Share a note', () => {
context('Open Notes > first note, click share in note footer', () => {
beforeEach(() => {
cy.get('[data-testid="control-button-notes"]').click()
cy.get('[data-testid="list-notes"] :nth-child(1) > [data-testid="note-body"]').first().click()
cy.get('[data-testid="list-notes"] [data-testid="note-body"]').first().click()

cy.window().then((win) => {
cy.stub(win.navigator.clipboard, 'writeText').as('clipboardSpy')
.resolves()
})
cy.get('.MuiCardActions-root > [data-testid="Share"] > .icon-share').click()
cy.get('.MuiCardActions-root > [data-testid="Share"] > .icon-share').first().click()
})

it('Link copied, SnackBar reports that - Screen', () => {
Expand Down
77 changes: 77 additions & 0 deletions cypress/e2e/placemarks-100/marker-selection.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import '@percy/cypress'
import {Raycaster, Vector2, Vector3} from 'three'
import {homepageSetup, returningUserVisitsHomepageWaitForModel} from '../../support/utils'
import {MOCK_MARKERS} from '../../../src/Components/Markers/Marker.fixture'


/** {@link https://github.com/bldrs-ai/Share/issues/1054} */
describe('Placemarks 100: Not visible when notes is not open', () => {
beforeEach(homepageSetup)
context('Returning user visits homepage', () => {
beforeEach(returningUserVisitsHomepageWaitForModel)

context('Select a marker', () => {
let win
beforeEach(() => {
cy.get('[data-testid="control-button-notes"]').click()
cy.get('[data-testid="list-notes"]')
cy.get('[data-testid="panelTitle"]').contains('NOTES')

cy.window().then((window) => {
win = window
})
// eslint-disable-next-line cypress/no-unnecessary-waiting, no-magic-numbers
cy.wait(1000)
})
it('should select a marker and url hash should change', () => {
const {markerObjects, camera, domElement} = win.markerScene

// Assert that markers exist
expect(markerObjects.length).to.eq(2)

// Get the first marker's position
const markerCoordinates = MOCK_MARKERS[0].coordinates
const markerPosition = new Vector3(markerCoordinates[0], markerCoordinates[1], markerCoordinates[2])

// Project marker position to NDC
const ndc = markerPosition.project(camera)

// Calculate the screen position of the marker
const canvasRect = domElement.getBoundingClientRect()
// eslint-disable-next-line no-mixed-operators
const screenX = ((ndc.x + 1) / 2) * canvasRect.width + canvasRect.left
// eslint-disable-next-line no-mixed-operators
const screenY = ((1 - ndc.y) / 2) * canvasRect.height + canvasRect.top


// Perform raycasting after updating the pointer
const raycaster = new Raycaster()
const pointer = new Vector2()
// eslint-disable-next-line no-mixed-operators
pointer.x = ((screenX - canvasRect.left) / canvasRect.width) * 2 - 1
// eslint-disable-next-line no-mixed-operators
pointer.y = -((screenY - canvasRect.top) / canvasRect.height) * 2 + 1

raycaster.setFromCamera(pointer, camera)
const intersects = raycaster.intersectObjects(markerObjects)

// Assert that the raycaster intersects with the marker
expect(intersects.length).to.be.greaterThan(0)

cy.get('[data-testid="cadview-dropzone"]').then(($el) => {
const event = new MouseEvent('mousedown', {
bubbles: true,
cancelable: true,
clientX: screenX,
clientY: screenY,
})
$el[0].dispatchEvent(event)
})

// Assert that the URL hash contains marker coordinates
const expectedHash = `#m:${markerCoordinates[0]},${markerCoordinates[1]},${markerCoordinates[2]}`
cy.url().should('include', expectedHash)
})
})
})
})
43 changes: 43 additions & 0 deletions cypress/e2e/placemarks-100/marker-visibility.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import '@percy/cypress'
import {homepageSetup, returningUserVisitsHomepageWaitForModel} from '../../support/utils'


/** {@link https://github.com/bldrs-ai/Share/issues/1054} */
describe('Placemarks 100: Not visible when notes is not open', () => {
beforeEach(homepageSetup)
context('Returning user visits homepage', () => {
beforeEach(returningUserVisitsHomepageWaitForModel)
it('MarkerControl should not exist', () => {
cy.get('[data-testid="markerControl"]').should('not.exist')
})

context('Open Notes and MarkerControl should exist', () => {
let win
beforeEach(() => {
cy.get('[data-testid="control-button-notes"]').click()

cy.get('[data-testid="list-notes"]')
cy.get('[data-testid="panelTitle"]').contains('NOTES')

cy.window().then((window) => {
win = window
})
// eslint-disable-next-line cypress/no-unnecessary-waiting, no-magic-numbers
cy.wait(1500)
})
it('MarkerControl should exist', () => {
// Access the scene objects
const markers = win.markerScene.markerObjects

// Assert that markers exist
expect(markers.length).to.eq(2)

// Check visibility of markers
markers.forEach((marker) => {
// eslint-disable-next-line no-unused-expressions
expect(marker.userData.id).to.exist
})
})
})
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bldrs",
"version": "1.0.1133",
"version": "1.0.1151",
"main": "src/index.jsx",
"license": "AGPL-3.0",
"homepage": "https://github.com/bldrs-ai/Share",
Expand Down
18 changes: 18 additions & 0 deletions src/Components/Markers/Marker.fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const MOCK_MARKERS = [
{
id: '14',
// eslint-disable-next-line no-magic-numbers
coordinates: [-47.076, 18.655, 0, 0, 0, 1],
isActive: false,
activeColor: 0xff0000,
inactiveColor: 0xa9a9a9,
},
{
id: '13',
// eslint-disable-next-line no-magic-numbers
coordinates: [-18, 20.289, -3.92, 1, 0, 0],
isActive: false,
activeColor: 0xff0000,
inactiveColor: 0xa9a9a9,
},
]
Loading
Loading