revisions.t 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Copyright (C) 2006–2015 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. require './t/test.pl';
  15. package OddMuse;
  16. use Test::More tests => 23;
  17. ## Test revision and diff stuff
  18. update_page('KeptRevisions', 'first');
  19. #sleep 120; # TODO implement fake time!
  20. update_page('KeptRevisions', 'second', '', 0, 0, 'username=BestContributorEver');
  21. #sleep 120; # TODO implement fake time!
  22. update_page('KeptRevisions', 'third');
  23. update_page('KeptRevisions', 'fourth', '', 1);
  24. update_page('KeptRevisions', 'fifth', '', 1);
  25. # Show the current revision
  26. test_page(get_page(KeptRevisions),
  27. 'KeptRevisions',
  28. 'fifth');
  29. # Show the other revision
  30. test_page(get_page('action=browse revision=2 id=KeptRevisions'),
  31. 'Showing revision 2',
  32. 'second');
  33. test_page(get_page('action=browse revision=1 id=KeptRevisions'),
  34. 'Showing revision 1',
  35. 'first');
  36. # Show the current revision if an inexisting revision is asked for
  37. test_page(get_page('action=browse revision=9 id=KeptRevisions'),
  38. 'Revision 9 not available \(showing current revision instead\)',
  39. 'fifth');
  40. my ($ts2) = get_page('action=browse revision=2 id=KeptRevisions') =~ /edited (.*?) diff/ix;
  41. my ($ts3) = get_page('action=browse revision=3 id=KeptRevisions') =~ /edited (.*?) diff/ix;
  42. ok($ts2 ne $ts3, 'Revision timestamp or author is different');
  43. # Request the correct last major diff
  44. xpath_test(get_page('action=browse diff=1 id=KeptRevisions'),
  45. '//div[@class="diff"]/p/b[contains(text(), "Last major edit")]',
  46. '//div[@class="diff"]/p/b/a[contains(text(), "later minor edits")]',
  47. '//div[@class="diff"]/p/b/a[@href="http://localhost/wiki.pl?action=browse;diff=2;id=KeptRevisions;diffrevision=3"]',
  48. '//div[@class="diff"]/div[@class="old"]/p/strong[contains(text(), "second")]',
  49. '//div[@class="diff"]/div[@class="new"]/p/strong[contains(text(), "third")]',
  50. '//div[@class="content browse"]/p[contains(text(), "fifth")]');
  51. # Look at the remaining differences
  52. test_page(get_page('action=browse diff=2 id=KeptRevisions diffrevision=3'),
  53. 'Difference between revision 3 and current revision',
  54. 'third',
  55. 'fifth');
  56. # Show a diff from the history page comparing two specific revisions
  57. test_page(get_page('action=browse diff=1 revision=4 diffrevision=2 id=KeptRevisions'),
  58. 'Difference between revision 2 and revision 4',
  59. 'second',
  60. 'fourth');
  61. # Show no difference
  62. update_page('KeptRevisions', 'second');
  63. test_page(get_page('action=browse diff=1 revision=6 diffrevision=2 id=KeptRevisions'),
  64. 'Difference between revision 2 and current revision',
  65. 'The two revisions are the same');