Skip to content

Commit

Permalink
build: e2e fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
m8vago committed Dec 13, 2022
1 parent 508216b commit 572efee
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 171 deletions.
20 changes: 15 additions & 5 deletions web/crux-ui/e2e/deploy-dagent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ test('Deploy to node should be successful', async ({ page }) => {

await page.screenshot({ path: screenshotPath('successful-deployment'), fullPage: true })

await expect(await page.locator('.bg-dyo-green').first()).toContainText('Successful')
const deployStatus = page.getByText('Successful')
await deployStatus.waitFor()

await expect(deployStatus).toHaveCount(1)
})

test('Second successful deployment should make the first deployment obsolete', async ({ page }) => {
Expand All @@ -27,11 +30,13 @@ test('Second successful deployment should make the first deployment obsolete', a

await deployWithDagent(page, prefixTwo, productId, versionId)

await expect(await page.locator('.bg-dyo-green').first()).toContainText('Successful')
const firstDeployStatus = await page.getByText('Successful')
await expect(firstDeployStatus).toHaveCount(1)

await deployWithDagent(page, prefixTwo, productId, versionId)

await expect(await page.locator('.bg-dyo-green').first()).toContainText('Successful')
const secondDeployStatus = await page.getByText('Successful')
await expect(secondDeployStatus).toHaveCount(1)

await page.goto(versionUrl(productId, versionId, { section: 'deployments' }))
await page.screenshot({ path: screenshotPath('deployment-should-be-obsolete'), fullPage: true })
Expand All @@ -40,6 +45,11 @@ test('Second successful deployment should make the first deployment obsolete', a
const deploymentsRows = await deploymentsTableBody.locator('.table-row')

await expect(deploymentsRows).toHaveCount(2)
await expect(await page.locator('.bg-dyo-purple')).toHaveCount(1)
await expect(await page.locator('.bg-dyo-green')).toHaveCount(1)

const successfulDeployment = await deploymentsRows.getByText('Successful', { exact: true })
const obsolateDeployment = await deploymentsRows.getByText('Obsolate', { exact: true })

await page.screenshot({ path: screenshotPath('deployment-should-be-obsolete-2'), fullPage: true })
await expect(successfulDeployment).toHaveCount(1)
await expect(obsolateDeployment).toHaveCount(1)
})
7 changes: 3 additions & 4 deletions web/crux-ui/e2e/deployment-copibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ test.describe('Complex product', () => {
const versionId = await createVersion(page, productId, '0.1.0', 'Incremental')
await createImage(page, productId, versionId, 'nginx')

await deployWithDagent(page, 'pw-complex-copibility', productId, versionId, true)
await deployWithDagent(page, 'pw-complex-copibility-inprogress', productId, versionId, true)

const { deploymentId } = extractDeploymentUrl(page.url())
await page.goto(deploymentUrl(productId, versionId, deploymentId))

await expect(await page.locator('div:has-text("In progress")')).toHaveCount(1)
await expect(await page.getByText('In progress')).toHaveCount(1)
await expect(await page.locator('button:has-text("Copy")')).toHaveCount(0)
})

Expand All @@ -217,8 +217,7 @@ test.describe('Complex product', () => {

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

const copyButton = await page.locator(`[alt="Copy"]:right-of(div:has-text("pw-complex-second"))`).first()

const copyButton = await page.locator(`[alt="Copy"]:right-of(:text("pw-complex-second"))`).first()
await copyButton.click()

await page.waitForNavigation()
Expand Down
2 changes: 1 addition & 1 deletion web/crux-ui/e2e/deployment-deletability.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('Inprogress deployment should be not deletable', async ({ page }) => {
const { deploymentId } = extractDeploymentUrl(page.url())
await page.goto(deploymentUrl(productId, versionId, deploymentId))

await expect(await page.locator('div:has-text("In progress")')).toHaveCount(1)
await expect(await page.getByText('In progress')).toHaveCount(1)
await expect(await page.locator('button:has-text("Delete")')).toHaveCount(0)
})

Expand Down
2 changes: 1 addition & 1 deletion web/crux-ui/e2e/image-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ test.describe('Filters', () => {
})
})

export const configureImagePort = async (page: Page, internal: string, external: string) => {
const configureImagePort = async (page: Page, internal: string, external: string) => {
const addPortsButton = await page.locator(`[src="/plus.svg"]:right-of(label:has-text("Ports"))`).first()

await addPortsButton.click()
Expand Down
9 changes: 5 additions & 4 deletions web/crux-ui/e2e/utils/node-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export const deployWithDagent = async (
versionId?: string,
ignoreResult?: boolean,
) => {
page.on('console', msg => console.log(prefix, msg))

if (versionId) {
await page.goto(versionUrl(productId, versionId))
} else {
Expand All @@ -58,12 +56,15 @@ export const deployWithDagent = async (

await page.waitForNavigation()

await page.locator('button:has-text("Deploy")').click()
const deploy = page.getByText('Deploy', {
exact: true,
})
await deploy.click()

await page.waitForNavigation()

if (!ignoreResult) {
await page.waitForSelector('div:has-text("Successful")')
await page.getByText('Successful').waitFor()
}
}

Expand Down
8 changes: 6 additions & 2 deletions web/crux-ui/e2e/utils/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ export const createVersion = async (page: Page, productId: string, name: string,

export const createImage = async (page: Page, productId: string, versionId: string, image: string) => {
await page.goto(versionUrl(productId, versionId))
await page.waitForSelector('button:has-text("Add image")')

await page.locator('button:has-text("Add image")').click()
const addImage = await page.waitForSelector('button:has-text("Add image")')
await addImage.click()

const registry = await page.waitForSelector(`button:has-text("Docker Hub Library")`)
await registry.click()

await page.locator('input[name=imageName] >> visible=true').type(image)

const imageItem = await page.waitForSelector(`label:has-text("${image}")`)
Expand Down
Loading

0 comments on commit 572efee

Please sign in to comment.