Skip to content

Commit

Permalink
add new cy-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Napolskyi committed Dec 12, 2023
1 parent 328a1a4 commit 7245ac3
Show file tree
Hide file tree
Showing 7 changed files with 492 additions and 0 deletions.
78 changes: 78 additions & 0 deletions cypress/e2e/assetEmpty/audioEmptyAsset.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/// <reference types="cypress" />

import { ALERT_CREATE, ASSET_TITLE, CY } from '../../utils/common'

describe(`Test audio empty asset, Env: ${CY.cfg}`,
{ tags: ['@assetAudioEmpty', '@assetEmpty'] }, () => {
it('Prepare Test Data', ()=> {
cy.prepareData('audio/sample.mp3', 0)
})
it('Test empty asset', () => {
cy.api_waitPageLoad('main')
cy.get('.mdi-view-grid-plus-outline').click()
cy.get('.v-list').contains('Vytvoriť prázdny asset').click()
cy.getCy('author-type').click()
cy.get('.v-overlay__content > .v-list').contains('Audio').click()
cy.getCy('button-close').should('be.visible')
cy.getCy('button-cancel').should('be.visible')
cy.getCy('button-confirm').should('be.visible').click()
cy.alertMessage(ALERT_CREATE)

cy.urlContains('/asset')
cy.get('.sidebar-info__content > .pa-2 > .v-alert').contains('Neobsahuje žiaden súbor')
cy.getCy('button-download').should('be.visible')
cy.getCy('button-delete').should('be.visible')
cy.get('.dam-image-detail__sidebar [data-cy="custom-field-title"] textarea').eq(0)
.type(`${ASSET_TITLE}`)
cy.getCy('button-save').should('be.visible').click()

cy.getCy('button-distribution').should('be.visible').click()
cy.circleLoad()
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Neobsahuje žiaden súbor')
cy.wrap(sidebarText).should('include', 'Nie je vybraná žiadna distribučná kategória')
cy.wrap(sidebarText).should('include', 'Nie je čo zobraziť')
})

cy.getCy('button-podcast').should('be.visible').click()
cy.circleLoad()
cy.getCy('button-add-new-podcast-episode').should('be.visible')
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Neobsahuje žiaden súbor')
cy.wrap(sidebarText).should('include', 'Nie je čo zobraziť')
})
cy.getCy('button-add-new-podcast-episode').should('be.visible')

cy.getCy('button-slots').should('be.visible').click()
cy.circleLoad()
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Neobsahuje žiaden súbor')
cy.wrap(sidebarText).should('include', 'free')
cy.wrap(sidebarText).should('include', 'bonus')
cy.wrap(sidebarText).should('include', 'premium')
cy.wrap(sidebarText).should('include', 'Žiaden súbor')
})
cy.get('.w-100 > .v-btn').should('be.visible')
cy.get('.sidebar-info__content input[type="file"]', { timeout: 10000 })
.eq(0)
.selectFile(
{ contents: 'cypress/fixtures/audio/sample.mp3' },
{ waitForAnimations: true, force: true, action: 'select' }
)
cy.api_getFileID().then((assetID) => {
cy.circleLoad()

cy.visit(`/asset/${assetID}`)
cy.get('.dam-image-detail__sidebar [data-cy="custom-field-title"] textarea').eq(0)
.invoke('val').then((assetTitle)=>{
cy.wrap(assetTitle).should('include', ASSET_TITLE)
})
cy.urlContains(assetID)
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('not.include', 'Neobsahuje žiaden súbor')
}).then(()=>{
cy.deleteFile([assetID])
})
})
})
})
59 changes: 59 additions & 0 deletions cypress/e2e/assetEmpty/documentAssetEmpty.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/// <reference types="cypress" />

import { ALERT_CREATE, ASSET_TITLE, CY } from '../../utils/common'

