Skip to content

Commit

Permalink
fix: project filter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m8vago committed Sep 26, 2023
1 parent bf55fee commit 507aafd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 33 deletions.
1 change: 0 additions & 1 deletion web/crux-ui/e2e/utils/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const createProject = async (page: Page, name: string, type: ProjectType)
await page.locator('button:has-text("Save")').click()

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

Check failure on line 21 in web/crux-ui/e2e/utils/projects.ts

View workflow job for this annotation

GitHub Actions / e2e

[project] › with-login/project.spec.ts:120:9 › Project › Project versioned filter should work › in list view

1) [project] › with-login/project.spec.ts:120:9 › Project › Project versioned filter should work › in list view TimeoutError: page.waitForURL: Timeout 30000ms exceeded. =========================== logs =========================== waiting for navigation to "/jot/projects/**" until "load" ============================================================ at utils/projects.ts:21 19 | await page.locator('button:has-text("Save")').click() 20 | > 21 | await page.waitForURL(`${TEAM_ROUTES.project.list()}/**`) | ^ 22 | await page.waitForSelector(`h5:text-is("${name}")`) 23 | 24 | if (type === 'versionless') { at createProject (/__w/dyrectorio/dyrectorio/web/crux-ui/e2e/utils/projects.ts:21:14) at /__w/dyrectorio/dyrectorio/web/crux-ui/e2e/with-login/project.spec.ts:100:7
await page.waitForLoadState('networkidle')
await page.waitForSelector(`h5:text-is("${name}")`)

if (type === 'versionless') {
Expand Down
85 changes: 53 additions & 32 deletions web/crux-ui/e2e/with-login/project.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, Page } from '@playwright/test'
import { test } from '../utils/test.fixture'
import { expect } from '@playwright/test'
import { TEAM_ROUTES } from 'e2e/utils/common'
import { createProject, deleteProject } from 'e2e/utils/projects'
import { test } from '../utils/test.fixture'

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

Expand Down Expand Up @@ -89,52 +89,73 @@ test.describe('Project', () => {
await expect(page.getByAltText('Picture of ', { exact: false })).toHaveCount(1)
})

const createEmptyProjects = async (page: Page, prefix: string) => {
await createProject(page, prefix.concat('-vrsd'), 'versioned')
await createProject(page, prefix.concat('-vrsl'), 'versionless')
}
test.describe('Project versioned filter should work', () => {
const FILTER_VERSIONED = 'filter-versioned'
const FILTER_VERSIONLESS = 'filter-versionless'

test.beforeAll(async ({ browser }) => {
const ctx = await browser.newContext()
const page = await ctx.newPage()

const projectFilterType = async (page: Page, projName: string, versioned: boolean, tileView: boolean) => {
await createEmptyProjects(page, projName)
await createProject(page, projName, versioned ? 'versioned' : 'versionless')
await createProject(page, FILTER_VERSIONED, 'versioned')
await createProject(page, FILTER_VERSIONLESS, 'versionless')

await page.goto(TEAM_ROUTES.project.list())
await page.waitForSelector('h2:text-is("Projects")')
await page.close()
await ctx.close()
})

tileView
? await page.locator('img[src="/view_tile.svg"]').click()
: await page.locator('img[src="/view_table.svg"]').click()
test('in tile view', async ({ page }) => {
await page.goto(TEAM_ROUTES.project.list())
await page.waitForSelector('h2:text-is("Projects")')

const projNum: number = tileView
? await page.locator('div.card.w-full').count()
: await page.locator('div.table-row-group div.table-row').count()
versioned
? await page.locator('button:has-text("Versioned")').click()
: await page.locator('button:has-text("Versionless")').click()
await page.locator('img[src="/view_tile.svg"]').click()

expect(
tileView
? await page.locator('div.card.w-full').count()
: await page.locator('div.table-row-group div.table-row').count(),
).toBeLessThan(projNum)
}
const projNum: number = await page.locator('div.card.w-full').count()

test.describe('Project versioned filter should work', () => {
test('in tile view', async ({ page }) => {
await projectFilterType(page, 'filter-by-versioned-tile-project', true, true)
await page.locator('button:has-text("Versioned")').click()

expect(await page.locator('div.card.w-full').count()).toBeLessThan(projNum)
})

test('in list view', async ({ page }) => {
await projectFilterType(page, 'filter-by-versioned-list-project', true, false)
await page.goto(TEAM_ROUTES.project.list())
await page.waitForSelector('h2:text-is("Projects")')

await page.locator('img[src="/view_table.svg"]').click()

const projNum: number = await page.locator('div.table-row-group div.table-row').count()

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

expect(await page.locator('div.table-row-group div.table-row').count()).toBeLessThan(projNum)
})
})

test.describe('Project versionless filter should work', () => {
test('in tile view', async ({ page }) => {
await projectFilterType(page, 'filter-by-versionless-tile-project', false, true)
await page.goto(TEAM_ROUTES.project.list())
await page.waitForSelector('h2:text-is("Projects")')

await page.locator('img[src="/view_tile.svg"]').click()

const projNum: number = await page.locator('div.card.w-full').count()

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

expect(await page.locator('div.card.w-full').count()).toBeLessThan(projNum)
})

test('in list view', async ({ page }) => {
await projectFilterType(page, 'filter-by-versionless-list-project', false, false)
await page.goto(TEAM_ROUTES.project.list())
await page.waitForSelector('h2:text-is("Projects")')

await page.locator('img[src="/view_table.svg"]').click()

const projNum: number = await page.locator('div.table-row-group div.table-row').count()

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

expect(await page.locator('div.table-row-group div.table-row').count()).toBeLessThan(projNum)
})
})
})

0 comments on commit 507aafd

Please sign in to comment.