Skip to content

Commit

Permalink
fix: storage saving
Browse files Browse the repository at this point in the history
  • Loading branch information
m8vago committed Dec 4, 2024
1 parent 038495d commit 8b21704
Show file tree
Hide file tree
Showing 14 changed files with 311 additions and 306 deletions.
106 changes: 53 additions & 53 deletions web/crux-ui/e2e/with-login/container-config/common-editor.spec.ts

Large diffs are not rendered by default.

177 changes: 86 additions & 91 deletions web/crux-ui/e2e/with-login/container-config/common-json.spec.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ const setup = async (
): Promise<{ projectId: string; versionId: string; imageId: string }> => {
const projectId = await createProject(page, projectName, 'versioned')
const versionId = await createVersion(page, projectId, versionName, 'Incremental')
const imageId = await createImage(page, projectId, versionId, imageName)
const imageConfigId = await createImage(page, projectId, versionId, imageName)

return {
projectId,
versionId,
imageId,
imageConfigId,
}
}

test.describe('Filters', () => {
test('None should be selected by default', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'filter-all', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'filter-all', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)

await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')

const allButton = await page.locator('button:has-text("All")')
Expand All @@ -34,9 +34,9 @@ test.describe('Filters', () => {
})

test('All should not be selected if one of the main filters are not selected', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'filter-select', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'filter-select', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)

await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')

await page.locator(`button:has-text("Common")`).first().click()
Expand All @@ -47,9 +47,9 @@ test.describe('Filters', () => {
})

test('Main filter should not be selected if one of its sub filters are not selected', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'sub-filter', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'sub-filter', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)

await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')

const subFilter = await page.locator(`button:has-text("Network mode")`)
Expand All @@ -62,9 +62,9 @@ test.describe('Filters', () => {
})

test('Config field should be invisible if its sub filter is not selected', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'sub-deselect', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'sub-deselect', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)

await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')

const subFilter = await page.locator(`button:has-text("Deployment strategy")`)
Expand Down
36 changes: 18 additions & 18 deletions web/crux-ui/e2e/with-login/container-config/docker-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
wsPatchMatchRestartPolicy,
} from 'e2e/utils/websocket-match'
import { createImage, createProject, createVersion } from '../../utils/projects'
import { WS_TYPE_PATCH_IMAGE } from '@app/models'
import { WS_TYPE_PATCH_CONFIG } from '@app/models'

const setup = async (
page: Page,
Expand All @@ -20,28 +20,28 @@ const setup = async (
): Promise<{ projectId: string; versionId: string; imageId: string }> => {
const projectId = await createProject(page, projectName, 'versioned')
const versionId = await createVersion(page, projectId, versionName, 'Incremental')
const imageId = await createImage(page, projectId, versionId, imageName)
const imageConfigId = await createImage(page, projectId, versionId, imageName)

return { projectId, versionId, imageId }
return { projectId, versionId, imageConfigId: imageConfigId }
}

test.describe('Image docker config from editor', () => {
test('Network mode should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(
const { projectId, versionId, imageConfigId } = await setup(
page,
'networkmode-editor',
'1.0.0',
NGINX_TEST_IMAGE_WITH_TAG,
)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)

const mode = 'host'

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchNetworkMode(mode))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchNetworkMode(mode))
await page.locator(`div.grid:has(label:has-text("NETWORK MODE")) button:has-text("${mode}")`).click()
await wsSent

Expand All @@ -53,14 +53,14 @@ test.describe('Image docker config from editor', () => {
})

test('Docker labels should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(
const { projectId, versionId, imageConfigId } = await setup(
page,
'dockerlabel-editor',
'1.0.0',
NGINX_TEST_IMAGE_WITH_TAG,
)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)
Expand All @@ -72,7 +72,7 @@ test.describe('Image docker config from editor', () => {

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

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchDockerLabel(key, value))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchDockerLabel(key, value))
await keyInput.fill(key)
await valueInput.fill(value)
await wsSent
Expand All @@ -84,19 +84,19 @@ test.describe('Image docker config from editor', () => {
})

test('Restart policy should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(
const { projectId, versionId, imageConfigId } = await setup(
page,
'restartpolicy-editor',
'1.0.0',
NGINX_TEST_IMAGE_WITH_TAG,
)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchRestartPolicy('always'))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchRestartPolicy('always'))
await page.locator('div.grid:has(label:has-text("RESTART POLICY")) button:has-text("Always")').click()
await wsSent

Expand All @@ -108,9 +108,9 @@ test.describe('Image docker config from editor', () => {
})

test('Log config should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'logconfig-editor', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'logconfig-editor', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)
Expand All @@ -123,7 +123,7 @@ test.describe('Image docker config from editor', () => {

const loggerConf = page.locator('div.grid:has(label:has-text("LOG CONFIG"))')

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchLogConfig(type, key, value))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchLogConfig(type, key, value))
await loggerConf.locator('input[placeholder="Key"]').first().fill(key)
await loggerConf.locator('input[placeholder="Value"]').first().fill(value)
await loggerConf.locator(`button:has-text("${type}")`).click()
Expand All @@ -137,9 +137,9 @@ test.describe('Image docker config from editor', () => {
})

test('Networks should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'networks-editor', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'networks-editor', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)
Expand All @@ -148,7 +148,7 @@ test.describe('Image docker config from editor', () => {

const network = '10.16.128.196'

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchNetwork(network))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchNetwork(network))
await page.locator('div.grid:has(label:has-text("NETWORKS")) input[placeholder="Network"]').first().fill(network)
await wsSent

Expand Down
36 changes: 18 additions & 18 deletions web/crux-ui/e2e/with-login/container-config/docker-json.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
wsPatchMatchRestartPolicy,
} from 'e2e/utils/websocket-match'
import { createImage, createProject, createVersion } from '../../utils/projects'
import { WS_TYPE_PATCH_IMAGE } from '@app/models'
import { WS_TYPE_PATCH_CONFIG } from '@app/models'

const setup = async (
page: Page,
Expand All @@ -20,18 +20,18 @@ const setup = async (
): Promise<{ projectId: string; versionId: string; imageId: string }> => {
const projectId = await createProject(page, projectName, 'versioned')
const versionId = await createVersion(page, projectId, versionName, 'Incremental')
const imageId = await createImage(page, projectId, versionId, imageName)
const imageConfigId = await createImage(page, projectId, versionId, imageName)

return { projectId, versionId, imageId }
return { projectId, versionId, imageConfigId: imageConfigId }
}

test.describe.configure({ mode: 'parallel' })

test.describe('Image docker config from JSON', () => {
test('Network mode should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'networkmode-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'networkmode-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)
Expand All @@ -45,7 +45,7 @@ test.describe('Image docker config from JSON', () => {
const json = JSON.parse(await jsonEditor.inputValue())
json.networkMode = mode

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchNetworkMode(mode))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchNetworkMode(mode))
await jsonEditor.fill(JSON.stringify(json))
await wsSent

Expand All @@ -57,9 +57,9 @@ test.describe('Image docker config from JSON', () => {
})

test('Docker labels should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'dockerlabel-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'dockerlabel-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)
Expand All @@ -74,7 +74,7 @@ test.describe('Image docker config from JSON', () => {
const json = JSON.parse(await jsonEditor.inputValue())
json.dockerLabels = { [key]: value }

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchDockerLabel(key, value))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchDockerLabel(key, value))
await jsonEditor.fill(JSON.stringify(json))
await wsSent

Expand All @@ -89,14 +89,14 @@ test.describe('Image docker config from JSON', () => {
})

test('Restart policy should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(
const { projectId, versionId, imageConfigId } = await setup(
page,
'restartpolicy-json',
'1.0.0',
NGINX_TEST_IMAGE_WITH_TAG,
)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)
Expand All @@ -108,7 +108,7 @@ test.describe('Image docker config from JSON', () => {
const json = JSON.parse(await jsonEditor.inputValue())
json.restartPolicy = 'always'

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchRestartPolicy('always'))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchRestartPolicy('always'))
await jsonEditor.fill(JSON.stringify(json))
await wsSent

Expand All @@ -120,9 +120,9 @@ test.describe('Image docker config from JSON', () => {
})

test('Log config should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'logconfig-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'logconfig-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)
Expand All @@ -138,7 +138,7 @@ test.describe('Image docker config from JSON', () => {
const json = JSON.parse(await jsonEditor.inputValue())
json.logConfig = { driver: type, options: { [key]: value } }

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchLogConfig(type, key, value))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchLogConfig(type, key, value))
await jsonEditor.fill(JSON.stringify(json))
await wsSent

Expand All @@ -151,9 +151,9 @@ test.describe('Image docker config from JSON', () => {
})

test('Networks should be saved', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'networks-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'networks-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const sock = waitSocketRef(page)
await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')
const ws = await sock
const wsRoute = TEAM_ROUTES.project.versions(projectId).detailsSocket(versionId)
Expand All @@ -169,7 +169,7 @@ test.describe('Image docker config from JSON', () => {
const json = JSON.parse(await jsonEditor.inputValue())
json.networks = [network]

const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_IMAGE, wsPatchMatchNetwork(network))
const wsSent = wsPatchSent(ws, wsRoute, WS_TYPE_PATCH_CONFIG, wsPatchMatchNetwork(network))
await jsonEditor.fill(JSON.stringify(json))
await wsSent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ const setup = async (
): Promise<{ projectId: string; versionId: string; imageId: string }> => {
const projectId = await createProject(page, projectName, 'versioned')
const versionId = await createVersion(page, projectId, versionName, 'Incremental')
const imageId = await createImage(page, projectId, versionId, imageName)
const imageConfigId = await createImage(page, projectId, versionId, imageName)

return {
projectId,
versionId,
imageId,
imageId: imageConfigId,
}
}

test.describe('View state', () => {
test('Editor state should show the configuration fields', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'editor-state-conf', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'editor-state-conf', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)

await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')

const editorButton = await page.waitForSelector('button:has-text("Editor")')
Expand All @@ -39,9 +39,9 @@ test.describe('View state', () => {
})

test('JSON state should show the json editor', async ({ page }) => {
const { projectId, versionId, imageId } = await setup(page, 'editor-state-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)
const { projectId, versionId, imageConfigId } = await setup(page, 'editor-state-json', '1.0.0', NGINX_TEST_IMAGE_WITH_TAG)

await page.goto(TEAM_ROUTES.project.versions(projectId).imageDetails(versionId, imageId))
await page.goto(TEAM_ROUTES.containerConfig.details(imageConfigId))
await page.waitForSelector('h2:text-is("Image")')

const jsonEditorButton = await page.waitForSelector('button:has-text("JSON")')
Expand Down
Loading

0 comments on commit 8b21704

Please sign in to comment.