Skip to content

Add integration test#178

Open
julien-nc wants to merge 9 commits intomainfrom
enh/noid/oauth-integration-test
Open

Add integration test#178
julien-nc wants to merge 9 commits intomainfrom
enh/noid/oauth-integration-test

Conversation

@julien-nc
Copy link
Member

@julien-nc julien-nc commented Mar 14, 2026

  • Use phpunit 11 to get the external dependency feature (used in integration tests)
  • Bump min NC version to 33 and max to 34 because phpunit 11 only supports php >= 8.2 and NC 33 is the first to drop support for php 8.1.
  • Update composer dependencies
  • Add oauth integration test that performs a full oauth flow with credentials stored as repo secrets (with totp support because we can't perform device validation per email 😁)
  • Add other integration tests that depend on the oauth test so we know we have a token stored in the DB
    • Get notifications for the dashboard widget
    • Search for the search providers
    • Issue/pr reference provider
    • Code reference provider
  • Fix issue in the issue/pr reference provider: When resolving links to a comment that does not exist (like https://github.com/nextcloud/server/issues/1#issuecomment-1), the reference object contained an invalid value for the comment which resulted in a crash of the widget. That's solved by acting like it's just an issue/pr link when the comment was not found.

@julien-nc julien-nc force-pushed the enh/noid/oauth-integration-test branch 12 times, most recently from b63d540 to a9c420a Compare March 14, 2026 16:19
@julien-nc julien-nc changed the title Add oauth integration test Add integration test Mar 14, 2026
@julien-nc julien-nc force-pushed the enh/noid/oauth-integration-test branch 5 times, most recently from ca3b0ce to 886e029 Compare March 15, 2026 00:25
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
…he oauth one

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
…rom nextcloud/.github

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@julien-nc julien-nc force-pushed the enh/noid/oauth-integration-test branch from 886e029 to 9f9b46e Compare March 15, 2026 00:28
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@julien-nc julien-nc force-pushed the enh/noid/oauth-integration-test branch from 9f9b46e to 5631c35 Compare March 15, 2026 00:36
@julien-nc julien-nc marked this pull request as ready for review March 15, 2026 00:40
if: steps.check_integration.outcome == 'success'
working-directory: apps/${{ env.APP_NAME }}
run: composer run test:integration
#- name: Check PHPUnit integration script is defined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we are commenting duplicated tests instead of removing?

class GitHubCodeReferenceIntegrationTest extends TestCase {
private GithubCodeReferenceProvider $referenceProvider;
private SecretService $secretService;
private IConfig $config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it used somewhere?


namespace OCA\Github\Tests\Integration;

require_once __DIR__ . '/GitHubHtml.php';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the other test files should have this or as alternative could we add these classes to the autoload-dev section in composer.json?

</coverage>
</source>
<testsuite name="GitHub integration App Tests">
<directory suffix="Test.php">.</directory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit test config scans . recursively, picking up integration tests too.
Maybe we should consider excluding the integration/ directory with something like <exclude>./integration</exclude>

This way test:unit only runs unit tests and test:integration only runs integration tests.


- name: Skipped
# Fail the action when neither unit nor integration tests ran
if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steps.check_integration.outcome - was commented out

$this->assertMatchesRegularExpression('/^[⑁⦿] .+#\d+$/u', $expectedSubline, 'Subline should match expected format');
}
}
}
Copy link
Contributor

@oleksandr-nc oleksandr-nc Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe adding tearDown() somewhere in this file will be a good idea to clean OAuth flow data to not affect any other tests that can be executed later and to revoke token from GitHub

public static function findAuthorizeForm(DOMXPath $selector): ?DOMElement {
return self::findForm($selector, [
'//form[contains(@class, "js-oauth-authorize-form")]',
'//form[contains(@class, "js-oath-authorize-form")]',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment here what is "js-oath" ? from quick search in the internet, I was not able to find such form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants