Skip to content

Move the e2e source-link test to a unit test #3254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2022
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
15 changes: 0 additions & 15 deletions test/end2end/dartdoc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,6 @@ void main() {
hasLength(kTestPackagePublicLibraries + 2));
expect(packageGraph.localPackages.length, equals(1));
});

test('source code links are visible', () async {
// Picked this object as this library explicitly should never contain
// a library directive, so we can predict what line number it will be.
var anonymousOutput = _resourceProvider.getFile(_pathContext.join(
tempDir.path,
'anonymous_library',
'anonymous_library-library.html'));
expect(anonymousOutput.exists, isTrue);
expect(
anonymousOutput.readAsStringSync(),
contains(r'<a title="View source code" class="source-link" '
'href="https://github.com/dart-lang/dartdoc/blob/master/testing/test_package/lib/anonymous_library.dart#L1">'
'<span class="material-symbols-outlined">description</span></a>'));
});
});

test('generate docs for ${p.basename(_testPackageBadDir.path)} fails',
Expand Down
34 changes: 26 additions & 8 deletions test/templates/extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ extension E<T> on C<T> {
}
'''),
],
dartdocOptions: '''
dartdoc:
linkToSource:
root: '.'
uriTemplate: 'https://github.com/dart-lang/TEST_PKG/%f%#L%l%'
''',
resourceProvider: resourceProvider,
);
await writeDartdocResources(resourceProvider);
Expand Down Expand Up @@ -200,14 +206,15 @@ extension E<T> on C<T> {

test('enum sidebar contains static properties', () async {
expect(
eLines,
containsAllInOrder([
matches('<div id="dartdoc-sidebar-right"'),
matches(
'<a href="../lib/E.html#static-properties">Static properties</a>'),
matches('<a href="../lib/E/gs1.html">gs1</a>'),
matches('<a href="../lib/E/sf1.html">sf1</a>'),
]));
eLines,
containsAllInOrder([
matches('<div id="dartdoc-sidebar-right"'),
matches(
'<a href="../lib/E.html#static-properties">Static properties</a>'),
matches('<a href="../lib/E/gs1.html">gs1</a>'),
matches('<a href="../lib/E/sf1.html">sf1</a>'),
]),
);
});

test('enum sidebar contains static methods', () async {
Expand All @@ -220,5 +227,16 @@ extension E<T> on C<T> {
matches('<a href="../lib/E/s1.html">s1</a>'),
]));
});

test('extension page contains source link', () async {
expect(
eLines,
containsAllInOrder([
matches('<a title="View source code" class="source-link" '
'href="https://github.com/dart-lang/TEST_PKG/lib/lib.dart#L5">'
'<span class="material-symbols-outlined">description</span></a>'),
]),
);
});
});
}