Skip to content

Commit

Permalink
fix: e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
m8vago committed Mar 1, 2024
1 parent c01c584 commit f0dc43b
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 73 deletions.
48 changes: 24 additions & 24 deletions images/playwright/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions images/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"homepage": "https://github.com/dyrector-io/playwright#readme",
"dependencies": {
"@playwright/test": "^1.38.0",
"playwright": "^1.38.0"
"@playwright/test": "^1.42.0",
"playwright": "^1.42.0"
}
}
4 changes: 2 additions & 2 deletions web/crux-ui/e2e/utils/node-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const installDagent = async (page: Page) => {
await page.goto(TEAM_ROUTES.node.list())
await page.waitForSelector('h2:text-is("Nodes")')

await page.locator('button:has-text("Add")').click()

page.addListener('framenavigated', frame => console.info('PW navigated', frame.url()))
await page.locator('button:text-is("Add")').click()
await page.waitForSelector('h4:text-is("New node")')

Check failure on line 13 in web/crux-ui/e2e/utils/node-helper.ts

View workflow job for this annotation

GitHub Actions / e2e

[global-setup] › utils/global.setup.spec.ts:21:5 › global setup

1) [global-setup] › utils/global.setup.spec.ts:21:5 › global setup ─────────────────────────────── TimeoutError: page.waitForSelector: Timeout 30000ms exceeded. Call log: - waiting for locator('h4:text-is("New node")') to be visible at utils/node-helper.ts:13 11 | page.addListener('framenavigated', frame => console.info('PW navigated', frame.url())) 12 | await page.locator('button:text-is("Add")').click() > 13 | await page.waitForSelector('h4:text-is("New node")') | ^ 14 | 15 | await page.locator('input[name=name] >> visible=true').fill(DAGENT_NODE) 16 | at installDagent (/__w/dyrectorio/dyrectorio/web/crux-ui/e2e/utils/node-helper.ts:13:14) at /__w/dyrectorio/dyrectorio/web/crux-ui/e2e/utils/global.setup.spec.ts:64:3

await page.locator('input[name=name] >> visible=true').fill(DAGENT_NODE)
Expand Down
58 changes: 28 additions & 30 deletions web/crux-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions web/crux-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"yup": "^1.2.0"
},
"devDependencies": {
"@playwright/test": "^1.38.0",
"@playwright/test": "^1.42.0",
"@types/google-protobuf": "^3.15.6",
"@types/jest": "^29.5.3",
"@types/jsoneditor": "^9.9.0",
Expand All @@ -77,7 +77,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"jest": "^29.6.2",
"next-translate-plugin": "^2.5.2",
"playwright": "^1.38.0",
"playwright": "^1.42.0",
"postcss": "^8.4.27",
"prettier": "^3.0.1",
"prettier-plugin-organize-imports": "^3.2.3",
Expand Down
4 changes: 3 additions & 1 deletion web/crux-ui/src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export const Layout = (props: LayoutProps) => {
{topBarContent}
</Topbar>

<div className="flex flex-col h-full">{children}</div>
<div key={router.asPath} className="flex flex-col h-full">
{children}
</div>

<Footer className="mt-auto" />
</div>
Expand Down
11 changes: 1 addition & 10 deletions web/crux-ui/src/hooks/use-anchor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'

const anchorOfPath = (path: string): string | null => {
const parts = path.split('#')
Expand All @@ -14,15 +13,7 @@ const useAnchor = (): string | null => {
const router = useRouter()
const path = router.asPath

const [anchor, setAnchor] = useState(null)

useEffect(() => {
const newAnchor = anchorOfPath(path)

setAnchor(newAnchor)
}, [path])

return anchor
return anchorOfPath(path)
}

export default useAnchor
23 changes: 21 additions & 2 deletions web/crux-ui/src/pages/[teamSlug]/nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import useTeamRoutes from '@app/hooks/use-team-routes'
import useWebSocket from '@app/hooks/use-websocket'
import { DyoNode, NODE_STATUS_VALUES, NodeEventMessage, NodeStatus, WS_TYPE_NODE_EVENT } from '@app/models'
import { ANCHOR_NEW, ListRouteOptions, ROUTE_DOCS, TeamRoutes } from '@app/routes'
import { withContextAuthorization } from '@app/utils'
import { isServerSide, withContextAuthorization } from '@app/utils'
import { getCruxFromContext } from '@server/crux-api'
import clsx from 'clsx'
import { GetServerSidePropsContext } from 'next'
Expand Down Expand Up @@ -51,7 +51,16 @@ const NodesPage = (props: NodesPageProps) => {
})

const creating = anchor === ANCHOR_NEW
console.info(
new Date().toISOString(),
'creating',
creating,
anchor,
router.asPath,
!isServerSide() ? document.location.href : 'ssr',
)
const submit = useSubmit()
console.info('creating', creating, anchor, router.asPath)

const socket = useWebSocket(routes.node.socket(), {
onError: _ => {
Expand Down Expand Up @@ -84,7 +93,17 @@ const NodesPage = (props: NodesPageProps) => {
}

const onRouteOptionsChange = async (routeOptions: ListRouteOptions) => {
await router.replace(routes.node.list(routeOptions))
console.info(new Date().toISOString(), 'navigation', routes.node.list(routeOptions), routeOptions)

console.info(
new Date().toISOString(),
'nav-creating',
creating,
anchor,
router.asPath,
!isServerSide() ? document.location.href : 'ssr',
)
await router.replace(`${routes.node.list(routeOptions)}`)
}

const pageLink: BreadcrumbLink = {
Expand Down

0 comments on commit f0dc43b

Please sign in to comment.