Skip to content

Commit

Permalink
worked on upload test
Browse files Browse the repository at this point in the history
  • Loading branch information
LiveDuo committed Nov 6, 2023
1 parent fe43d0d commit d3395ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions e2e/dev-react/dev.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('should drap and drop a component', async ({ page }) => {
await page.goto('/')

// open category
await page.click('#banner')
await page.click('text=BANNER')

// add component
const imagePath = 'http://localhost:12785/api/builder/handle?type=asset&path=/themes/hyperui/Banner1/preview.png'
Expand All @@ -22,27 +22,28 @@ test('should drap and drop a component', async ({ page }) => {
await page.mouse.move(deleteElement?.x as number, deleteElement?.y as number)
})

test.skip('should add an image to renderer', async ({ page }) => {
test('should add an image to renderer', async ({ page }) => {
await page.goto('/')

// NOTE: skip for now as upload image in not working in react
// react-scripts reloads after uploading in the public folder
return

// open category
await page.click('text=CTA')

// add component with image
await page.click('div.toolbox > div > div:nth-child(1)')
await page.click('div.toolbox > div > div:nth-child(2)')
const imagePath = 'http://localhost:12785/api/builder/handle?type=asset&path=/themes/hyperui/Cta1/preview.png'
await page.dragAndDrop(`img[src='${imagePath}']`, '#editor > div')
await expect(page.locator('#editor > div')).toHaveCount(1)
await page.dragAndDrop(`img[src='${imagePath}']`, '#editor')

// open image dialog
await page.hover('#editor img')
await page.click('div.page-container a:nth-child(3)')
await page.hover('text=Lorem')
const imageElement = await page.getByRole('img', { name: 'Student' }).first()
await imageElement.click()

// click replace image
await page.click('text=Replace')
await page.setInputFiles("input[type='file']", ['e2e/dev-react/pattern.jpg'])
await page.setInputFiles("input[type='file']", ['e2e/dev/pattern.jpg'])
await page.click('text=Upload')
await page.click('text=Save')

Expand All @@ -51,9 +52,10 @@ test.skip('should add an image to renderer', async ({ page }) => {

// remove the component
await page.hover('text=Lorem')
await page.click('div.page-container a:nth-child(4)')
const deleteElement = await page.locator('#delete').boundingBox()
await page.mouse.move(deleteElement?.x as number, deleteElement?.y as number)

// remove the uploaded image
// @ts-ignore
await require('fs/promises').rm('dev/react-project/public/uploaded/pattern.jpg')
await require('fs/promises').rm('dev/nextjs-project/public/uploaded/pattern.jpg')
})
2 changes: 1 addition & 1 deletion e2e/dev/dev.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('should add an image to renderer', async ({ page }) => {
await page.dragAndDrop(`img[src='${imagePath}']`, '#editor')

// open image dialog
await page.hover('text= Lorem')
await page.hover('text=Lorem')
const imageElement = await page.getByRole('img', { name: 'Student' }).first()
await imageElement.click()

Expand Down

0 comments on commit d3395ec

Please sign in to comment.