Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ coverage:
# it is only QOL change and not required
#
comment:
after_n_builds: 32
after_n_builds: 29
17 changes: 7 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ jobs:
- web-comments
- web-general
- web-media-library
- web-notifications1
- web-notifications2
- web-notifications3
- web-notifications4
- web-notifications
- web-profile
- web-project
- web-project-details
Expand Down Expand Up @@ -199,7 +196,7 @@ jobs:
# - If the tests pass we can set the output status to success, this allows to only execute the reruns if needed
run: |
echo ::set-output name=status::failure
docker exec app.catroweb bin/behat -s ${{ matrix.testSuite }} \
docker exec app.catroweb bin/behat -s ${{ matrix.testSuite }} -f pretty \
|& tee tests/testreports/behat/${{ matrix.testSuite }}.log ; \
( exit ${PIPESTATUS[0]} )
echo ::set-output name=status::success
Expand All @@ -210,8 +207,8 @@ jobs:
if: always()
id: missing-check
run: |
cat tests/testreports/behat/${{ matrix.testSuite }}.log;
if grep -q 'has missing steps. Define them with these snippets:' tests/testreports/behat/${{ matrix.testSuite }}.log; then
cat tests/testreports/behat/${{ matrix.testSuite }}.log;
false;
fi

Expand All @@ -221,19 +218,19 @@ jobs:
if: always()
id: pending-check
run: |
cat tests/testreports/behat/${{ matrix.testSuite }}.log;
if grep -q 'pending)' tests/testreports/behat/${{ matrix.testSuite }}.log; then
cat tests/testreports/behat/${{ matrix.testSuite }}.log;
false;
fi

# Chrome exception are problems that can't be fixed with a rerun
# Chrome exception are problems that can't be fixed with a rerun. However, we can try to run the whole suite one more time
- name: Check that suite has NO chrome exceptions
if: always()
id: chrome-exception-check
run: |
cat tests/testreports/behat/${{ matrix.testSuite }}.log;
if grep -q '\[DMore\\ChromeDriver\\StreamReadException\]' tests/testreports/behat/${{ matrix.testSuite }}.log; then
false;
cat tests/testreports/behat/${{ matrix.testSuite }}.log;
docker exec app.catroweb bin/behat -s ${{ matrix.testSuite }} -f pretty;
fi

- uses: codecov/codecov-action@v1
Expand Down
32 changes: 4 additions & 28 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ default:
api_url: "http://localhost:9222"
download_behavior: allow
download_path: tests/testdata/UploadDownloadTemp
socket_timeout: 60
dom_wait_timeout: 10000
socket_timeout: 90
dom_wait_timeout: 15000

DVDoug\Behat\CodeCoverage\Extension:
filter:
Expand Down Expand Up @@ -203,38 +203,14 @@ default:
- Tests\behat\context\CatrowebBrowserContext
- Tests\behat\context\ApiContext

web-notifications1:
paths: ["tests/behat/features/web/notifications1"]
web-notifications:
paths: ["tests/behat/features/web/notifications"]
contexts:
- Tests\behat\context\RefreshEnvironmentContext
- Tests\behat\context\DataFixturesContext
- Tests\behat\context\CatrowebBrowserContext
- Tests\behat\context\ApiContext

web-notifications2:
paths: ["tests/behat/features/web/notifications2"]
contexts:
- Tests\behat\context\RefreshEnvironmentContext
- Tests\behat\context\DataFixturesContext
- Tests\behat\context\CatrowebBrowserContext
- Tests\behat\context\ApiContext

web-notifications3:
paths: ["tests/behat/features/web/notifications3"]
contexts:
- Tests\behat\context\RefreshEnvironmentContext
- Tests\behat\context\DataFixturesContext
- Tests\behat\context\CatrowebBrowserContext
- Tests\behat\context\ApiContext

web-notifications4:
paths: ["tests/behat/features/web/notifications4"]
contexts:
- Tests\behat\context\RefreshEnvironmentContext
- Tests\behat\context\DataFixturesContext
- Tests\behat\context\CatrowebBrowserContext
- Tests\behat\context\ApiContext

