[Jifty-commit] r4637 - in jifty/trunk/t/TestApp-JiftyJS: . bin doc
etc lib lib/TestApp lib/TestApp/JiftyJS
lib/TestApp/JiftyJS/Action lib/TestApp/JiftyJS/Model log
share share/po share/web share/web/static share/web/templates t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Dec 7 08:31:24 EST 2007
Author: gugod
Date: Fri Dec 7 08:31:17 2007
New Revision: 4637
Added:
jifty/trunk/t/TestApp-JiftyJS/
jifty/trunk/t/TestApp-JiftyJS/Makefile.PL
jifty/trunk/t/TestApp-JiftyJS/bin/
jifty/trunk/t/TestApp-JiftyJS/bin/jifty (contents, props changed)
jifty/trunk/t/TestApp-JiftyJS/doc/
jifty/trunk/t/TestApp-JiftyJS/etc/
jifty/trunk/t/TestApp-JiftyJS/etc/config.yml
jifty/trunk/t/TestApp-JiftyJS/lib/
jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/
jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/
jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Action/
jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Model/
jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm
jifty/trunk/t/TestApp-JiftyJS/log/
jifty/trunk/t/TestApp-JiftyJS/share/
jifty/trunk/t/TestApp-JiftyJS/share/po/
jifty/trunk/t/TestApp-JiftyJS/share/web/
jifty/trunk/t/TestApp-JiftyJS/share/web/static/
jifty/trunk/t/TestApp-JiftyJS/share/web/templates/
jifty/trunk/t/TestApp-JiftyJS/t/
jifty/trunk/t/TestApp-JiftyJS/t/1-jifty-update.t
jifty/trunk/t/TestApp-JiftyJS/var/
Log:
Prepare a TestApp just for testing jifty.js javascript functions.
The goal is to test javascript code, not just perl code, so using
selenium is a must. Pretty much like this test suit should be the
counter-part of mech-based tests under TestApp/.
Provide a simple test file to test Jifty.update() function, both
with and without argument.
Added: jifty/trunk/t/TestApp-JiftyJS/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-JiftyJS/Makefile.PL Fri Dec 7 08:31:17 2007
@@ -0,0 +1,7 @@
+use inc::Module::Install;
+
+name 'TestApp::JiftyJS/';
+version '0.01';
+requires 'Jifty' => '0.70824';
+
+WriteAll;
Added: jifty/trunk/t/TestApp-JiftyJS/bin/jifty
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-JiftyJS/bin/jifty Fri Dec 7 08:31:17 2007
@@ -0,0 +1,11 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use File::Basename qw(dirname);
+use UNIVERSAL::require;
+
+use Jifty;
+use Jifty::Script;
+
+local $SIG{INT} = sub { warn "Stopped\n"; exit; };
+Jifty::Script->dispatch();
Added: jifty/trunk/t/TestApp-JiftyJS/etc/config.yml
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-JiftyJS/etc/config.yml Fri Dec 7 08:31:17 2007
@@ -0,0 +1,67 @@
+---
+framework:
+ AdminMode: 1
+ ApplicationClass: TestApp::JiftyJS
+ ApplicationName: TestApp::JiftyJS
+ ApplicationUUID: F43CA57E-A4BE-11DC-A07C-465A83BE23AB
+ ConfigFileVersion: 2
+ Database:
+ CheckSchema: 1
+ Database: testapp_jiftyjs
+ Driver: SQLite
+ Host: localhost
+ Password: ''
+ RecordBaseClass: Jifty::DBI::Record::Cachable
+ User: ''
+ Version: 0.0.1
+ DevelMode: 1
+ L10N:
+ PoDir: share/po
+ LogLevel: INFO
+ Mailer: Sendmail
+ MailerArgs: []
+
+ Plugins:
+ -
+ LetMe: {}
+
+ -
+ SkeletonApp: {}
+
+ -
+ REST: {}
+
+ -
+ Halo: {}
+
+ -
+ ErrorTemplates: {}
+
+ -
+ OnlineDocs: {}
+
+ -
+ CompressedCSSandJS: {}
+
+ -
+ AdminUI: {}
+
+ PubSub:
+ Backend: Memcached
+ Enable: ~
+ SkipAccessControl: 0
+ TemplateClass: TestApp::JiftyJS::View
+ Web:
+ BaseURL: http://localhost
+ DataDir: var/mason
+ Globals: []
+
+ MasonConfig:
+ autoflush: 0
+ default_escape_flags: h
+ error_format: text
+ error_mode: fatal
+ Port: 8888
+ ServeStaticFiles: 1
+ StaticRoot: share/web/static
+ TemplateRoot: share/web/templates
Added: jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm Fri Dec 7 08:31:17 2007
@@ -0,0 +1,64 @@
+package TestApp::JiftyJS::View;
+use Jifty::View::Declare -base;
+
+template '/1-jifty-update.html' => page {
+ h1 { "Jifty.update() tests" };
+
+ hyperlink(
+ id => 'region1',
+ label => "Region 1",
+ onclick => {
+ region => 'content',
+ replace_with => 'region1'
+ }
+ );
+
+ hyperlink(
+ id => 'region2',
+ label => "Region 2",
+ onclick => {
+ region => 'content',
+ replace_with => 'region2'
+ }
+ );
+
+ hyperlink(
+ id => 'region3',
+ label => "John",
+ onclick => {
+ region => 'content',
+ replace_with => 'hello_world',
+ args => {
+ name => "John"
+ }
+ }
+ );
+
+ hyperlink(
+ id => 'region4',
+ label => "Smith",
+ onclick => {
+ region => 'content',
+ replace_with => 'hello_world',
+ args => {
+ name => "Smith"
+ }
+ }
+ );
+
+ render_region( name => 'content' );
+};
+
+template 'hello_world' => sub {
+ p { "Hello, " . ( get('name') || "World" ) }
+};
+
+template 'region1' => sub {
+ p { "Region One" }
+};
+
+template 'region2' => sub {
+ p { "Region Two" }
+};
+
+1;
Added: jifty/trunk/t/TestApp-JiftyJS/t/1-jifty-update.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-JiftyJS/t/1-jifty-update.t Fri Dec 7 08:31:17 2007
@@ -0,0 +1,44 @@
+# This test is for testing Jifty.update() javascript function.
+
+use strict;
+use warnings;
+use lib 't/lib';
+use Jifty::SubTest;
+use Jifty::Test tests => 12;
+use Jifty::Test::WWW::Selenium;
+use utf8;
+
+my $server = Jifty::Test->make_server;
+my $sel = Jifty::Test::WWW::Selenium->rc_ok($server);
+my $URL = $server->started_ok;
+
+$sel->open_ok("/1-jifty-update.html");
+
+my $html = $sel->get_html_source;
+
+like $html, qr{<h1>Jifty\.update\(\) tests</h1>}is;
+
+$sel->click_ok("region1");
+sleep 2;
+$html = $sel->get_html_source;
+like $html, qr{<p>Region One</p>}is;
+
+$sel->click_ok("region2");
+sleep 2;
+$html = $sel->get_html_source;
+like $html, qr{<p>Region Two</p>}is;
+
+
+# Update the same region path with different argument
+$sel->click_ok("region3");
+sleep 2;
+$html = $sel->get_html_source;
+like $html, qr{<p>Hello, John</p>}is;
+
+$sel->click_ok("region4");
+sleep 2;
+$html = $sel->get_html_source;
+like $html, qr{<p>Hello, Smith</p>}is;
+
+$sel->stop;
+
More information about the Jifty-commit
mailing list