describe(`Test document empty asset, Env: ${CY.cfg}`,
{ tags: ['@assetDocumentEmpty', '@assetEmpty'] }, () => {
it('Prepare Test Data', ()=> {
cy.prepareData('document/sample.doc', 0)
})
it('Test empty asset', () => {
cy.api_waitPageLoad('main')
cy.get('.mdi-view-grid-plus-outline').click()
cy.get('.v-list').contains('Vytvoriť prázdny asset').click()
cy.getCy('author-type').click()
cy.get('.v-overlay__content > .v-list').contains('Dokument').click()
cy.getCy('button-close').should('be.visible')
cy.getCy('button-cancel').should('be.visible')
cy.getCy('button-confirm').should('be.visible').click()
cy.alertMessage(ALERT_CREATE)

cy.urlContains('/asset')
cy.get('.sidebar-info__content > .pa-2 > .v-alert').contains('Neobsahuje žiaden súbor')
cy.getCy('button-download').should('be.visible')
cy.getCy('button-delete').should('be.visible')
cy.get('.dam-image-detail__sidebar [data-cy="custom-field-title"] textarea').eq(0)
.type(`${ASSET_TITLE}`)
cy.getCy('button-save').should('be.visible').click()

cy.getCy('button-slots').should('be.visible').click()
cy.circleLoad()
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Neobsahuje žiaden súbor')
cy.wrap(sidebarText).should('include', 'default')
cy.wrap(sidebarText).should('include', 'Žiaden súbor')
})
cy.get('.w-100 > .v-btn').should('be.visible')
cy.get('.sidebar-info__content input[type="file"]', { timeout: 10000 })
.eq(0)
.selectFile(
{ contents: 'cypress/fixtures/document/sample.doc' },
{ waitForAnimations: true, force: true, action: 'select' }
)
cy.api_getFileID().then((assetID) => {
cy.circleLoad()

cy.visit(`/asset/${assetID}`)
cy.get('.dam-image-detail__sidebar [data-cy="custom-field-title"] textarea').eq(0)
.invoke('val').then((assetTitle)=>{
cy.wrap(assetTitle).should('include', ASSET_TITLE)
})
cy.urlContains(assetID)
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('not.include', 'Neobsahuje žiaden súbor')
}).then(()=>{
cy.deleteFile([assetID])
})
})
})
})
67 changes: 67 additions & 0 deletions cypress/e2e/assetEmpty/imageAssetEmpty.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/// <reference types="cypress" />

import { ALERT_CREATE, ASSET_TITLE, CY } from '../../utils/common'

describe(`Test image empty asset, Env: ${CY.cfg}`,
{ tags: ['@assetImageEmpty', '@assetEmpty'] }, () => {
it('Prepare Test Data', ()=> {
cy.prepareData('image/sample.png', 0)
})
it('Test empty asset', () => {
cy.api_waitPageLoad('main')
cy.get('.mdi-view-grid-plus-outline').click()
cy.get('.v-list').contains('Vytvoriť prázdny asset').click()
cy.getCy('author-type').click()
cy.get('.v-overlay__content > .v-list').contains('Obrázok').click()
cy.getCy('button-close').should('be.visible')
cy.getCy('button-cancel').should('be.visible')
cy.getCy('button-confirm').should('be.visible').click()
cy.alertMessage(ALERT_CREATE)

cy.urlContains('/asset')
cy.get('.sidebar-info__content > .pa-2 > .v-alert').contains('Neobsahuje žiaden súbor')
cy.getCy('button-download').should('be.visible')
cy.getCy('button-delete').should('be.visible')
cy.get('.dam-image-detail__sidebar [data-cy="custom-field-title"] textarea').eq(0)
.type(`${ASSET_TITLE}`)
cy.getCy('button-save').should('be.visible').click()

cy.getCy('button-focus').should('be.visible').click()
cy.circleLoad()
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Náhľady')
cy.wrap(sidebarText).should('include', 'Náhľad obrázku na mobile, počítači alebo v aplikácii')
})
cy.get('.w-100 .v-btn').should('be.visible')

cy.getCy('button-slots').should('be.visible').click()
cy.circleLoad()
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Neobsahuje žiaden súbor')
cy.wrap(sidebarText).should('include', 'default')
cy.wrap(sidebarText).should('include', 'Žiaden súbor')
})
cy.get('.w-100 > .v-btn').should('be.visible')
cy.get('.sidebar-info__content input[type="file"]', { timeout: 10000 })
.eq(0)
.selectFile(
{ contents: 'cypress/fixtures/image/sample.png' },
{ waitForAnimations: true, force: true, action: 'select' }
)
cy.api_getFileID().then((assetID) => {
cy.circleLoad()

cy.visit(`/asset/${assetID}`)
cy.get('.dam-image-detail__sidebar [data-cy="custom-field-title"] textarea').eq(0)
.invoke('val').then((assetTitle)=>{
cy.wrap(assetTitle).should('include', ASSET_TITLE)
})
cy.urlContains(assetID)
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('not.include', 'Neobsahuje žiaden súbor')
}).then(()=>{
cy.deleteFile([assetID])
})
})
})
})
75 changes: 75 additions & 0 deletions cypress/e2e/assetEmpty/videoAssetEmpty.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/// <reference types="cypress" />

import { ALERT_CREATE, ASSET_TITLE, CY } from '../../utils/common'

