Skip to content

Commit ad651b1

Browse files
authored
Move the e2e source-link test to a unit test (#3254)
1 parent d14c680 commit ad651b1

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

test/end2end/dartdoc_test.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,6 @@ void main() {
148148
hasLength(kTestPackagePublicLibraries + 2));
149149
expect(packageGraph.localPackages.length, equals(1));
150150
});
151-
152-
test('source code links are visible', () async {
153-
// Picked this object as this library explicitly should never contain
154-
// a library directive, so we can predict what line number it will be.
155-
var anonymousOutput = _resourceProvider.getFile(_pathContext.join(
156-
tempDir.path,
157-
'anonymous_library',
158-
'anonymous_library-library.html'));
159-
expect(anonymousOutput.exists, isTrue);
160-
expect(
161-
anonymousOutput.readAsStringSync(),
162-
contains(r'<a title="View source code" class="source-link" '
163-
'href="https://github.com/dart-lang/dartdoc/blob/master/testing/test_package/lib/anonymous_library.dart#L1">'
164-
'<span class="material-symbols-outlined">description</span></a>'));
165-
});
166151
});
167152

168153
test('generate docs for ${p.basename(_testPackageBadDir.path)} fails',

test/templates/extension_test.dart

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ extension E<T> on C<T> {
9797
}
9898
'''),
9999
],
100+
dartdocOptions: '''
101+
dartdoc:
102+
linkToSource:
103+
root: '.'
104+
uriTemplate: 'https://github.com/dart-lang/TEST_PKG/%f%#L%l%'
105+
''',
100106
resourceProvider: resourceProvider,
101107
);
102108
await writeDartdocResources(resourceProvider);
@@ -200,14 +206,15 @@ extension E<T> on C<T> {
200206

201207
test('enum sidebar contains static properties', () async {
202208
expect(
203-
eLines,
204-
containsAllInOrder([
205-
matches('<div id="dartdoc-sidebar-right"'),
206-
matches(
207-
'<a href="../lib/E.html#static-properties">Static properties</a>'),
208-
matches('<a href="../lib/E/gs1.html">gs1</a>'),
209-
matches('<a href="../lib/E/sf1.html">sf1</a>'),
210-
]));
209+
eLines,
210+
containsAllInOrder([
211+
matches('<div id="dartdoc-sidebar-right"'),
212+
matches(
213+
'<a href="../lib/E.html#static-properties">Static properties</a>'),
214+
matches('<a href="../lib/E/gs1.html">gs1</a>'),
215+
matches('<a href="../lib/E/sf1.html">sf1</a>'),
216+
]),
217+
);
211218
});
212219

213220
test('enum sidebar contains static methods', () async {
@@ -220,5 +227,16 @@ extension E<T> on C<T> {
220227
matches('<a href="../lib/E/s1.html">s1</a>'),
221228
]));
222229
});
230+
231+
test('extension page contains source link', () async {
232+
expect(
233+
eLines,
234+
containsAllInOrder([
235+
matches('<a title="View source code" class="source-link" '
236+
'href="https://github.com/dart-lang/TEST_PKG/lib/lib.dart#L5">'
237+
'<span class="material-symbols-outlined">description</span></a>'),
238+
]),
239+
);
240+
});
223241
});
224242
}

0 commit comments

Comments
 (0)