publicSpec.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * @copyright 2018 Julius Härtl <jus@bitgrid.net>
  3. *
  4. * @author 2018 Julius Härtl <jus@bitgrid.net>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. const puppeteer = require('puppeteer');
  23. const helper = require('../helper.js');
  24. const config = require('../config.js');
  25. describe('public', function () {
  26. before(async () => {
  27. await helper.init(this)
  28. await helper.login(this)
  29. });
  30. after(async () => await helper.exit());
  31. /**
  32. * Test invalid file share rendering
  33. */
  34. config.resolutions.forEach(function (resolution) {
  35. it('file-share-invalid.' + resolution.title, async function () {
  36. return helper.takeAndCompare(this, 'index.php/s/invalid', async function () {
  37. }, {waitUntil: 'networkidle2', viewport: resolution});
  38. });
  39. });
  40. /**
  41. * Share a file via public link
  42. */
  43. var shareLink = {};
  44. it('file-share-link', async function () {
  45. return helper.takeAndCompare(this, 'index.php/apps/files', async function (page) {
  46. const element = await page.$('[data-file="welcome.txt"] .action-share');
  47. await element.click('[data-file="welcome.txt"] .action-share');
  48. await page.waitForSelector('input.linkCheckbox');
  49. const linkCheckbox = await page.$('.linkShareView label');
  50. await Promise.all([
  51. linkCheckbox.click(),
  52. page.waitForSelector('.linkText')
  53. ]);
  54. await helper.delay(500);
  55. const text = await page.waitForSelector('.linkText');
  56. const link = await (await text.getProperty('value')).jsonValue();
  57. shareLink[page.url()] = link;
  58. return await helper.delay(500);
  59. }, {
  60. runOnly: true,
  61. waitUntil: 'networkidle2',
  62. viewport: {w: 1920, h: 1080}
  63. });
  64. });
  65. config.resolutions.forEach(function (resolution) {
  66. it('file-share-valid.' + resolution.title, async function () {
  67. return helper.takeAndCompare(this, 'index.php/apps/files', async function (page) {
  68. await page.goto(shareLink[page.url()]);
  69. await helper.delay(500);
  70. }, {waitUntil: 'networkidle2', viewport: resolution});
  71. });
  72. it('file-share-valid-actions.' + resolution.title, async function () {
  73. return helper.takeAndCompare(this, undefined, async function (page) {
  74. const moreButton = await page.waitForSelector('#header-secondary-action');
  75. await moreButton.click();
  76. await page.evaluate((data) => {
  77. return document.querySelector('#directLink').value = 'http://nextcloud.example.com/';
  78. });
  79. await helper.delay(500);
  80. }, {waitUntil: 'networkidle2', viewport: resolution});
  81. });
  82. });
  83. it('file-unshare', async function () {
  84. return helper.takeAndCompare(this, 'index.php/apps/files', async function (page) {
  85. const element = await page.$('[data-file="welcome.txt"] .action-share');
  86. await element.click('[data-file="welcome.txt"] .action-share');
  87. await page.waitForSelector('input.linkCheckbox');
  88. const linkCheckbox = await page.$('.linkShareView label');
  89. await linkCheckbox.click();
  90. await helper.delay(500);
  91. }, { waitUntil: 'networkidle2', viewport: {w: 1920, h:1080}});
  92. });
  93. });