Feature/ACA-1676 e2e share file (#1106)

* ACA-1676 add share tests with user logouts

* ACA-1676 add share tests with user logouts

* ACA-1676 split the logout test into own describe and reformat the tests a bit.

* ACA-1676 split the logout test into own describe and reformat the tests a bit.

* ACA-1676 split the logout test into own describe and reformat the tests a bit.

* ACA-1676 split the logout test into own describe and reformat the tests a bit.

* ACA-1676 change some protractor config as suggested from Adina

* ACA-1676 change some protractor config as suggested from Adina
This commit is contained in:
Martin Muller
2019-05-14 16:58:58 +01:00
committed by Adina Parpalita
parent d8e3b9ada0
commit 39f528af67
3 changed files with 1019 additions and 1019 deletions

View File

@@ -50,7 +50,8 @@ jobs:
script: SUITE="--suite search" npm run e2e:docker script: SUITE="--suite search" npm run e2e:docker
- name: Test Suite actionsAvailable - name: Test Suite actionsAvailable
script: SUITE="--suite actionsAvailable" npm run e2e:docker script: SUITE="--suite actionsAvailable" npm run e2e:docker
- name: Test Suite actions - stage: e2e
name: Test Suite actions
script: SUITE="--suite actions" npm run e2e:docker script: SUITE="--suite actions" npm run e2e:docker
- name: Test Suite viewer - name: Test Suite viewer
script: SUITE="--suite viewer" npm run e2e:docker script: SUITE="--suite viewer" npm run e2e:docker

View File

@@ -33,30 +33,31 @@ import { Utils } from '../../utilities/utils';
describe('Share a file', () => { describe('Share a file', () => {
const username = `user-${Utils.random()}`; const username = `user-${Utils.random()}`;
const parent = `parent-${Utils.random()}`; let parentId; const parent = `parent-${Utils.random()}`; let parentId;
const expiryDate: any = '2020-12-25T18:30:00.000+0000'; const file1 = `file1-${Utils.random()}.txt`; let file1Id;
const file2 = `file2-${Utils.random()}.txt`; let file2Id;
let file3 = `file3-${Utils.random()}.txt`; let file3Id;
const file4 = `file4-${Utils.random()}.txt`; let file4Id;
let file5 = `file5-${Utils.random()}.txt`; let file5Id;
let file6 = `file6-${Utils.random()}.txt`; let file6Id;
let file7 = `file7-${Utils.random()}.txt`; let file7Id;
const file8 = `file8-${Utils.random()}.txt`; let file8Id;
let file9 = `file9-${Utils.random()}.txt`; let file9Id;
const viewer = new Viewer();
const page = new BrowsingPage();
const { dataTable, toolbar } = page;
const shareLinkPreUrl = "/#/preview/s/";
const apis = { const apis = {
admin: new RepoClient(), admin: new RepoClient(),
user: new RepoClient(username, username) user: new RepoClient(username, username)
}; };
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable, toolbar } = page;
const shareDialog = new ShareDialog();
const viewer = new Viewer();
const contextMenu = dataTable.menu;
const { searchInput } = page.header;
beforeAll(async (done) => { beforeAll(async (done) => {
await apis.admin.people.createUser({ username }); await apis.admin.people.createUser({ username });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id; parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await loginPage.loginWith(username);
done(); done();
}); });
@@ -65,17 +66,47 @@ describe('Share a file', () => {
done(); done();
}); });
describe('from Personal Files', () => { describe('when logged out', () => {
let file6SharedLink;
const file1 = `file1-${Utils.random()}.txt`; let file1Id; beforeAll(async (done) => {
const file2 = `file2-${Utils.random()}.txt`; let file2Id; file6Id = (await apis.user.nodes.createFile(file6, parentId)).entry.id;
const file3 = `file3-${Utils.random()}.txt`; let file3Id; const sharedId = (await apis.user.shared.shareFileById(file6Id)).entry.id;
const file4 = `file4-${Utils.random()}.txt`; let file4Id; file6SharedLink = `${shareLinkPreUrl}${sharedId}`;
const file5 = `file5-${Utils.random()}.txt`; let file5Id; await apis.user.shared.waitForApi({ expect: 1 });
const file6 = `file6-${Utils.random()}.txt`; let file6Id; done();
const file7 = `file7-${Utils.random()}.txt`; let file7Id; });
const file8 = `file8-${Utils.random()}.txt`; let file8Id;
const file9 = `file9-${Utils.random()}.txt`; let file9Id; afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(file6Id);
await apis.user.shared.waitForApi({ expect: 0 });
done();
});
it('A non-logged user can download the shared file from the viewer - [C286326]', async () => {
await browser.get(file6SharedLink);
expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open');
expect(await viewer.getFileTitle()).toEqual(file6);
await toolbar.clickDownload();
expect(await Utils.fileExistsOnOS(file6)).toBe(true, 'File not found in download location');
});
})
describe('when logged in', () => {
const expiryDate: any = '2020-12-25T18:30:00.000+0000';
const loginPage = new LoginPage();
const shareDialog = new ShareDialog();
const contextMenu = dataTable.menu;
const { searchInput } = page.header;
beforeAll(async (done) => {
await loginPage.loginWith(username);
done();
});
describe('from Personal Files', () => {
beforeAll(async (done) => { beforeAll(async (done) => {
file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id;
@@ -127,7 +158,7 @@ describe('Share a file', () => {
expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`); expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`);
expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.'); expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.');
expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share');
expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.getLinkUrl()).toContain(shareLinkPreUrl);
expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly');
expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked');
expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on');
@@ -162,7 +193,7 @@ describe('Share a file', () => {
await toolbar.clickShare(); await toolbar.clickShare();
await shareDialog.waitForDialogToOpen(); await shareDialog.waitForDialogToOpen();
const url = await shareDialog.getLinkUrl(); const url = await shareDialog.getLinkUrl();
expect(url).toContain('/preview/s/'); expect(url).toContain(shareLinkPreUrl);
await shareDialog.copyUrl(); await shareDialog.copyUrl();
expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard'); expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard');
@@ -255,16 +286,6 @@ describe('Share a file', () => {
describe('from File Libraries', () => { describe('from File Libraries', () => {
const file1 = `file1-${Utils.random()}.txt`;
const file2 = `file2-${Utils.random()}.txt`;
const file3 = `file3-${Utils.random()}.txt`; let file3Id;
const file4 = `file4-${Utils.random()}.txt`;
const file5 = `file5-${Utils.random()}.txt`; let file5Id;
const file6 = `file6-${Utils.random()}.txt`; let file6Id;
const file7 = `file7-${Utils.random()}.txt`; let file7Id;
const file8 = `file8-${Utils.random()}.txt`;
const file9 = `file9-${Utils.random()}.txt`; let file9Id;
const siteName = `site-${Utils.random()}`; const siteName = `site-${Utils.random()}`;
const parentInSite = `parent-site-${Utils.random()}`; let parentInSiteId; const parentInSite = `parent-site-${Utils.random()}`; let parentInSiteId;
@@ -317,7 +338,7 @@ describe('Share a file', () => {
expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`); expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`);
expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.'); expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.');
expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share');
expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.getLinkUrl()).toContain(shareLinkPreUrl);
expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly');
expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked');
expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on');
@@ -352,7 +373,7 @@ describe('Share a file', () => {
await toolbar.clickShare(); await toolbar.clickShare();
await shareDialog.waitForDialogToOpen(); await shareDialog.waitForDialogToOpen();
const url = await shareDialog.getLinkUrl(); const url = await shareDialog.getLinkUrl();
expect(url).toContain('/preview/s/'); expect(url).toContain(shareLinkPreUrl);
await shareDialog.copyUrl(); await shareDialog.copyUrl();
expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard'); expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard');
@@ -445,16 +466,6 @@ describe('Share a file', () => {
describe('from Recent Files', () => { describe('from Recent Files', () => {
const file1 = `file1-${Utils.random()}.txt`; let file1Id;
const file2 = `file2-${Utils.random()}.txt`; let file2Id;
const file3 = `file3-${Utils.random()}.txt`; let file3Id;
const file4 = `file4-${Utils.random()}.txt`; let file4Id;
const file5 = `file5-${Utils.random()}.txt`; let file5Id;
const file6 = `file6-${Utils.random()}.txt`; let file6Id;
const file7 = `file7-${Utils.random()}.txt`; let file7Id;
const file8 = `file8-${Utils.random()}.txt`; let file8Id;
const file9 = `file9-${Utils.random()}.txt`; let file9Id;
beforeAll(async (done) => { beforeAll(async (done) => {
file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id;
file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id;
@@ -504,7 +515,7 @@ describe('Share a file', () => {
expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`); expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`);
expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.'); expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.');
expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share');
expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.getLinkUrl()).toContain(shareLinkPreUrl);
expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly');
expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked');
expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on');
@@ -539,7 +550,7 @@ describe('Share a file', () => {
await toolbar.clickShare(); await toolbar.clickShare();
await shareDialog.waitForDialogToOpen(); await shareDialog.waitForDialogToOpen();
const url = await shareDialog.getLinkUrl(); const url = await shareDialog.getLinkUrl();
expect(url).toContain('/preview/s/'); expect(url).toContain(shareLinkPreUrl);
await shareDialog.copyUrl(); await shareDialog.copyUrl();
expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard'); expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard');
@@ -632,14 +643,6 @@ describe('Share a file', () => {
describe('from Shared Files', () => { describe('from Shared Files', () => {
const file1 = `file1-${Utils.random()}.txt`; let file1Id;
const file2 = `file2-${Utils.random()}.txt`; let file2Id;
const file3 = `file3-${Utils.random()}.txt`; let file3Id;
const file4 = `file4-${Utils.random()}.txt`; let file4Id;
const file5 = `file5-${Utils.random()}.txt`; let file5Id;
const file6 = `file6-${Utils.random()}.txt`; let file6Id;
const file7 = `file7-${Utils.random()}.txt`; let file7Id;
beforeAll(async (done) => { beforeAll(async (done) => {
file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id;
file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id;
@@ -691,7 +694,7 @@ describe('Share a file', () => {
expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`); expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`);
expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.'); expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.');
expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share');
expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.getLinkUrl()).toContain(shareLinkPreUrl);
expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly');
expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked');
expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on');
@@ -714,7 +717,7 @@ describe('Share a file', () => {
await toolbar.clickSharedLinkSettings(); await toolbar.clickSharedLinkSettings();
await shareDialog.waitForDialogToOpen(); await shareDialog.waitForDialogToOpen();
const url = await shareDialog.getLinkUrl(); const url = await shareDialog.getLinkUrl();
expect(url).toContain('/preview/s/'); expect(url).toContain(shareLinkPreUrl);
await shareDialog.copyUrl(); await shareDialog.copyUrl();
expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard'); expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard');
@@ -779,7 +782,7 @@ describe('Share a file', () => {
expect(await shareDialog.getTitle()).toEqual(`Share ${file7}`); expect(await shareDialog.getTitle()).toEqual(`Share ${file7}`);
expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.'); expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.');
expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share');
expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.getLinkUrl()).toContain(shareLinkPreUrl);
expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly');
expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked');
expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on');
@@ -790,16 +793,6 @@ describe('Share a file', () => {
describe('from Favorites', () => { describe('from Favorites', () => {
const file1 = `file1-${Utils.random()}.txt`; let file1Id;
const file2 = `file2-${Utils.random()}.txt`; let file2Id;
const file3 = `file3-${Utils.random()}.txt`; let file3Id;
const file4 = `file4-${Utils.random()}.txt`; let file4Id;
const file5 = `file5-${Utils.random()}.txt`; let file5Id;
const file6 = `file6-${Utils.random()}.txt`; let file6Id;
const file7 = `file7-${Utils.random()}.txt`; let file7Id;
const file8 = `file8-${Utils.random()}.txt`; let file8Id;
const file9 = `file9-${Utils.random()}.txt`; let file9Id;
beforeAll(async (done) => { beforeAll(async (done) => {
file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id;
file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id;
@@ -861,7 +854,7 @@ describe('Share a file', () => {
expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`); expect(await shareDialog.getTitle()).toEqual(`Share ${file1}`);
expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.'); expect(await shareDialog.getInfoText()).toEqual('Click the link below to copy it to the clipboard.');
expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share');
expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.getLinkUrl()).toContain(shareLinkPreUrl);
expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly');
expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked');
expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on');
@@ -896,7 +889,7 @@ describe('Share a file', () => {
await toolbar.clickShare(); await toolbar.clickShare();
await shareDialog.waitForDialogToOpen(); await shareDialog.waitForDialogToOpen();
const url = await shareDialog.getLinkUrl(); const url = await shareDialog.getLinkUrl();
expect(url).toContain('/preview/s/'); expect(url).toContain(shareLinkPreUrl);
await shareDialog.copyUrl(); await shareDialog.copyUrl();
expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard'); expect(await page.getSnackBarMessage()).toBe('Link copied to the clipboard');
@@ -988,11 +981,12 @@ describe('Share a file', () => {
}); });
describe('from Search Results', () => { describe('from Search Results', () => {
const file3 = `search-file3-${Utils.random()}.txt`; let file3Id;
const file5 = `search-file5-${Utils.random()}.txt`; let file5Id; file3 = `search-file3-${Utils.random()}.txt`;
const file6 = `search-file6-${Utils.random()}.txt`; let file6Id; file5 = `search-file5-${Utils.random()}.txt`;
const file7 = `search-file7-${Utils.random()}.txt`; let file7Id; file6 = `search-file6-${Utils.random()}.txt`;
const file9 = `search-file9-${Utils.random()}.txt`; let file9Id; file7 = `search-file7-${Utils.random()}.txt`;
file9 = `search-file9-${Utils.random()}.txt`;
beforeAll(async (done) => { beforeAll(async (done) => {
file3Id = (await apis.user.nodes.createFile(file3, parentId)).entry.id; file3Id = (await apis.user.nodes.createFile(file3, parentId)).entry.id;
@@ -1104,5 +1098,5 @@ describe('Share a file', () => {
expect(url).toContain(sharedId); expect(url).toContain(sharedId);
}); });
}); });
})
}); });

View File

@@ -80,7 +80,7 @@ exports.config = {
'--incognito', '--incognito',
'--headless', '--headless',
'--remote-debugging-port=9222', '--remote-debugging-port=9222',
`--window-size=${width},${height}`, '--disable-gpu',
'--no-sandbox' '--no-sandbox'
] ]
} }
@@ -118,6 +118,11 @@ exports.config = {
project: 'e2e/tsconfig.e2e.json' project: 'e2e/tsconfig.e2e.json'
}); });
browser
.manage()
.window()
.setSize(width, height);
jasmine.getEnv().addReporter( jasmine.getEnv().addReporter(
new SpecReporter({ new SpecReporter({
spec: { spec: {