summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/authenticated-de.t112
-rw-r--r--t/journey-edit.t (renamed from t/12-journey-edit.t)0
-rw-r--r--t/journey-stats.t (renamed from t/11-journey-stats.t)0
-rw-r--r--t/journey-visibility.t (renamed from t/23-journey-visibility.t)0
-rw-r--r--t/past-visibility.t (renamed from t/24-past-visibility.t)0
-rw-r--r--t/registration.t (renamed from t/10-registration.t)0
-rw-r--r--t/relations.t (renamed from t/21-relations.t)0
-rw-r--r--t/static-de.t (renamed from t/01-static.t)0
-rw-r--r--t/static-en.t (renamed from t/02-static-en.t)0
-rw-r--r--t/static-fr.t (renamed from t/03-static-fr.t)0
-rw-r--r--t/transit-visibility.t (renamed from t/22-transit-visibility.t)0
11 files changed, 112 insertions, 0 deletions
diff --git a/t/authenticated-de.t b/t/authenticated-de.t
new file mode 100644
index 0000000..f6a9c5c
--- /dev/null
+++ b/t/authenticated-de.t
@@ -0,0 +1,112 @@
+#!/usr/bin/env perl
+
+# Copyright (C) 2025 Birte Kristina Friesel <derf@finalrewind.org>
+#
+# SPDX-License-Identifier: MIT
+
+use Mojo::Base -strict;
+
+use Test::More;
+use Test::Mojo;
+
+# Include application
+use FindBin;
+require "$FindBin::Bin/../index.pl";
+
+my $t = Test::Mojo->new('Travelynx');
+
+$t->ua->on( start => sub { $_[1]->req->headers->accept_language('de-DE') } );
+
+if ( not $t->app->config->{db} ) {
+ plan( skip_all => 'No database configured' );
+}
+
+# Account boilerplate
+
+$t->app->pg->db->query('drop schema if exists travelynx_test_auth_de cascade');
+$t->app->pg->db->query('create schema travelynx_test_auth_de');
+$t->app->pg->db->query('set search_path to travelynx_test_auth_de');
+$t->app->pg->on(
+ connection => sub {
+ my ( $pg, $dbh ) = @_;
+ $dbh->do('set search_path to travelynx_test_auth_de');
+ }
+);
+
+$t->app->config->{mail}->{disabled} = 1;
+
+$ENV{__TRAVELYNX_TEST_MINI_IRIS} = 1;
+$t->app->start( 'database', 'migrate' );
+
+my $csrf_token
+ = $t->ua->get('/register')->res->dom->at('input[name=csrf_token]')
+ ->attr('value');
+
+# Successful registration
+$t->post_ok(
+ '/register' => form => {
+ csrf_token => $csrf_token,
+ dt => 1,
+ user => 'someone',
+ email => 'foo@example.org',
+ password => 'foofoofoo',
+ password2 => 'foofoofoo',
+ }
+);
+$t->status_is(200)->content_like(qr{Verifizierungslink});
+
+my $res = $t->app->pg->db->select( 'users', ['id'], { name => 'someone' } );
+my $uid = $res->hash->{id};
+$res = $t->app->pg->db->select( 'pending_registrations', ['token'],
+ { user_id => $uid } );
+my $token = $res->hash->{token};
+
+# Successful verification
+$t->get_ok("/reg/${uid}/${token}");
+$t->status_is(200)->content_like(qr{freigeschaltet});
+
+# Successful login
+$t->post_ok(
+ '/login' => form => {
+ csrf_token => $csrf_token,
+ user => 'someone',
+ password => 'foofoofoo',
+ }
+);
+$t->status_is(302)->header_is( location => '/' );
+
+# Actual Test
+
+$t->get_ok('/account')->status_is(200);
+$t->text_like( 'a[href="/p/someone"]' => qr{Öffentliches Profil} );
+$t->text_like( 'a[href="/api"]' => qr{Dokumentation} );
+
+for my $subpage (qw(privacy social profile hooks insight language)) {
+ $t->get_ok("/account/${subpage}")->status_is(200);
+ $t->text_like( 'button' => qr{Speichern} );
+}
+
+for my $subpage (qw(password mail name)) {
+ $t->get_ok("/account/${subpage}")->status_is(200);
+ $t->text_like( 'button' => qr{Ändern} );
+}
+
+$t->get_ok('/account/select_backend')->status_is(200);
+$t->text_like( 'a[href="#help"]' => qr{Details} );
+
+$t->get_ok('/account/traewelling')->status_is(200);
+$t->text_like( 'button' => qr{Verknüpfen} );
+
+$t->get_ok('/history')->status_is(200);
+$t->text_like( 'a[href="/history/map"]' => qr{Fahrtenkarte} );
+
+$t->get_ok('/history/map')->status_is(200);
+$t->text_like( 'button[type="submit"]' => qr{Anzeigen} );
+
+$t->get_ok('/history/commute')->status_is(200);
+$t->text_like( 'button[type="submit"]' => qr{Anzeigen} );
+
+$t->get_ok('/journey/add')->status_is(200);
+$t->text_like( 'button[type="submit"]' => qr{Hinzufügen} );
+
+done_testing();
diff --git a/t/12-journey-edit.t b/t/journey-edit.t
index f0b2f36..f0b2f36 100644
--- a/t/12-journey-edit.t
+++ b/t/journey-edit.t
diff --git a/t/11-journey-stats.t b/t/journey-stats.t
index 205bf96..205bf96 100644
--- a/t/11-journey-stats.t
+++ b/t/journey-stats.t
diff --git a/t/23-journey-visibility.t b/t/journey-visibility.t
index c2294b3..c2294b3 100644
--- a/t/23-journey-visibility.t
+++ b/t/journey-visibility.t
diff --git a/t/24-past-visibility.t b/t/past-visibility.t
index 5c084b2..5c084b2 100644
--- a/t/24-past-visibility.t
+++ b/t/past-visibility.t
diff --git a/t/10-registration.t b/t/registration.t
index ec09eaf..ec09eaf 100644
--- a/t/10-registration.t
+++ b/t/registration.t
diff --git a/t/21-relations.t b/t/relations.t
index c5fbe32..c5fbe32 100644
--- a/t/21-relations.t
+++ b/t/relations.t
diff --git a/t/01-static.t b/t/static-de.t
index 21d0350..21d0350 100644
--- a/t/01-static.t
+++ b/t/static-de.t
diff --git a/t/02-static-en.t b/t/static-en.t
index 26641cb..26641cb 100644
--- a/t/02-static-en.t
+++ b/t/static-en.t
diff --git a/t/03-static-fr.t b/t/static-fr.t
index dc4c278..dc4c278 100644
--- a/t/03-static-fr.t
+++ b/t/static-fr.t
diff --git a/t/22-transit-visibility.t b/t/transit-visibility.t
index 6aa48ed..6aa48ed 100644
--- a/t/22-transit-visibility.t
+++ b/t/transit-visibility.t