2020-06-01 17:04:47 +02:00
|
|
|
import { Selector } from 'testcafe';
|
|
|
|
import testcafeconfig from './testcafeconfig';
|
|
|
|
import Page from "./page-model";
|
|
|
|
import { RequestLogger } from 'testcafe';
|
|
|
|
|
2020-06-05 18:03:22 +02:00
|
|
|
const logger = RequestLogger( /http:\/\/localhost\/api\/v1\/*/ , {
|
2020-06-01 17:04:47 +02:00
|
|
|
logResponseHeaders: true,
|
|
|
|
logResponseBody: true
|
|
|
|
});
|
|
|
|
|
|
|
|
fixture `Test albums`
|
|
|
|
.page`${testcafeconfig.url}`
|
|
|
|
.requestHooks(logger);
|
|
|
|
|
|
|
|
const page = new Page();
|
|
|
|
|
|
|
|
test('#1 Create/delete album', async t => {
|
|
|
|
logger.clear();
|
2020-07-03 15:39:38 +02:00
|
|
|
await t.click(Selector('.nav-albums'));
|
2020-06-04 18:25:29 +02:00
|
|
|
//TODO fails in container with request but outsides without it
|
2020-06-03 08:42:56 +02:00
|
|
|
//const request = await logger.requests[0].response.body;
|
2020-06-01 17:04:47 +02:00
|
|
|
const countAlbums = await Selector('div.p-album').count;
|
|
|
|
logger.clear();
|
|
|
|
await t
|
|
|
|
.click(Selector('button.action-add'));
|
2020-07-03 15:39:38 +02:00
|
|
|
//const request1 = await logger.requests[0].response.body;
|
2020-06-01 17:04:47 +02:00
|
|
|
const countAlbumsAfterCreate = await Selector('div.p-album').count;
|
|
|
|
const NewAlbum = await Selector('div.p-album').nth(0).getAttribute('data-uid');
|
|
|
|
await t
|
|
|
|
.expect(countAlbumsAfterCreate).eql(countAlbums + 1);
|
|
|
|
await page.selectFromUID(NewAlbum);
|
|
|
|
logger.clear();
|
2020-06-23 13:06:55 +02:00
|
|
|
await page.deleteSelected();
|
2020-07-03 15:39:38 +02:00
|
|
|
//const request2 = await logger.requests[0].response.body;
|
2020-06-01 17:04:47 +02:00
|
|
|
const countAlbumsAfterDelete = await Selector('div.p-album').count;
|
|
|
|
await t
|
|
|
|
.expect(countAlbumsAfterDelete).eql(countAlbumsAfterCreate - 1);
|
|
|
|
});
|
2020-06-01 09:45:24 +02:00
|
|
|
|
2020-06-02 13:07:18 +02:00
|
|
|
test('#2 Update album', async t => {
|
2020-06-01 17:04:47 +02:00
|
|
|
await t
|
2020-07-03 15:39:38 +02:00
|
|
|
.click(Selector('.nav-albums'))
|
2020-06-01 17:04:47 +02:00
|
|
|
.typeText(Selector('.p-albums-search input'), 'Holiday')
|
|
|
|
.pressKey('enter');
|
|
|
|
const AlbumUid = await Selector('div.p-album').nth(0).getAttribute('data-uid');
|
|
|
|
await t
|
|
|
|
.expect(Selector('div.v-card__actions').nth(0).innerText).contains('Holiday')
|
2020-07-03 15:39:38 +02:00
|
|
|
.click(Selector('.action-title-edit').nth(0))
|
|
|
|
.typeText(Selector('.input-title input'), 'Animals', { replace: true })
|
2020-06-01 17:04:47 +02:00
|
|
|
.expect(Selector('.input-description textarea').value).eql('')
|
|
|
|
.expect(Selector('.input-category input').value).eql('')
|
|
|
|
.typeText(Selector('.input-description textarea'), 'All my animals')
|
|
|
|
.typeText(Selector('.input-category input'), 'Pets')
|
2020-07-03 15:39:38 +02:00
|
|
|
.pressKey('enter')
|
|
|
|
.click('.action-confirm')
|
|
|
|
.click(Selector('div.p-album').nth(0));
|
|
|
|
//const request1 = await logger.requests[0].response.body;
|
|
|
|
const PhotoCount = await Selector('div.p-photo').count;
|
2020-06-01 17:04:47 +02:00
|
|
|
await t
|
2020-07-03 15:39:38 +02:00
|
|
|
.expect(Selector('.v-card__text').nth(0).innerText).contains('All my animals')
|
|
|
|
.expect(Selector('.v-toolbar__title').nth(1).innerText).contains('Animals')
|
|
|
|
.click(Selector('.nav-photos'));
|
2020-06-01 17:04:47 +02:00
|
|
|
const FirstPhotoUid = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
|
|
|
|
const SecondPhotoUid = await Selector('div.p-photo').nth(1).getAttribute('data-uid');
|
|
|
|
await page.selectFromUID(FirstPhotoUid);
|
|
|
|
await page.selectFromUID(SecondPhotoUid);
|
|
|
|
await page.addSelectedToAlbum('Animals');
|
|
|
|
await t
|
2020-07-03 15:39:38 +02:00
|
|
|
.click(Selector('.nav-albums'));
|
2020-06-01 17:04:47 +02:00
|
|
|
logger.clear();
|
|
|
|
await t
|
2020-07-03 15:39:38 +02:00
|
|
|
.click(Selector('.input-category i'))
|
2020-06-01 17:04:47 +02:00
|
|
|
.click(Selector('div[role="listitem"]').withText('Family'));
|
2020-07-03 15:39:38 +02:00
|
|
|
//const request3 = await logger.requests[0].response.body;
|
2020-06-01 17:04:47 +02:00
|
|
|
logger.clear();
|
|
|
|
await t
|
|
|
|
.expect(Selector('div.v-card__actions').nth(0).innerText).contains('Christmas')
|
2020-07-03 15:39:38 +02:00
|
|
|
.click(Selector('.nav-albums'))
|
|
|
|
.click('.action-reload')
|
|
|
|
.click(Selector('.input-category i'))
|
2020-06-01 17:04:47 +02:00
|
|
|
.click(Selector('div[role="listitem"]').withText('All Categories'), {timeout: 55000});
|
2020-07-03 15:39:38 +02:00
|
|
|
//const request4 = await logger.requests[0].response.body;
|
2020-06-01 17:04:47 +02:00
|
|
|
await t
|
|
|
|
.click(Selector('div.p-album').withAttribute('data-uid', AlbumUid));
|
2020-07-03 15:39:38 +02:00
|
|
|
//const request5 = await logger.requests[0].response.body;
|
2020-06-01 17:04:47 +02:00
|
|
|
const PhotoCountAfterAdd = await Selector('div.p-photo').count;
|
|
|
|
await t
|
|
|
|
.expect(PhotoCountAfterAdd).eql(PhotoCount + 2);
|
|
|
|
await page.selectFromUID(FirstPhotoUid);
|
|
|
|
await page.selectFromUID(SecondPhotoUid);
|
|
|
|
await page.removeSelected();
|
|
|
|
await t
|
|
|
|
.click('.action-reload');
|
|
|
|
const PhotoCountAfterDelete = await Selector('div.p-photo').count;
|
|
|
|
logger.clear();
|
|
|
|
await t
|
|
|
|
.expect(PhotoCountAfterDelete).eql(PhotoCountAfterAdd - 2)
|
2020-07-03 15:39:38 +02:00
|
|
|
.click(Selector('.action-edit'))
|
|
|
|
.typeText(Selector('.input-title input'), 'Holiday', { replace: true })
|
|
|
|
.expect(Selector('.input-description textarea').value).eql('All my animals')
|
|
|
|
.expect(Selector('.input-category input').value).eql('Pets')
|
2020-06-01 17:04:47 +02:00
|
|
|
.click(Selector('.input-description textarea'))
|
|
|
|
.pressKey('ctrl+a delete')
|
2020-07-03 15:39:38 +02:00
|
|
|
.pressKey('enter')
|
2020-06-01 17:04:47 +02:00
|
|
|
.click(Selector('.input-category input'))
|
|
|
|
.pressKey('ctrl+a delete')
|
|
|
|
.pressKey('enter')
|
2020-07-03 15:39:38 +02:00
|
|
|
.click('.action-confirm')
|
|
|
|
.click('.action-reload')
|
|
|
|
.click(Selector('.nav-albums'))
|
|
|
|
.expect(Selector('div').withText("Holiday").visible).ok()
|
|
|
|
.expect(Selector('div').withText("Animals").exists).notOk();
|
2020-06-01 17:04:47 +02:00
|
|
|
});
|
2020-05-28 10:00:09 +02:00
|
|
|
|
2020-06-01 17:04:47 +02:00
|
|
|
//TODO test download itself + clipboard count after download
|
2020-06-02 13:07:18 +02:00
|
|
|
test('#3 Download album', async t => {
|
2020-07-03 15:39:38 +02:00
|
|
|
await t.click(Selector('.nav-albums'));
|
2020-06-01 17:04:47 +02:00
|
|
|
const FirstAlbum = await Selector('div.p-album').nth(0).getAttribute('data-uid');
|
|
|
|
await page.selectFromUID(FirstAlbum);
|
2020-06-23 13:06:55 +02:00
|
|
|
const clipboardCount = await Selector('span.count-clipboard');
|
2020-06-01 17:04:47 +02:00
|
|
|
await t
|
|
|
|
.expect(clipboardCount.textContent).eql("1")
|
2020-06-23 13:06:55 +02:00
|
|
|
.click(Selector('button.action-menu'))
|
|
|
|
.expect(Selector('button.action-download').visible).ok();
|
2020-06-04 15:38:46 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
test('#4 View folders', async t => {
|
|
|
|
await page.openNav();
|
|
|
|
await t
|
2020-07-03 15:39:38 +02:00
|
|
|
.click(Selector('.nav-albums + div'))
|
|
|
|
.click(Selector('.nav-folders'))
|
2020-06-04 15:38:46 +02:00
|
|
|
.expect(Selector('a').withText('BotanicalGarden').visible).ok()
|
|
|
|
.expect(Selector('a').withText('Kanada').visible).ok()
|
|
|
|
.expect(Selector('a').withText('KorsikaAdventure').visible).ok();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('#5 View calendar', async t => {
|
|
|
|
logger.clear();
|
|
|
|
await t
|
2020-07-03 15:39:38 +02:00
|
|
|
.click(Selector('.nav-calendar'))
|
2020-06-04 18:25:29 +02:00
|
|
|
.expect(Selector('a').withText('May 2019').visible).ok()
|
2020-06-04 15:38:46 +02:00
|
|
|
.expect(Selector('a').withText('October 2019').visible).ok();
|
2020-06-26 16:35:21 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
//TODO test that sharing link works as expected
|
|
|
|
test('#6 Create sharing link', async t => {
|
2020-07-03 15:39:38 +02:00
|
|
|
await t.click(Selector('.nav-albums'));
|
2020-06-26 16:35:21 +02:00
|
|
|
const FirstAlbum = await Selector('div.p-album').nth(0).getAttribute('data-uid');
|
|
|
|
await page.selectFromUID(FirstAlbum);
|
|
|
|
const clipboardCount = await Selector('span.count-clipboard');
|
|
|
|
await t
|
|
|
|
.expect(clipboardCount.textContent).eql("1")
|
|
|
|
.click(Selector('button.action-menu'))
|
|
|
|
.click(Selector('button.action-share'))
|
|
|
|
.click(Selector('div.v-expansion-panel__header__icon').nth(0));
|
|
|
|
const InitialUrl = await (Selector('.action-url').innerText);
|
|
|
|
const InitialSecret = await (Selector('.input-secret input').value)
|
|
|
|
const InitialExpire = await (Selector('div.v-select__selections').innerText);
|
|
|
|
await t
|
|
|
|
.expect(InitialUrl).notContains('secretfortesting')
|
|
|
|
.expect(InitialExpire).eql('Never')
|
|
|
|
.typeText(Selector('.input-secret input'), 'secretForTesting', { replace: true })
|
|
|
|
.click(Selector('.input-expires input'))
|
|
|
|
.click(Selector('div').withText('After 1 day').parent('div[role="listitem"]'))
|
|
|
|
.click(Selector('button.action-save'))
|
|
|
|
.click(Selector('button.action-close'))
|
|
|
|
.click(Selector('button.action-share'))
|
|
|
|
.click(Selector('div.v-expansion-panel__header__icon').nth(0));
|
|
|
|
const UrlAfterChange = await (Selector('.action-url').innerText);
|
|
|
|
const ExpireAfterChange = await (Selector('div.v-select__selections').innerText);
|
|
|
|
await t
|
|
|
|
.expect(UrlAfterChange).contains('secretfortesting')
|
|
|
|
.expect(ExpireAfterChange).eql('After 1 day')
|
|
|
|
.typeText(Selector('.input-secret input'), InitialSecret, { replace: true })
|
|
|
|
.click(Selector('.input-expires input'))
|
|
|
|
.click(Selector('div').withText('Never').parent('div[role="listitem"]'))
|
|
|
|
.click(Selector('button.action-save'))
|
|
|
|
.click(Selector('div.v-expansion-panel__header__icon'));
|
|
|
|
const LinkCount = await (Selector('.action-url').count);
|
|
|
|
await t
|
|
|
|
.click('.action-add-link');
|
|
|
|
const LinkCountAfterAdd = await (Selector('.action-url').count);
|
|
|
|
await t
|
|
|
|
.expect(LinkCountAfterAdd).eql(LinkCount + 1)
|
|
|
|
.click(Selector('div.v-expansion-panel__header__icon'))
|
|
|
|
.click(Selector('.action-delete'));
|
|
|
|
const LinkCountAfterDelete = await (Selector('.action-url').count);
|
|
|
|
await t
|
|
|
|
.expect(LinkCountAfterDelete).eql(LinkCountAfterAdd - 1)
|
2020-06-01 17:04:47 +02:00
|
|
|
});
|