web-profile:
paths: [ "tests/behat/features/web/profile" ]
contexts:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ services:
volumes:
- ./../tests/testdata/DataFixtures:/var/www/catroweb/tests/testdata/DataFixtures:ro
- ./../tests/testdata/UploadDownloadTemp:/var/www/catroweb/tests/testdata/UploadDownloadTemp
command: ["chromium-browser", "--headless", "--disable-gpu", "--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222", "--disable-extensions", "--disable-dev-shm-usage", "--disable-software-rasterizer", "--no-sandbox"]
command: ["chromium-browser", "--disable-gpu", "--headless", "--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222", "--disable-extensions", "--no-sandbox"]
ports:
- 9222

Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
restart: on-failure
volumes:
- ./../tests/testdata/DataFixtures:/var/www/catroweb/tests/testdata/DataFixtures:ro
command: ["chromium-browser", "--headless", "--disable-gpu", "--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222", "--disable-extensions", "--disable-dev-shm-usage", "--disable-software-rasterizer", "--no-sandbox"]
command: ["chromium-browser", "--disable-gpu", "--headless", "--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222", "--disable-extensions", "--no-sandbox"]
ports:
- 9222

Expand Down
9 changes: 6 additions & 3 deletions src/Catrobat/Services/TestEnv/SymfonySupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,14 @@ public function insertUserComment(array $config, bool $andFlush = true): UserCom
$user = $this->getUserManager()->find($config['user_id']);

$new_comment = new UserComment();
$new_comment->setUploadDate(new DateTime($config['upload_date'], new DateTimeZone('UTC')));
$new_comment->setUploadDate(isset($config['upload_date']) ?
new DateTime($config['upload_date'], new DateTimeZone('UTC')) :
new DateTime('01.01.2013 12:00', new DateTimeZone('UTC'))
);
$new_comment->setProgram($project);
$new_comment->setUser($user);
$new_comment->setUsername($config['user_name']);
$new_comment->setIsReported($config['reported']);
$new_comment->setUsername($user->getUsername());
$new_comment->setIsReported(isset($config['reported']) ? $config['reported'] : false);
$new_comment->setText($config['text']);

$this->getManager()->persist($new_comment);
Expand Down
5 changes: 3 additions & 2 deletions templates/Default/baseParent.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@
<script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>
<script src="{{ asset('js/base.min.js') }}"></script>

