Tests: Adapt acceptance tests to css changes

This commit is contained in:
theresa 2021-01-13 11:05:11 +01:00
parent e48bb48eaa
commit f35fe19519
3 changed files with 217 additions and 184 deletions

View file

@ -1,190 +1,182 @@
import { Selector } from 'testcafe'; import { Selector } from "testcafe";
import testcafeconfig from './testcafeconfig'; import testcafeconfig from "./testcafeconfig";
import Page from "./page-model"; import Page from "./page-model";
import { RequestLogger } from 'testcafe';
const logger = RequestLogger( /http:\/\/localhost\/api\/v1\/*/ , { fixture`Test albums`.page`${testcafeconfig.url}`;
logResponseHeaders: true,
logResponseBody: true
});
fixture `Test albums`
.page`${testcafeconfig.url}`
.requestHooks(logger);
const page = new Page(); const page = new Page();
test('#1 Create/delete album', async t => { test("#1 Create/delete album", async (t) => {
logger.clear(); await t.click(Selector(".nav-albums"));
await t.click(Selector('.nav-albums')); const countAlbums = await Selector("a.is-album").count;
//TODO fails in container with request but outsides without it await t.click(Selector("button.action-add"));
//const request = await logger.requests[0].response.body; const countAlbumsAfterCreate = await Selector("a.is-album").count;
const countAlbums = await Selector('div.p-album').count; const NewAlbum = await Selector("a.is-album").nth(0).getAttribute("data-uid");
logger.clear(); await t.expect(countAlbumsAfterCreate).eql(countAlbums + 1);
await t
.click(Selector('button.action-add'));
//const request1 = await logger.requests[0].response.body;
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); await page.selectFromUID(NewAlbum);
logger.clear();
await page.deleteSelected(); await page.deleteSelected();
//const request2 = await logger.requests[0].response.body; const countAlbumsAfterDelete = await Selector("a.is-album").count;
const countAlbumsAfterDelete = await Selector('div.p-album').count; await t.expect(countAlbumsAfterDelete).eql(countAlbumsAfterCreate - 1);
await t
.expect(countAlbumsAfterDelete).eql(countAlbumsAfterCreate - 1);
}); });
test('#2 Update album', async t => { test("#2 Update album", async (t) => {
await t await t
.click(Selector('.nav-albums')) .click(Selector(".nav-albums"))
.typeText(Selector('.p-albums-search input'), 'Holiday') .typeText(Selector(".p-albums-search input"), "Holiday")
.pressKey('enter'); .pressKey("enter");
const AlbumUid = await Selector('div.p-album').nth(0).getAttribute('data-uid'); const AlbumUid = await Selector("a.is-album").nth(0).getAttribute("data-uid");
await t await t
.expect(Selector('h3.action-title-edit').nth(0).innerText).contains('Holiday') .expect(Selector("button.action-title-edit").nth(0).innerText)
.click(Selector('.action-title-edit').nth(0)) .contains("Holiday")
.typeText(Selector('.input-title input'), 'Animals', { replace: true }) .click(Selector(".action-title-edit").nth(0))
.expect(Selector('.input-description textarea').value).eql('') .typeText(Selector(".input-title input"), "Animals", { replace: true })
.expect(Selector('.input-category input').value).eql('') .expect(Selector(".input-description textarea").value)
.typeText(Selector('.input-description textarea'), 'All my animals') .eql("")
.typeText(Selector('.input-category input'), 'Pets') .expect(Selector(".input-category input").value)
.pressKey('enter') .eql("")
.click('.action-confirm') .typeText(Selector(".input-description textarea"), "All my animals")
.click(Selector('div.p-album').nth(0)); .typeText(Selector(".input-category input"), "Pets")
//const request1 = await logger.requests[0].response.body; .pressKey("enter")
const PhotoCount = await Selector('div.p-photo').count; .click(".action-confirm")
.click(Selector("a.is-album").nth(0));
const PhotoCount = await Selector("div.is-photo").count;
await t await t
.expect(Selector('.v-card__text').nth(0).innerText).contains('All my animals') .expect(Selector(".v-card__text").nth(0).innerText)
.expect(Selector('div').withText("Animals").exists).ok() .contains("All my animals")
.click(Selector('.nav-photos')); .expect(Selector("div").withText("Animals").exists)
const FirstPhotoUid = await Selector('div.p-photo').nth(0).getAttribute('data-uid'); .ok()
const SecondPhotoUid = await Selector('div.p-photo').nth(1).getAttribute('data-uid'); .click(Selector(".nav-browse"));
await page.selectFromUID(FirstPhotoUid); await page.search("photo:true");
await page.selectFromUID(SecondPhotoUid); const FirstPhotoUid = await Selector("div.is-photo.type-image").nth(0).getAttribute("data-uid");
await page.addSelectedToAlbum('Animals'); const SecondPhotoUid = await Selector("div.is-photo.type-image").nth(1).getAttribute("data-uid");
await page.selectFromUIDInFullscreen(FirstPhotoUid);
await page.selectPhotoFromUID(SecondPhotoUid);
await page.addSelectedToAlbum("Animals");
await t.click(Selector(".nav-albums"));
await t await t
.click(Selector('.nav-albums')); .click(Selector(".input-category i"))
logger.clear(); .click(Selector('div[role="listitem"]').withText("Family"));
await t await t
.click(Selector('.input-category i')) .expect(Selector("button.action-title-edit").nth(0).innerText)
.click(Selector('div[role="listitem"]').withText('Family')); .contains("Christmas")
//const request3 = await logger.requests[0].response.body; .click(Selector(".nav-albums"))
logger.clear(); .click(".action-reload")
await t .click(Selector(".input-category i"))
.expect(Selector('h3.action-title-edit').nth(0).innerText).contains('Christmas') .click(Selector('div[role="listitem"]').withText("All Categories"), { timeout: 55000 });
.click(Selector('.nav-albums')) await t.click(Selector("a.is-album").withAttribute("data-uid", AlbumUid));
.click('.action-reload') const PhotoCountAfterAdd = await Selector("div.is-photo").count;
.click(Selector('.input-category i')) await t.expect(PhotoCountAfterAdd).eql(PhotoCount + 2);
.click(Selector('div[role="listitem"]').withText('All Categories'), {timeout: 55000}); await page.selectPhotoFromUID(FirstPhotoUid);
//const request4 = await logger.requests[0].response.body; await page.selectPhotoFromUID(SecondPhotoUid);
await t
.click(Selector('div.p-album').withAttribute('data-uid', AlbumUid));
//const request5 = await logger.requests[0].response.body;
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 page.removeSelected();
await t.click(".action-reload");
const PhotoCountAfterDelete = await Selector("div.is-photo").count;
await t await t
.click('.action-reload'); .expect(PhotoCountAfterDelete)
const PhotoCountAfterDelete = await Selector('div.p-photo').count; .eql(PhotoCountAfterAdd - 2)
logger.clear(); .click(Selector(".action-edit"))
await t .typeText(Selector(".input-title input"), "Holiday", { replace: true })
.expect(PhotoCountAfterDelete).eql(PhotoCountAfterAdd - 2) .expect(Selector(".input-description textarea").value)
.click(Selector('.action-edit')) .eql("All my animals")
.typeText(Selector('.input-title input'), 'Holiday', { replace: true }) .expect(Selector(".input-category input").value)
.expect(Selector('.input-description textarea').value).eql('All my animals') .eql("Pets")
.expect(Selector('.input-category input').value).eql('Pets') .click(Selector(".input-description textarea"))
.click(Selector('.input-description textarea')) .pressKey("ctrl+a delete")
.pressKey('ctrl+a delete') .pressKey("enter")
.pressKey('enter') .click(Selector(".input-category input"))
.click(Selector('.input-category input')) .pressKey("ctrl+a delete")
.pressKey('ctrl+a delete') .pressKey("enter")
.pressKey('enter') .click(".action-confirm")
.click('.action-confirm') .click(".action-reload")
.click('.action-reload') .click(Selector(".nav-albums"))
.click(Selector('.nav-albums')) .expect(Selector("div").withText("Holiday").visible)
.expect(Selector('div').withText("Holiday").visible).ok() .ok()
.expect(Selector('div').withText("Animals").exists).notOk(); .expect(Selector("div").withText("Animals").exists)
.notOk();
}); });
//TODO test download itself + clipboard count after download //TODO test download itself + clipboard count after download
test('#3 Download album', async t => { test("#3 Download album", async (t) => {
await t.click(Selector('.nav-albums')); await t.click(Selector(".nav-albums"));
const FirstAlbum = await Selector('div.p-album').nth(0).getAttribute('data-uid'); const FirstAlbum = await Selector("a.is-album").nth(0).getAttribute("data-uid");
await page.selectFromUID(FirstAlbum); await page.selectFromUID(FirstAlbum);
const clipboardCount = await Selector('span.count-clipboard'); const clipboardCount = await Selector("span.count-clipboard");
await t await t
.expect(clipboardCount.textContent).eql("1") .expect(clipboardCount.textContent)
.click(Selector('button.action-menu')) .eql("1")
.expect(Selector('button.action-download').visible).ok(); .click(Selector("button.action-menu"))
.expect(Selector("button.action-download").visible)
.ok();
}); });
test('#4 View folders', async t => { test("#4 View folders", async (t) => {
await page.openNav(); await page.openNav();
await t await t
.click(Selector('.nav-albums + div')) .click(Selector(".nav-folders"))
.click(Selector('.nav-folders')) .expect(Selector("a").withText("BotanicalGarden").visible)
.expect(Selector('a').withText('BotanicalGarden').visible).ok() .ok()
.expect(Selector('a').withText('Kanada').visible).ok() .expect(Selector("a").withText("Kanada").visible)
.expect(Selector('a').withText('KorsikaAdventure').visible).ok(); .ok()
.expect(Selector("a").withText("KorsikaAdventure").visible)
.ok();
}); });
test('#5 View calendar', async t => { test("#5 View calendar", async (t) => {
logger.clear();
await t await t
.click(Selector('.nav-calendar')) .click(Selector(".nav-calendar"))
.expect(Selector('a').withText('May 2019').visible).ok() .expect(Selector("a").withText("May 2019").visible)
.expect(Selector('a').withText('October 2019').visible).ok(); .ok()
.expect(Selector("a").withText("October 2019").visible)
.ok();
}); });
//TODO test that sharing link works as expected //TODO test that sharing link works as expected
test('#6 Create sharing link', async t => { test("#6 Create, Edit, delete sharing link", async (t) => {
await t.click(Selector('.nav-albums')); await t.click(Selector(".nav-albums"));
const FirstAlbum = await Selector('div.p-album').nth(0).getAttribute('data-uid'); const FirstAlbum = await Selector("a.is-album").nth(0).getAttribute("data-uid");
await page.selectFromUID(FirstAlbum); await page.selectFromUID(FirstAlbum);
const clipboardCount = await Selector('span.count-clipboard'); const clipboardCount = await Selector("span.count-clipboard");
await t await t
.expect(clipboardCount.textContent).eql("1") .expect(clipboardCount.textContent)
.click(Selector('button.action-menu')) .eql("1")
.click(Selector('button.action-share')) .click(Selector("button.action-menu"))
.click(Selector('div.v-expansion-panel__header__icon').nth(0)); .click(Selector("button.action-share"))
const InitialUrl = await (Selector('.action-url').innerText); .click(Selector("div.v-expansion-panel__header__icon").nth(0));
const InitialSecret = await (Selector('.input-secret input').value) const InitialUrl = await Selector(".action-url").innerText;
const InitialExpire = await (Selector('div.v-select__selections').innerText); const InitialSecret = await Selector(".input-secret input").value;
const InitialExpire = await Selector("div.v-select__selections").innerText;
await t await t
.expect(InitialUrl).notContains('secretfortesting') .expect(InitialUrl)
.expect(InitialExpire).eql('Never') .notContains("secretfortesting")
.typeText(Selector('.input-secret input'), 'secretForTesting', { replace: true }) .expect(InitialExpire)
.click(Selector('.input-expires input')) .eql("Never")
.click(Selector('div').withText('After 1 day').parent('div[role="listitem"]')) .typeText(Selector(".input-secret input"), "secretForTesting", { replace: true })
.click(Selector('button.action-save')) .click(Selector(".input-expires input"))
.click(Selector('button.action-close')) .click(Selector("div").withText("After 1 day").parent('div[role="listitem"]'))
.click(Selector('button.action-share')) .click(Selector("button.action-save"))
.click(Selector('div.v-expansion-panel__header__icon').nth(0)); .click(Selector("button.action-close"))
const UrlAfterChange = await (Selector('.action-url').innerText); .click(Selector("button.action-share"))
const ExpireAfterChange = await (Selector('div.v-select__selections').innerText); .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 await t
.expect(UrlAfterChange).contains('secretfortesting') .expect(UrlAfterChange)
.expect(ExpireAfterChange).eql('After 1 day') .contains("secretfortesting")
.typeText(Selector('.input-secret input'), InitialSecret, { replace: true }) .expect(ExpireAfterChange)
.click(Selector('.input-expires input')) .eql("After 1 day")
.click(Selector('div').withText('Never').parent('div[role="listitem"]')) .typeText(Selector(".input-secret input"), InitialSecret, { replace: true })
.click(Selector('button.action-save')) .click(Selector(".input-expires input"))
.click(Selector('div.v-expansion-panel__header__icon')); .click(Selector("div").withText("Never").parent('div[role="listitem"]'))
const LinkCount = await (Selector('.action-url').count); .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 await t
.click('.action-add-link'); .expect(LinkCountAfterAdd)
const LinkCountAfterAdd = await (Selector('.action-url').count); .eql(LinkCount + 1)
await t .click(Selector("div.v-expansion-panel__header__icon"))
.expect(LinkCountAfterAdd).eql(LinkCount + 1) .click(Selector(".action-delete"));
.click(Selector('div.v-expansion-panel__header__icon')) const LinkCountAfterDelete = await Selector(".action-url").count;
.click(Selector('.action-delete')); await t.expect(LinkCountAfterDelete).eql(LinkCountAfterAdd - 1);
const LinkCountAfterDelete = await (Selector('.action-url').count);
await t
.expect(LinkCountAfterDelete).eql(LinkCountAfterAdd - 1)
}); });

View file

@ -1,14 +1,12 @@
import { Selector } from 'testcafe'; import { Selector } from "testcafe";
import testcafeconfig from '../testcafeconfig'; import testcafeconfig from "../testcafeconfig";
import Page from "../page-model"; import Page from "../page-model";
fixture `Import file from folder` fixture `Import file from folder`
.page`${testcafeconfig.url}`; .page`${testcafeconfig.url}`;
const page = new Page(); const page = new Page();
//TODO use upload + delete test("#1 Import files from folder using copy", async t => {
//TODO check metadata like camera, keywords, location etc are added
test('#1 Import files from folder using copy', async t => {
await t await t
.click(Selector('.nav-labels')); .click(Selector('.nav-labels'));
await page.search('bakery'); await page.search('bakery');
@ -16,7 +14,6 @@ test('#1 Import files from folder using copy', async t => {
.expect(Selector('h3').withText('Couldn\'t find anything').visible).ok(); .expect(Selector('h3').withText('Couldn\'t find anything').visible).ok();
await t await t
.click(Selector('.nav-library')) .click(Selector('.nav-library'))
//TODO Connecting... error must be moved somewhere else
.click(Selector('#tab-library-import')) .click(Selector('#tab-library-import'))
.click(Selector('.input-import-folder input'), {timeout: 5000}) .click(Selector('.input-import-folder input'), {timeout: 5000})
.click(Selector('div.v-list__tile__title').withText('/Bäckerei')) .click(Selector('div.v-list__tile__title').withText('/Bäckerei'))
@ -28,5 +25,5 @@ test('#1 Import files from folder using copy', async t => {
.click(Selector('.action-reload')); .click(Selector('.action-reload'));
await page.search('bakery'); await page.search('bakery');
await t await t
.expect(Selector('.p-label').visible).ok(); .expect(Selector('.is-label').visible).ok();
}); });

View file

@ -6,7 +6,6 @@ fixture `Test index`
.page`${testcafeconfig.url}`; .page`${testcafeconfig.url}`;
const page = new Page(); const page = new Page();
//TODO check metadata like camera, keywords, location etc are added
test('#1 Index files from folder', async t => { test('#1 Index files from folder', async t => {
await t await t
.click(Selector('.nav-labels')); .click(Selector('.nav-labels'));
@ -14,6 +13,27 @@ test('#1 Index files from folder', async t => {
await t await t
.expect(Selector('h3').withText('Couldn\'t find anything').visible).ok() .expect(Selector('h3').withText('Couldn\'t find anything').visible).ok()
.click(Selector('.nav-moments')) .click(Selector('.nav-moments'))
.expect(Selector('h3').withText('Couldn\'t find anything').visible).ok()
.click(Selector('.nav-calendar'));
await page.search('December 2013');
await t
.expect(Selector('h3').withText('Couldn\'t find anything').visible).ok()
.click(Selector('.nav-folders'));
await page.search('Moment');
await t
.expect(Selector('h3').withText('Couldn\'t find anything').visible).ok();
await page.openNav();
await t
.click(Selector('.nav-places + div > i'))
.click(Selector('.nav-states'));
await page.search('KwaZulu');
await t
.expect(Selector('h3').withText('Couldn\'t find anything').visible).ok();
await page.openNav();
await t
.click(Selector('.nav-library+div>i'))
.click(Selector('.nav-originals'))
.click(Selector('.is-folder').withText('moment'))
.expect(Selector('h3').withText('Couldn\'t find anything').visible).ok(); .expect(Selector('h3').withText('Couldn\'t find anything').visible).ok();
await t await t
.click(Selector('.nav-library')) .click(Selector('.nav-library'))
@ -28,8 +48,32 @@ test('#1 Index files from folder', async t => {
.click(Selector('.action-reload')); .click(Selector('.action-reload'));
await page.search('cheetah'); await page.search('cheetah');
await t await t
.expect(Selector('.p-label').visible).ok() .expect(Selector('.is-label').visible).ok()
.click(Selector('.nav-moments')) .click(Selector('.nav-moments'))
.click(Selector('a').withText('South Africa 2013')) .click(Selector('a').withText('South Africa 2013'))
.expect(Selector('.p-photo').visible).ok(); .expect(Selector('.is-photo').visible).ok()
.click(Selector('.nav-calendar'))
.click(Selector('.action-reload'));
await page.search('December 2013');
await t
.expect(Selector('.is-album').visible).ok()
.click(Selector('.nav-folders'))
.click(Selector('.action-reload'));
await page.search('Moment');
await t
.expect(Selector('.is-album').visible).ok();
await page.openNav();
await t
.click(Selector('.nav-places+div>i'))
.click(Selector('.nav-states'))
.click(Selector('.action-reload'));
await page.search('KwaZulu');
await t
.expect(Selector('.is-album').visible).ok();
await page.openNav();
await t
.click(Selector('.nav-library+div>i'))
.click(Selector('.nav-originals'))
.click(Selector('.action-reload'))
.expect(Selector('.is-folder').withText('moment').visible, {timeout: 60000}).ok();
}); });