Skip to content

Commit

Permalink
feat(testcafe): Create empty album scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
CozyKourai committed Feb 25, 2019
1 parent 4ab882d commit bfeffc5
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
1 change: 1 addition & 0 deletions testcafe/runner-photos.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ async function runRunner() {

'testcafe/tests/photos/photos_crud.js',
'testcafe/tests/photos/create_full_album_scenario.js',
'testcafe/tests/photos/create_empty_album_scenario.js',

//Scenario that just delete photos, so we don't need to do it in every test.
'testcafe/tests/photos/photos_end_delete_all_data.js'
Expand Down
4 changes: 3 additions & 1 deletion testcafe/tests/pages/photos-album-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default class Page {
await isExistingAndVisibile(this.allPhotosAddToAlbum, 'Photo item(s)')
const allPhotosCount = await this.allPhotosAddToAlbum.count

console.log(`Number of pictures on page (${when} test): ${allPhotosCount}`)
console.log(
`Number of pictures ready to be added (${when} test): ${allPhotosCount}`
)
return allPhotosCount
}

Expand Down
69 changes: 69 additions & 0 deletions testcafe/tests/photos/create_empty_album_scenario.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { photosUser } from '../helpers/roles'
import { TESTCAFE_PHOTOS_URL } from '../helpers/utils'
import { ALBUM_DATE_TIME } from '../helpers/data'
import PhotoPage from '../pages/photos-model'
import AlbumPage from '../pages/photos-album-model'

const photoPage = new PhotoPage()
const photoAlbumPage = new AlbumPage()

fixture`Create new empty album and add photos`
.page`${TESTCAFE_PHOTOS_URL}/`.beforeEach(async t => {
await t.useRole(photosUser)
await photoPage.initPhotoPage()
})

test('Go into Album view, and check that there is no album', async () => {
await photoPage.goToAlbums()
await photoAlbumPage.checkEmptyAlbum()
})

test('Go into Album view, and create new empty album', async () => {
await photoPage.goToAlbums()
await photoAlbumPage.addNewAlbum(ALBUM_DATE_TIME, 0)
await photoAlbumPage.checkAlbumPage(ALBUM_DATE_TIME, 0)
//we need to check the album page, just after the redirection from album creation, hence this step being in this test
})

test('Go to ALBUM_DATE_TIME, and rename it (exit by pressing "enter")', async t => {
await photoPage.goToAlbums()
await photoAlbumPage.goToAlbum(ALBUM_DATE_TIME)
await photoAlbumPage.checkAlbumPage(ALBUM_DATE_TIME, 0)
await photoAlbumPage.renameAlbum(ALBUM_DATE_TIME, `New_${ALBUM_DATE_TIME}`)
await t.pressKey('enter')
await photoAlbumPage.checkAlbumPage(`New_${ALBUM_DATE_TIME}`, 0)
})

test('Go to New_ALBUM_DATE_TIME, and rename it (exit by clicking away)', async t => {
await photoPage.goToAlbums()
await photoAlbumPage.goToAlbum(`New_${ALBUM_DATE_TIME}`)
await photoAlbumPage.checkAlbumPage(`New_${ALBUM_DATE_TIME}`, 0)
await photoAlbumPage.renameAlbum(
`New_${ALBUM_DATE_TIME}`,
`New2_${ALBUM_DATE_TIME}`
)
await t.click(photoAlbumPage.mainContent)
await photoAlbumPage.checkAlbumPage(`New2_${ALBUM_DATE_TIME}`, 0)
})

test('Go to New2_ALBUM_DATE_TIME, and add 2 more photos', async () => {
await photoPage.goToAlbums()
await photoAlbumPage.goToAlbum(`New2_${ALBUM_DATE_TIME}`)
await photoAlbumPage.addPhotosToAlbum(`New2_${ALBUM_DATE_TIME}`, 0, 2)
await photoAlbumPage.backToAlbumsList()
await photoAlbumPage.isAlbumExistsAndVisible(`New2_${ALBUM_DATE_TIME}`, 2)
})

test('Go to New2_ALBUM_DATE_TIME, and remove the 1st photos', async () => {
await photoPage.goToAlbums()
await photoAlbumPage.goToAlbum(`New2_${ALBUM_DATE_TIME}`)
await photoAlbumPage.removePhoto(1)
})

test('Go to New2_ALBUM_DATE_TIME, and delete it', async () => {
await photoPage.goToAlbums()
await photoAlbumPage.goToAlbum(`New2_${ALBUM_DATE_TIME}`)
await photoAlbumPage.deleteAlbum()
await photoAlbumPage.waitForLoading()
await photoAlbumPage.checkEmptyAlbum() //There is no more album
})

0 comments on commit bfeffc5

Please sign in to comment.