<script> {# seems to be needed for some behat tests #} let configGA = { 'UaId': 'UA-42270417-5' } </script>

{% if app_env == 'prod' %}
<script> let configGA = { 'UaId': 'UA-42270417-5' } </script>
<script async src="{{ asset('js/analytics.min.js') }}"></script>
{% endif %}

{# Main Script #}
<script>
Expand Down
32 changes: 31 additions & 1 deletion tests/behat/context/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,21 @@ public function iUploadAValidCatrobatProject(string $api_version): void
$this->uploadProject($this->FIXTURES_DIR.'test.catrobat', null, $api_version);
}

/**
* @When user :username uploads a valid Catrobat project, API version :api_version
*
* @param string $username The name of the user who initiates the upload
* @param string $api_version The API version to be used
*
* @throws APIVersionNotSupportedException when the specified API version is not supported
*/
public function userUploadsAValidCatrobatProject(string $username, string $api_version): void
{
/** @var User|null $user */
$user = $this->getUserManager()->findUserByUsername($username);
$this->uploadProject($this->FIXTURES_DIR.'test.catrobat', $user, $api_version);
}

/**
* @When /^I upload another program using token "([^"]*)"$/
*
Expand Down Expand Up @@ -2156,11 +2171,25 @@ public function iUploadThisGeneratedProject(string $api_version): void
* @throws APIVersionNotSupportedException when the specified API version is not supported
*/
public function userUploadThisGeneratedProject(string $username, string $api_version): void
{
$this::userUploadThisGeneratedProjectWithID($username, $api_version, '');
}

/**
* @When user :username uploads this generated program, API version :api_version, ID :id
*
* @param string $username The name of the user uploading the project
* @param string $api_version The version of the API to be used
* @param string $id Desired id of the project
*
* @throws APIVersionNotSupportedException when the specified API version is not supported
*/
public function userUploadThisGeneratedProjectWithID(string $username, string $api_version, string $id): void
{
/** @var User|null $user */
$user = $this->getUserManager()->findUserByUsername($username);
Assert::assertNotNull($user);
$this->uploadProject(sys_get_temp_dir().'/program_generated.catrobat', $user, $api_version);
$this->uploadProject(sys_get_temp_dir().'/program_generated.catrobat', $user, $api_version, $id);
}

/**
Expand Down Expand Up @@ -2515,6 +2544,7 @@ public function iHaveOtherwiseValidRegistrationParameters(): void
/**
* @Given /^I have a project with "([^"]*)" set to "([^"]*)"$/
* @Given /^I have a program with "([^"]*)" set to "([^"]*)"$/
* @Given /^there is a project with "([^"]*)" set to "([^"]*)"$/
*
* @param mixed $key
* @param mixed $value
Expand Down
26 changes: 14 additions & 12 deletions tests/behat/context/BrowserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function iShouldHaveDownloadedAFileNamed(string $name): void
$received = false;
$file_path = $this->getSymfonyParameter('catrobat.tests.upld-dwnld-dir').'/'.$name;

$end_time = TimeUtils::getTimestamp() + 5; // Waiting for files to be downloaded times out after 10 seconds
$end_time = TimeUtils::getTimestamp() + 5; // Waiting for files to be downloaded times out after 5 seconds
while (TimeUtils::getTimestamp() < $end_time)
{
if (file_exists($file_path))
Expand All @@ -363,7 +363,7 @@ public function iShouldHaveDownloadedAFileNamed(string $name): void
unlink($file_path);
break;
}
sleep(1);
usleep(125000);
}

Assert::assertEquals(true, $received, "File {$name} hasn't been found at location '{$file_path}'");
Expand Down Expand Up @@ -448,7 +448,7 @@ public function iWaitMilliseconds($milliseconds): void
*/
public function iWaitForThePageToBeLoaded(): void
{
$this->getSession()->wait(15_000, "document.readyState === 'complete'");
$this->getSession()->wait(5_000, "document.readyState === 'complete'");
$this->iWaitForAjaxToFinish();
}

Expand All @@ -459,7 +459,7 @@ public function iWaitForThePageToBeLoaded(): void
*/
public function iWaitForAjaxToFinish(): void
{
$this->getSession()->wait(15_000,
$this->getSession()->wait(5_000,
'(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))'
);
}
Expand All @@ -475,17 +475,18 @@ public function iWaitForTheElementToBeVisible($locator): void
{
/** @var NodeElement $element */
$element = $this->getSession()->getPage()->find('css', $locator);
$timeout_in_seconds = 15;
for ($timer = 0; $timer < $timeout_in_seconds; ++$timer)
$tries = 100;
$delay = 100000; // every 1/10 second
for ($timer = 0; $timer < $tries; ++$timer)
{
if ($element->isVisible())
{
return;
}
sleep(1);
usleep($delay);
}

$message = sprintf("The element '%s' was not visible after a %s seconds timeout", $locator, $timeout_in_seconds);
$message = sprintf("The element '%s' was not visible after a %s micro seconds timeout", $locator, ($delay * $tries));
throw new ResponseTextException($message, $this->getSession());
}

Expand All @@ -501,17 +502,18 @@ public function iWaitForTheElementToContain($locator, $text): void
{
/** @var NodeElement $element */
$element = $this->getSession()->getPage()->find('css', $locator);
$timeout_in_seconds = 15;
for ($timer = 0; $timer < $timeout_in_seconds; ++$timer)
$tries = 100;
$delay = 100000; // every 1/10 second
for ($timer = 0; $timer < $tries; ++$timer)
{
if ($element->getText() === $text)
{
return;
}
sleep(1);
usleep($delay);
}

$message = sprintf("The text '%s' was not found after a %s seconds timeout", $text, $timeout_in_seconds);
$message = sprintf("The text '%s' was not found after a %s seconds timeout", $text, ($delay * $tries));
throw new ResponseTextException($message, $this->getSession());
}

Expand Down
32 changes: 24 additions & 8 deletions tests/behat/context/DataFixturesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,23 @@ public function userIsFollowed($user_id, $follow_ids): void
}
}