describe(`Test video empty asset, Env: ${CY.cfg}`,
{ tags: ['@assetVideoEmpty', '@assetEmpty'] }, () => {
it('Prepare Test Data', ()=> {
cy.prepareData('video/sample.mp4', 0)
})
it('Test empty asset', () => {
cy.api_waitPageLoad('main')
cy.get('.mdi-view-grid-plus-outline').click()
cy.get('.v-list').contains('Vytvoriť prázdny asset').click()
cy.getCy('author-type').click()
cy.get('.v-overlay__content > .v-list').contains('Video').click()
cy.getCy('button-close').should('be.visible')
cy.getCy('button-cancel').should('be.visible')
cy.getCy('button-confirm').should('be.visible').click()
cy.alertMessage(ALERT_CREATE)

cy.urlContains('/asset')
cy.get('.sidebar-info__content > .pa-2 > .v-alert').contains('Neobsahuje žiaden súbor')
cy.getCy('button-download').should('be.visible')
cy.getCy('button-delete').should('be.visible')
cy.get('.dam-image-detail__sidebar [data-cy="custom-field-title"] textarea').eq(0)
.type(`${ASSET_TITLE}`)
cy.getCy('button-save').should('be.visible').click()

cy.getCy('button-distribution').should('be.visible').click()
cy.circleLoad()
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Neobsahuje žiaden súbor')
cy.wrap(sidebarText).should('include', 'Nie je vybraná žiadna distribučná kategória')
cy.wrap(sidebarText).should('include', 'Nie je čo zobraziť')
})

cy.getCy('button-video-show').should('be.visible').click()
cy.circleLoad()
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Neobsahuje žiaden súbor')
cy.wrap(sidebarText).should('include', 'Nie je čo zobraziť')
})
cy.getCy('button-add-new-vs-episode').should('be.visible')

cy.getCy('button-slots').should('be.visible').click()
cy.circleLoad()
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('include', 'Neobsahuje žiaden súbor')
cy.wrap(sidebarText).should('include', 'default')
cy.wrap(sidebarText).should('include', 'Žiaden súbor')
})
cy.get('.w-100 > .v-btn').should('be.visible')
cy.get('.sidebar-info__content input[type="file"]', { timeout: 10000 })
.eq(0)
.selectFile(
{ contents: 'cypress/fixtures/video/sample.mp4' },
{ waitForAnimations: true, force: true, action: 'select' }
)
cy.api_getFileID().then((assetID) => {
cy.circleLoad()

cy.visit(`/asset/${assetID}`)
cy.get('.dam-image-detail__sidebar [data-cy="custom-field-title"] textarea').eq(0)
.invoke('val').then((assetTitle)=>{
cy.wrap(assetTitle).should('include', ASSET_TITLE)
})
cy.urlContains(assetID)
cy.get('.sidebar-info__content').invoke('text').then((sidebarText) => {
cy.wrap(sidebarText).should('not.include', 'Neobsahuje žiaden súbor')
}).then(()=>{
cy.deleteFile([assetID])
})
})
})
})
45 changes: 45 additions & 0 deletions cypress/e2e/assets/unsplash.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/// <reference types="cypress" />

import { ALERT_UPLOAD, CY } from '../../utils/common'
const ASSET_ID: Array<string> = []

describe(`Test audio slots function, Env: ${CY.cfg}`,
{ tags: ['@unsplash', '@assets'], env: { visitBaseUrl: true } }, () => {
it('test Unsplash Image', ()=>{
cy.api_waitPageLoad('main')
cy.get('.v-toolbar__content > .w-100 > :nth-child(2) > .v-btn').click()
cy.get('.v-list-item').contains('Unsplash').click()
cy.api_waitPageLoad('unsplash')
cy.get('.v-form > .v-input > .v-input__control > .v-field > .v-field__field > .v-field__input')
.type('Forest{ENTER}')
cy.get('.dam-image-grid > :nth-child(1)').click()
cy.get('.pa-2 > .bg-primary').click()
cy.get('.dam-image-grid > :nth-child(2)').click()
cy.get('.pa-2 > .bg-primary').click()
cy.waitForUpload(ALERT_UPLOAD)
cy.duplicateShouldExist(false)
cy.getCy('button-add-description').click()
cy.getCy('table-copy').eq(0).click()
cy.window().then((win) => {
win.navigator.clipboard.readText().then((text) => {
ASSET_ID.push(text)
})
})
cy.getCy('table-copy').eq(1).click()
cy.window().then((win) => {
win.navigator.clipboard.readText().then((text) => {
ASSET_ID.push(text)
})
})
})
it('Visit data', ()=>{
ASSET_ID.forEach((id)=>{
cy.log(id)
cy.visit(`/asset/${id}`)
cy.urlContains(id)
})
})
it('Delete Test data', ()=>{
cy.deleteFile(ASSET_ID)
})
})
Loading

0 comments on commit 7245ac3

Please sign in to comment.