Fix Search results for Threads when useContainers=1

This commit is contained in:
Colin Kuskie 2010-02-25 08:59:33 -08:00
parent 25aad27cdb
commit 3a054b4895
7 changed files with 106 additions and 19 deletions

View file

@ -13,7 +13,7 @@ use strict;
use lib "$FindBin::Bin/../../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 5; # increment this value for each test you create
use Test::More tests => 9; # increment this value for each test you create
use Test::MockObject::Extends;
use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post::Thread;
@ -30,7 +30,12 @@ addToCleanup($versionTag);
# Need to create a Collaboration system in which the post lives.
my @addArgs = ( undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1 } );
my $collab = $node->addChild({className => 'WebGUI::Asset::Wobject::Collaboration', editTimeout => '1'}, @addArgs);
my $collab = $node->addChild({
className => 'WebGUI::Asset::Wobject::Collaboration',
editTimeout => '1',
threadsPerPage => 3,
},
@addArgs);
# finally, add the post to the collaboration system
@ -63,8 +68,19 @@ $thread->rate(1);
$thread->trash;
is($thread->get('threadRating'), 0, 'trash does not die, and updates the threadRating to 0');
unlike $thread->getDirectLinkUrl, qr/\?pn=\d+/, 'threads do not need pagination url query fragments';
unlike $uncommittedThread->getDirectLinkUrl, qr/\?pn=\d+/, 'uncommitted threads, too';
like $uncommittedThread->getDirectLinkUrl, qr/\?revision=\d+/, 'uncommitted threads do have a revision query param';
note 'getThreadLinkUrl';
unlike $thread->getThreadLinkUrl, qr/\?pn=\d+/, 'threads do not need pagination url query fragments';
unlike $uncommittedThread->getThreadLinkUrl, qr/\?pn=\d+/, 'uncommitted threads, too';
like $uncommittedThread->getThreadLinkUrl, qr/\?revision=\d+/, 'uncommitted threads do have a revision query param';
note 'getCSLinkUrl';
my @newThreads;
push @newThreads, $collab->addChild($props, @addArgs);
push @newThreads, $collab->addChild($props, @addArgs);
my $csUrl = $collab->get('url');
like $newThreads[-1]->getCSLinkUrl, qr/^$csUrl/, 'getCsLinkUrl returns URL of the parent CS with no gateway';
like $newThreads[-1]->getCSLinkUrl, qr/\?pn=1/, 'and has the right page number';
like $newThreads[-1]->getCSLinkUrl, qr/\?pn=1;sortBy=lineage;sortOrder=desc/, 'and has the right sort parameters';
like $thread->getCSLinkUrl, qr/\?pn=2/, 'checking 2nd thread on another page';
# vim: syntax=perl filetype=perl

View file

@ -16,14 +16,15 @@ use lib "$FindBin::Bin/../../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 9; # increment this value for each test you create
use Test::More tests => 11; # increment this value for each test you create
use Test::Deep;
use WebGUI::Asset::Wobject::Search;
use Data::Dumper;
my $session = WebGUI::Test->session;
# Do our work in the import node
my $node = WebGUI::Asset->getImportNode($session);
my $node = WebGUI::Asset->getDefault($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Search Test"});
@ -85,10 +86,50 @@ $search->update({
ok(! $@, 'view did now error out on prefix regexp wildcard')
or diag $@;
WebGUI::Test->unmockAssetId($templateId);
$session->request->setup_body({});
}
$session->request->setup_body({});
{
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
$versionTag2->set({name=>"Collab setup"});
my @addArgs = ( undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1 } );
my $collab = $node->addChild({
className => 'WebGUI::Asset::Wobject::Collaboration',
editTimeout => '1',
threadsPerPage => 3,
},
@addArgs);
# finally, add the post to the collaboration system
my $props = {
className => 'WebGUI::Asset::Post::Thread',
content => 'verbosity shale anything',
ownerUserId => 1,
};
my $thread = $collab->addChild($props, @addArgs);
$versionTag2->commit();
addToCleanup($versionTag2);
$session->request->setup_body({
doit => 1,
keywords => 'shale',
});
WebGUI::Test->mockAssetId($templateId, $templateMock);
$search->prepareView;
$search->view;
$search->update({useContainers => 0});
unlike $templateVars->{result_set}->[0]->{url}, qr{\?pn=\d}, 'search returns regular URL for a Thread';
$search->update({useContainers => 1});
$search->view;
like $templateVars->{result_set}->[0]->{url}, qr{\?pn=\d}, 'search returns paginated URL for a Thread when useContainers=1';
diag Dumper $templateVars;
WebGUI::Test->unmockAssetId($templateId);
$session->request->setup_body({});
$search->update({useContainers => 0});
}
TODO: {
local $TODO = "Tests to make later";