/**
* @When /^User "([^"]*)" is followed by user "([^"]*)"$/
*
* @param mixed $user_id
* @param mixed $follow_id
*/
public function userIsFollowedByUser($user_id, $follow_id): void
{
/** @var User|null $user */
$user = $this->getUserManager()->find($user_id);

/** @var User|null $followUser */
$followUser = $this->getUserManager()->find($follow_id);
$user->addFollowing($followUser);
$this->getUserManager()->updateUser($user);
}

// -------------------------------------------------------------------------------------------------------------------
// Projects
// -------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1119,13 +1136,13 @@ public function thereAreCatroNotifications(TableNode $table): void
$to_create = new NewProgramNotification($user, $program);
break;
case 'anniversary':
$to_create = new AnniversaryNotification($user, $notification['title'], $notification['message'], $notification['prize']);
$to_create = new AnniversaryNotification($user, 'title_deprecated', $notification['message'], 'price');
break;
case 'achievement':
$to_create = new AchievementNotification($user, $notification['title'], $notification['message'], $notification['image_path']);
$to_create = new AchievementNotification($user, 'title_deprecated', $notification['message'], 'image_path');
break;
case 'broadcast':
$to_create = new BroadcastNotification($user, $notification['title'], $notification['message']);
$to_create = new BroadcastNotification($user, 'title_deprecated', $notification['message']);
break;
case 'remix':
/** @var Program $parent_program */
Expand Down Expand Up @@ -1160,13 +1177,12 @@ public function thereAreNotificationsFor($arg1, $username): void
{
$em = $this->getManager();

/** @var User|null $user */
$user = $this->getUserManager()->findUserByUsername($username);
Assert::assertNotNull($user, 'user is null');

for ($i = 0; $i < $arg1; ++$i)
{
/** @var User|null $user */
$user = $this->getUserManager()->findUserByUsername($username);

Assert::assertNotNull($user, 'user is null');

$to_create = new CatroNotification($user, 'Random Title', 'Random Text');
$em->persist($to_create);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/features/web/admin/reported_users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ Feature: Admin reported users
| #Reported Comments | #Reported Programs | Username | Email |
| 3 | 2 | Gregor | dev2@pocketcode.org |
And I should not see "Adminius"
And I should not see "Superman"
And I should not see "Superman"
20 changes: 10 additions & 10 deletions tests/behat/features/web/comments/project_comments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Feature: As a visitor I want to write, see and report comments.
| 3 | project 3 | OtherUser |

And there are comments:
| program_id | user_id | upload_date | text | user_name | reported |
| 1 | 1 | 01.01.2013 12:01 | c1 | Catrobat | true |
| 2 | 2 | 01.01.2013 12:01 | c2 | OtherUser | true |
| 2 | 2 | 01.01.2013 12:01 | c3 | OtherUser | true |
| 2 | 2 | 01.01.2013 12:01 | c4 | OtherUser | true |
| 2 | 1 | 01.01.2013 12:01 | c5 | Catrobat | true |
| 2 | 1 | 01.01.2013 12:01 | c6 | Catrobat | true |
| 2 | 1 | 01.01.2013 12:01 | c7 | Catrobat | true |
| 2 | 1 | 01.01.2013 12:01 | c8 | Catrobat | true |
| program_id | user_id | text |
| 1 | 1 | c1 |
| 2 | 2 | c2 |
| 2 | 2 | c3 |
| 2 | 2 | c4 |
| 2 | 1 | c5 |
| 2 | 1 | c6 |
| 2 | 1 | c7 |
| 2 | 1 | c8 |
# 3 has no comments


Expand Down Expand Up @@ -228,4 +228,4 @@ Feature: As a visitor I want to write, see and report comments.
And I wait for AJAX to finish
Then I should see "hello"
When I am on "/app/user_notifications"
Then the element "#catro-notification-1" should not exist
Then the element "#catro-notification-1" should not exist
Loading