8000 feat(web): add team slug by m8vago · Pull Request #752 · dyrector-io/dyrectorio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(web): add team slug #752

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

Merged
merged 26 commits into from
Aug 1, 2023
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
12 changes: 6 additions & 6 deletions web/crux-ui/e2e/utils/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-cycle */
import { ATTRIB_CSRF, HEADER_SET_COOKIE } from '@app/const'
import { TeamRoutes } from '@app/routes'
import { findAttributes } from '@app/utils'
import {
Configuration,
Expand All @@ -18,10 +19,13 @@ export const MAILSLURPER_TIMEOUT = 30000 // millis
export const USER_EMAIL = 'john.doe@example.com'
export const USER_PASSWORD = 'TestPw23233'
export const USER_TEAM = "John's Team"
export const USER_TEAM_SLUG = 'jot'
export const USER_FIRSTNAME = 'John'
export const USER_LASTNAME = 'Doe'
export const USER_FULLNAME = `${USER_FIRSTNAME} ${USER_LASTNAME}`

export const TEAM_ROUTES = new TeamRoutes(USER_TEAM_SLUG)

export const DAGENT_NODE = 'dagent-deployable'
export const SCREENSHOTS_FOLDER = 'screenshots'

Expand Down Expand Up @@ -73,13 +77,9 @@ export const kratosFrontendFromBaseURL = (baseURL?: string) => {
return new FrontendApi(kratosConfig)
}

export const kratosFromConfig = (baseURL: string) => {
return kratosFromBaseURL(baseURL)
}
export const kratosFromConfig = (baseURL: string) => kratosFromBaseURL(baseURL)

export const kratosFrontendFromConfig = (baseURL: string) => {
return kratosFrontendFromBaseURL(baseURL)
}
export const kratosFrontendFromConfig = (baseURL: string) => kratosFrontendFromBaseURL(baseURL)

export const createUser = async (
kratos: IdentityApi,
Expand Down
13 changes: 9 additions & 4 deletions web/crux-ui/e2e/utils/global.setup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/* eslint-disable import/no-extraneous-dependencies */
import { ROUTE_DASHBOARD, ROUTE_LOGIN, ROUTE_REGISTRIES, ROUTE_TEAMS_CREATE } from '@app/routes'
import { ROUTE_LOGIN, ROUTE_TEAMS_CREATE } from '@app/routes'
import { test } from '@playwright/test'
import { BASE_URL, STORAGE_STATE } from '../../playwright.config'
import {
createUser,
GHCR_MIRROR,
kratosFromConfig,
REGISTRY_NAME,
TEAM_ROUTES,
USER_EMAIL,
USER_PASSWORD,
USER_TEAM,
USER_TEAM_SLUG,
} from './common'
import { globalTeardown } from './global.teardown'
import { installDagent } from './node-helper'
Expand All @@ -34,17 +36,18 @@ test('global setup', async ({ page }) => {
logInfo('creating team')
await page.waitForURL(ROUTE_TEAMS_CREATE)
await page.locator('input[name=name]').fill(USER_TEAM)
await page.locator('input[name=slug]').fill(USER_TEAM_SLUG)
await page.locator('button[type=submit]').click()

await page.waitForURL(ROUTE_DASHBOARD)
await page.waitForURL(TEAM_ROUTES.dashboard.index())

logInfo('saving storage state')
await page.context().storageState({ path: STORAGE_STATE as string })

logInfo('changing registry to ghcr')
await page.goto(ROUTE_REGISTRIES)
await page.goto(TEAM_ROUTES.registry.list())
await page.click('h3:has-text("Docker Hu F438 b Library")')
await page.waitForURL(`${ROUTE_REGISTRIES}/**`)
await page.waitForURL(`${TEAM_ROUTES.registry.list()}/**`)
await page.click('button:has-text("Edit")')
await page.click('button:has-text("Unchecked")')
await page.locator('input[name=name]').fill(REGISTRY_NAME)
Expand All @@ -53,4 +56,6 @@ test('global setup', async ({ page }) => {

logInfo('installing dagent')
await installDagent(page)

logInfo('completed')
})
16 changes: 8 additions & 8 deletions web/crux-ui/e2e/utils/node-helper.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { deploymentDeployUrl, projectUrl, ROUTE_DEPLOYMENTS, ROUTE_NODES, versionUrl } from '@app/routes'
// eslint-disable-next-line import/no-extraneous-dependencies
import { expect, Page } from '@playwright/test'
import { exec, ExecOptions } from 'child_process'
import { DAGENT_NODE, screenshotPath } from './common'
import { DAGENT_NODE, screenshotPath, TEAM_ROUTES } from './common'
import { fillDeploymentPrefix } from './projects'

export const installDagent = async (page: Page) => {
await page.goto(ROUTE_NODES)
await page.goto(TEAM_ROUTES.node.list())

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

Expand All @@ -26,6 +25,7 @@ export const installDagent = async (page: Page) => {
const commandInput = await page.locator('input[readonly]')
const curl = await commandInput.inputValue()

// eslint-disable-next-line @typescript-eslint/no-use-before-define
exec(curl, getInstallScriptExecSettings(), logCmdOutput)

await page.waitForSelector('div.bg-dyo-green')
Expand All @@ -42,9 +42,9 @@ export const deployWithDagent = async (
testName?: string,
): Promise<string> => {
if (versionId) {
await page.goto(versionUrl(projectId, versionId))
await page.goto(TEAM_ROUTES.project.versions(projectId).details(versionId))
} else {
await page.goto(projectUrl(projectId))
await page.goto(TEAM_ROUTES.project.details(projectId))
}

await page.locator('button:has-text("Add deployment")').click()
Expand All @@ -56,7 +56,7 @@ export const deployWithDagent = async (
await fillDeploymentPrefix(page, prefix)

await page.locator('button:has-text("Add")').click()
await page.waitForURL(`${ROUTE_DEPLOYMENTS}/**`)
await page.waitForURL(`${TEAM_ROUTES.deployment.list()}/**`)

const deploymentId = page.url().split('/').pop()

Expand All @@ -65,7 +65,7 @@ export const deployWithDagent = async (
})

await deploy.click()
await page.waitForURL(deploymentDeployUrl(deploymentId))
await page.waitForURL(TEAM_ROUTES.deployment.deploy(deploymentId))

if (ignoreResult) {
return deploymentId
Expand All @@ -76,7 +76,7 @@ export const deployWithDagent = async (
await page.screenshot({ path: screenshotPath(`dagent-deploy-after-1s-${testName}`), fullPage: true })
}

expect(page.url()).toContain(deploymentDeployUrl(deploymentId))
expect(page.url()).toContain(TEAM_ROUTES.deployment.deploy(deploymentId))
await page.getByText('Successful').waitFor()

return deploymentId
Expand Down
6 changes: 4 additions & 2 deletions web/crux-ui/e2e/utils/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ROUTE_NODES } from '@app/routes'
// eslint-disable-next-line import/no-extraneous-dependencies
import { expect, Page } from '@playwright/test'
import { TEAM_ROUTES } from './common'

// eslint-disable-next-line import/prefer-default-export
export const createNode = async (page: Page, name: string) => {
await page.goto(ROUTE_NODES)
await page.goto(TEAM_ROUTES.node.list())

await page.locator('button:has-text("Add")').click()
await expect(page.locator('h4:has-text("New node")')).toHaveCount(1)
Expand Down
28 changes: 14 additions & 14 deletions web/crux-ui/e2e/utils/projects.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable import/no-extraneous-dependencies */
import { ProjectType } from '@app/models'
import { projectUrl, ROUTE_DEPLOYMENTS, ROUTE_PROJECTS, versionUrl } from '@app/routes'
import { expect, Page } from '@playwright/test'
import { REGISTRY_NAME } from './common'
import { REGISTRY_NAME, TEAM_ROUTES } from './common'

export const createProject = async (page: Page, name: string, type: ProjectType) => {
await page.goto(ROUTE_PROJECTS)
await page.goto(TEAM_ROUTES.project.list())

await page.locator('button:has-text("Add")').click()
await expect(page.locator('h4:has-text("New project")')).toHaveCount(1)
Expand All @@ -17,7 +17,7 @@ export const createProject = async (page: Page, name: string, type: ProjectType)

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

await page.waitForURL(`${ROUTE_PROJECTS}/**`)
await page.waitForURL(`${TEAM_ROUTES.project.list()}/**`)

if (type === 'versionless') {
await page.waitForSelector(`span:has-text("Changelog")`)
Expand All @@ -30,7 +30,7 @@ export 10000 const createProject = async (page: Page, name: string, type: ProjectType)
}

export const createVersion = async (page: Page, projectId: string, name: string, type: 'Incremental' | 'Rolling') => {
await page.goto(projectUrl(projectId))
await page.goto(TEAM_ROUTES.project.details(projectId))
await page.waitForSelector(`button:has-text("Add version")`)

await page.locator('button:has-text("Add version")').click()
Expand All @@ -50,7 +50,7 @@ export const createVersion = async (page: Page, projectId: string, name: string,
}

export const createImage = async (page: Page, projectId: string, versionId: string, image: string) => {
await page.goto(versionUrl(projectId, versionId))
await page.goto(TEAM_ROUTES.project.versions(projectId).details(versionId))

const addImage = await page.waitForSelector('button:has-text("Add image")')
await addImage.click()
Expand All @@ -74,7 +74,7 @@ export const createImage = async (page: Page, projectId: string, versionId: stri
}

export const addImageToVersion = async (page: Page, projectId: string, versionId: string, image: string) => {
await page.goto(versionUrl(projectId, versionId))
await page.goto(TEAM_ROUTES.project.versions(projectId).details(versionId))

await page.locator('button:has-text("Add image")').click()
await expect(page.locator('h4:has-text("Add image")')).toHaveCount(1)
Expand All @@ -88,7 +88,7 @@ export const addImageToVersion = async (page: Page, projectId: string, versionId
}

export const addImageToVersionlessProject = async (page: Page, projectId: string, image: string) => {
await page.goto(projectUrl(projectId))
await page.goto(TEAM_ROUTES.project.details(projectId))

await page.locator('button:has-text("Add image")').click()
await expect(page.locator('h4:has-text("Add image")')).toHaveCount(1)
Expand All @@ -107,7 +107,7 @@ export const addDeploymentToVersionlessProject = async (
nodeName: string,
prefix: string | null,
): Promise<{ id: string; url: string }> => {
await page.goto(projectUrl(projectId))
await page.goto(TEAM_ROUTES.project.details(projectId))

await page.locator('button:has-text("Add deployment")').click()
await expect(page.locator('h4:has-text("Add deployment")')).toHaveCount(1)
Expand All @@ -117,7 +117,7 @@ export const addDeploymentToVersionlessProject = async (
await page.locator(`button:has-text("${nodeName}")`).click()

await page.locator('button:has-text("Add")').click()
await page.waitForURL(`${ROUTE_DEPLOYMENTS}/**`)
await page.waitForURL(`${TEAM_ROUTES.deployment.list()}/**`)

const deploymentId = page.url().split('/').pop()
return {
Expand All @@ -133,7 +133,7 @@ export const addDeploymentToVersion = async (
nodeName: string,
prefix: string = null,
): Promise<{ id: string; url: string }> => {
await page.goto(versionUrl(projectId, versionId))
await page.goto(TEAM_ROUTES.project.versions(projectId).details(versionId))

await page.locator('button:has-text("Add deployment")').click()
await expect(page.locator('h4:has-text("Add deployment")')).toHaveCount(1)
Expand All @@ -143,7 +143,7 @@ export const addDeploymentToVersion = async (
await page.locator(`button:has-text("${nodeName}")`).click()

await page.locator('button:has-text("Add")').click()
await page.waitForURL(`${ROUTE_DEPLOYMENTS}/**`)
await page.waitForURL(`${TEAM_ROUTES.deployment.list()}/**`)

return {
id: page.url().split('/').pop(),
Expand All @@ -157,8 +157,8 @@ export const fillDeploymentPrefix = async (page: Page, prefix: string) => {
}

export const deleteProject = async (page: Page, projectId: string): Promise<void> => {
await page.goto(projectUrl(projectId))
await page.goto(TEAM_ROUTES.project.details(projectId))
await page.locator('button:has-text("Delete")').click()
await page.locator('div[data-headlessui-state="open"] button:has-text("Delete")').click()
await page.waitForURL(ROUTE_PROJECTS)
await page.waitForURL(TEAM_ROUTES.project.list())< 10000 /span>
}
11 changes: 6 additions & 5 deletions web/crux-ui/e2e/utils/storages.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ROUTE_STORAGES, storageUrl } from '@app/routes'
// eslint-disable-next-line import/no-extraneous-dependencies
import { Page } from 'playwright'
import { TEAM_ROUTES } from './common'

export const createStorage = async (page: Page, name: string, url: string, accessKey: string, secretKey: string) => {
await page.goto(ROUTE_STORAGES)
await page.goto(TEAM_ROUTES.storage.list())
await page.locator('button:has-text("Add")').click()
await page.locator('div.card h4:has-text("New storage") >> visible=true')
await page.locator('input[id="name"]').fill(name)
Expand All @@ -11,13 +12,13 @@ export const createStorage = async (page: Page, name: string, url: string, acces
await page.locator('input[id="secretKey"]').fill(secretKey)
await page.locator('button:has-text("Save")').click()
await page.locator(`div.card h3:has-text('${name}')`).click()
await page.waitForURL(`${ROUTE_STORAGES}/**`)
await page.waitForURL(`${TEAM_ROUTES.storage.list()}/**`)
return page.url().split('/').pop()
}

export const deleteStorage = async (page: Page, storageId: string) => {
await page.goto(storageUrl(storageId))
await page.goto(TEAM_ROUTES.storage.details(storageId))
await page.locator('button:has-text("Delete")').click()
await page.locator('div[data-headlessui-state="open"] button:has-text("Delete")').click()
await page.waitForURL(`${ROUTE_STORAGES}`)
await page.waitForURL(`${TEAM_ROUTES.storage.list()}`)
}
6 changes: 4 additions & 2 deletions web/crux-ui/e2e/utils/teams.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* eslint-disable import/no-extraneous-dependencies */
import { ROUTE_TEAMS, teamUrl } from '@app/routes'
import { Page } from 'playwright'

export const createTeam = async (page: Page, name: string) => {
export const createTeam = async (page: Page, name: string, slug: string) => {
await page.goto(ROUTE_TEAMS)
await page.locator('button:has-text("Add")').click()
await page.locator('input[id="name"]').fill(name)
await page.locator('input[name="name"]').fill(name)
await page.locator('input[name="slug"]').fill(slug)
await page.locator('button:has-text("Save")').click()
await page.locator(`h4:has-text('${name}')`).click()
await page.waitForURL(`${ROUTE_TEAMS}/**`)
Expand Down
5 changes: 3 additions & 2 deletions web/crux-ui/e2e/utils/templates.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable import/prefer-default-export */
/* eslint-disable import/no-extraneous-dependencies */
import { ProjectType } from '@app/models'
import { ROUTE_PROJECTS, ROUTE_TEMPLATES } from '@app/routes'
import { ROUTE_TEMPLATES } from '@app/routes'
import { Page } from '@playwright/test'
import { TEAM_ROUTES } from './common'

export const createProjectFromTemplate = async (
page: Page,
Expand All @@ -27,7 +28,7 @@ export const createProjectFromTemplate = async (
}

await page.locator('text=Add >> nth=0').click()
await page.waitForURL(`${ROUTE_PROJECTS}/**`)
await page.waitForURL(`${TEAM_ROUTES.project.list()}/**`)

return page.url().split('/').pop()
}
13 changes: 7 additions & 6 deletions web/crux-ui/e2e/with-login/dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { ROUTE_DASHBOARD, ROUTE_PROFILE } from '@app/routes'
import { ROUTE_PROFILE } from '@app/routes'
import { expect, test } from '@playwright/test'
import { TEAM_ROUTES } from 'e2e/utils/common'

test.describe('Onboarding', () => {
test('should be toggleable', async ({ page }) => {
await page.goto(ROUTE_DASHBOARD)
await page.waitForURL(ROUTE_DASHBOARD)
await page.goto(TEAM_ROUTES.dashboard.index())
await page.waitForURL(TEAM_ROUTES.dashboard.index())
await expect(page.locator('label:has-text("Onboarding")')).toBeVisible()

await page.goto(ROUTE_PROFILE)
await page.getByRole('switch', { name: 'Onboarding tips' }).click()

await page.goto(ROUTE_DASHBOARD)
await page.goto(TEAM_ROUTES.dashboard.index())
await expect(page.locator('label:has-text("Onboarding")')).not.toBeVisible()

await page.goto(ROUTE_PROFILE)
await page.getByRole('switch', { name: 'Onboarding tips' }).click()

await page.goto(ROUTE_DASHBOARD)
await page.goto(TEAM_ROUTES.dashboard.index())
await expect(page.locator('label:has-text("Onboarding")')).toBeVisible()
})

test('should close after pressing hide', async ({ page }) => {
await page.goto(ROUTE_DASHBOARD)
await page.goto(TEAM_ROUTES.dashboard.index())

const dashTitle = await page.locator('label:has-text("Onboarding")')
await expect(dashTitle).toBeVisible()
Expand Down
Loading
0