Skip to content

Commit

Permalink
wip: try tests again -d
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Oct 24, 2024
1 parent 19f6d4a commit 1c6c0b7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion @fiction/core/plugin-db/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function dbPrep<T>(args: {
)

let isValid = !sch || value === null
if (sch && value !== null) {
if (sch && value !== null && value) {
const schema = sch({ z })
value = removeUndefined(value, { removeNull: true })
const parsed = schema.safeParse(value)
Expand Down
27 changes: 17 additions & 10 deletions @fiction/core/test-utils/buildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export async function performActions(args: {
break
}
case 'hasValue': {
await element.first().waitFor({ state: 'visible', timeout: 20000 })
await element.first().waitFor({ state: 'visible', timeout: 30000 })
logger.info('HAS_VALUE', { data: { selector: action.selector, text: action.text } })
await playwrightTest.expect(element).toHaveValue(action.text || '')
break
Expand All @@ -354,7 +354,7 @@ export async function performActions(args: {
break
}
case 'click': {
await element.first().waitFor({ state: 'visible', timeout: 10000 })
await element.first().waitFor({ state: 'visible', timeout: 30000 })
logger.info('CLICK_ELEMENT', { data: { selector: action.selector } })
await element.click()
break
Expand All @@ -371,21 +371,21 @@ export async function performActions(args: {
break
}
case 'visible': {
await element.first().waitFor({ state: 'visible', timeout: 20000 })
await element.first().waitFor({ state: 'visible', timeout: 30000 })
const isVisible = await element.isVisible()
logger.info('IS_VISIBLE', { data: { result: isVisible, selector: action.selector } })
expect(isVisible, `${action.selector} is visible`).toBe(true)
break
}
case 'exists': {
await element.first().waitFor({ state: 'attached', timeout: 10000 })
await element.first().waitFor({ state: 'attached', timeout: 30000 })
const exists = await element.count()
logger.info('EXISTS', { data: { result: exists, selector: action.selector } })
expect(exists, `${action.selector} exists`).toBeGreaterThan(0)
break
}
case 'count': {
await element.first().waitFor({ state: 'attached', timeout: 10000 })
await element.first().waitFor({ state: 'attached', timeout: 30000 })
const cnt = await element.count()
logger.info('CNT', { data: { result: cnt, selector: action.selector } })
expect(cnt, `${action.selector} count ${cnt}`).toBe(cnt)
Expand Down Expand Up @@ -416,26 +416,33 @@ export async function performActions(args: {
lastSelector = frameAction.selector || ''
lastAction = frameAction.type

if (frameAction.wait) {
logger.info('FRAME_WAIT_FOR', { data: { wait: `${frameAction.wait}ms` } })
await waitFor(frameAction.wait)
}

const frameElement = frame.locator(frameAction.selector || 'body')
// Handle frame actions similarly to main actions
switch (frameAction.type) {
case 'click':
await frameElement.first().waitFor({ state: 'visible', timeout: 30000 })
await frameElement.click()
break
case 'fill':
await frameElement.first().waitFor({ state: 'visible', timeout: 30000 })
await frameElement.fill(frameAction.text || '')
break
case 'visible':
await frameElement.waitFor({ state: 'visible', timeout: 20000 })
await frameElement.first().waitFor({ state: 'visible', timeout: 30000 })
expect(await frameElement.isVisible(), `${frameAction.selector} is visible in frame`).toBe(true)
break
case 'hasValue':
await frameElement.waitFor({ state: 'visible', timeout: 20000 })
await frameElement.first().waitFor({ state: 'visible', timeout: 30000 })
logger.info('HAS_VALUE', { data: { selector: frameAction.selector, text: frameAction.text } })
await playwrightTest.expect(frameElement).toHaveValue(frameAction.text || '')
break
case 'hasText': {
await frameElement.waitFor({ state: 'visible', timeout: 20000 })
await frameElement.first().waitFor({ state: 'visible', timeout: 30000 })
logger.info('HAS_TEXT', { data: { selector: frameAction.selector, text: frameAction.text } })
await playwrightTest.expect(frameElement).toContainText(frameAction.text || '')
break
Expand All @@ -444,11 +451,11 @@ export async function performActions(args: {
await frameElement.scrollIntoViewIfNeeded()
break
case 'exists':
await frameElement.waitFor({ state: 'attached', timeout: 10000 })
await frameElement.waitFor({ state: 'attached', timeout: 30000 })
expect(await frameElement.count(), `${frameAction.selector} exists in frame`).toBeGreaterThan(0)
break
case 'count':
await frameElement.waitFor({ state: 'attached', timeout: 10000 })
await frameElement.waitFor({ state: 'attached', timeout: 30000 })
expect(await frameElement.count(), `${frameAction.selector} count in frame`).toBeGreaterThan(0)
break
case 'hasAttribute': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { afterAll, describe, expect, it } from 'vitest'
import { setup } from './kit.main.js'

describe('admin:newsletter', async () => {
const kit = await createUiTestingKit({ headless: false, setup, slowMo: 500, initUser: true })
const kit = await createUiTestingKit({ headless: false, setup, slowMo: 0, initUser: true })
const testUtils = kit.testUtils

if (!testUtils)
throw new Error('missing test utils')

afterAll(async () => kit.close())

it('newsletter workflow', { timeout: 80000, retry: isCi() ? 3 : 0 }, async () => {
it('newsletter workflow', { timeout: 100000, retry: isCi() ? 3 : 0 }, async () => {
await kit.performActions({
caller: 'kitNewsletter',
path: '/app',
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('admin:newsletter', async () => {
{ type: 'hasText', selector: '[data-test-id="email-preview-text-display-value"]', text: 'Test Preview Text' },
{ type: 'click', selector: '[data-test-id="view-preview-button"]' },
{ type: 'frameInteraction', frameSelector: `#email-preview-frame`, frameActions: [
{ type: 'hasText', selector: `[data-test-id="email-title"]`, text: 'Test Content Title' },
{ type: 'hasText', selector: `[data-test-id="email-title"]`, text: 'Test Content Title', wait: 10000 },
{ type: 'hasText', selector: `[data-test-id="email-sub-title"]`, text: 'Test Content Subtitle' },
{ type: 'hasText', selector: `[data-test-id="email-content"]`, text: 'welcome to the jungle' },
] },
Expand Down
2 changes: 0 additions & 2 deletions @fiction/posts/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,6 @@ export class QueryManagePost extends PostsQuery {

const final = await this.getPost({ ...params, where: { orgId, ...where }, _action: 'get' }, { ...meta, caller: 'updatePostEnd' })

this.log.info('prepped', { data: { prepped, final } })

return { status: 'success', data: final.data, message: 'Post updated' }
}

Expand Down
4 changes: 0 additions & 4 deletions @fiction/www/.fiction/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@
"key": "ManagePost",
"path": "/api/fiction-posts/ManagePost"
},
{
"key": "ManagePostIndex",
"path": "/api/fiction-posts/ManagePostIndex"
},
{
"key": "ManageCampaign",
"path": "/api/send/ManageCampaign"
Expand Down
1 change: 0 additions & 1 deletion @fiction/www/.fiction/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export interface CompiledServiceConfig {
| 'ManageOrganization'
| 'ManagePage'
| 'ManagePost'
| 'ManagePostIndex'
| 'ManageSend'
| 'ManageSite'
| 'ManageSites'
Expand Down

0 comments on commit 1c6c0b7

Please sign in to comment.