Skip to content

Commit

Permalink
Cleanup report experimental flag uses in tests. (dart-lang#8026)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos committed Sep 6, 2024
1 parent adc622c commit f8d85ef
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 62 deletions.
1 change: 0 additions & 1 deletion app/test/admin/moderate_package_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ void main() {
group('Moderate package', () {
Future<ModerationCase> _report(String package) async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await client.postReport(ReportForm(
email: 'user@pub.dev',
Expand Down
1 change: 0 additions & 1 deletion app/test/admin/moderate_package_version_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void main() {
group('Moderate package version', () {
Future<ModerationCase> _report(String package, String version) async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await client.postReport(ReportForm(
email: 'user@pub.dev',
Expand Down
1 change: 0 additions & 1 deletion app/test/admin/moderate_publisher_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ void main() {
group('Moderate Publisher', () {
Future<ModerationCase> _report(String publisherId) async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await client.postReport(ReportForm(
email: 'user@pub.dev',
Expand Down
1 change: 0 additions & 1 deletion app/test/admin/moderate_user_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ void main() {
group('Moderate User', () {
Future<ModerationCase> _report(String package) async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await client.postReport(account_api.ReportForm(
email: 'user@pub.dev',
Expand Down
1 change: 0 additions & 1 deletion app/test/admin/moderation_case_resolve_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void main() {
required bool? apply,
}) async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await client.postReport(ReportForm(
email: 'user@pub.dev',
Expand Down
38 changes: 5 additions & 33 deletions app/test/frontend/handlers/report_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:clock/clock.dart';
import 'package:pub_dev/admin/models.dart';
import 'package:pub_dev/fake/backend/fake_auth_provider.dart';
import 'package:pub_dev/fake/backend/fake_email_sender.dart';
import 'package:pub_dev/frontend/handlers/experimental.dart';
import 'package:pub_dev/frontend/request_context.dart';
import 'package:pub_dev/shared/datastore.dart';
import 'package:test/test.dart';
Expand All @@ -20,10 +19,7 @@ void main() {
group('Report handlers test', () {
testWithProfile('page does not require authentication', fn: () async {
await expectHtmlResponse(
await issueGet(
'/report?subject=package:oxygen',
headers: {'cookie': '$experimentalCookieName=report'},
),
await issueGet('/report?subject=package:oxygen'),
present: [
'Please describe the issue you want to report:',
'Contact information',
Expand All @@ -36,7 +32,7 @@ void main() {
await expectHtmlResponse(
await issueGet(
'/report?subject=package:oxygen',
headers: {'cookie': '$experimentalCookieName=report; $cookies'},
headers: {'cookie': cookies},
),
present: ['Please describe the issue you want to report:'],
absent: ['Contact information'],
Expand All @@ -45,10 +41,7 @@ void main() {

testWithProfile('page with missing subject', fn: () async {
await expectHtmlResponse(
await issueGet(
'/report',
headers: {'cookie': '$experimentalCookieName=report'},
),
await issueGet('/report'),
present: [
'&quot;subject&quot; cannot be `null`',
],
Expand All @@ -61,10 +54,7 @@ void main() {

testWithProfile('page with bad subject', fn: () async {
await expectHtmlResponse(
await issueGet(
'/report?subject=x',
headers: {'cookie': '$experimentalCookieName=report'},
),
await issueGet('/report?subject=x'),
present: [
'Invalid &quot;subject&quot; parameter.',
],
Expand All @@ -77,10 +67,7 @@ void main() {

testWithProfile('page with package version subject', fn: () async {
await expectHtmlResponse(
await issueGet(
'/report?subject=package-version:oxygen/1.0.0',
headers: {'cookie': '$experimentalCookieName=report'},
),
await issueGet('/report?subject=package-version:oxygen/1.0.0'),
present: [
'Please describe the issue you want to report:',
'oxygen/1.0.0',
Expand All @@ -92,7 +79,6 @@ void main() {
group('Report API test', () {
testWithProfile('unauthenticated email missing', fn: () async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -112,7 +98,6 @@ void main() {
final sessionId = requestContext.sessionData?.sessionId;
final csrfToken = requestContext.csrfToken;
await withHttpPubApiClient(
experimental: {'report'},
sessionId: sessionId,
csrfToken: csrfToken,
fn: (client) async {
Expand All @@ -133,7 +118,6 @@ void main() {

testWithProfile('subject missing', fn: () async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -151,7 +135,6 @@ void main() {

testWithProfile('subject is invalid', fn: () async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -170,7 +153,6 @@ void main() {

testWithProfile('package missing', fn: () async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -189,7 +171,6 @@ void main() {

testWithProfile('version missing', fn: () async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -208,7 +189,6 @@ void main() {

testWithProfile('publisher missing', fn: () async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -230,7 +210,6 @@ void main() {
final sessionId = requestContext.sessionData?.sessionId;
final csrfToken = requestContext.csrfToken;
await withHttpPubApiClient(
experimental: {'report'},
sessionId: sessionId,
csrfToken: csrfToken,
fn: (client) async {
Expand All @@ -251,7 +230,6 @@ void main() {

testWithProfile('unauthenticated report success', fn: () async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
final msg = await client.postReport(ReportForm(
email: 'user2@pub.dev',
Expand Down Expand Up @@ -279,7 +257,6 @@ void main() {
final sessionId = requestContext.sessionData?.sessionId;
final csrfToken = requestContext.csrfToken;
await withHttpPubApiClient(
experimental: {'report'},
sessionId: sessionId,
csrfToken: csrfToken,
fn: (client) async {
Expand Down Expand Up @@ -331,7 +308,6 @@ void main() {

testWithProfile('failure: case does not exists', fn: () async {
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -351,7 +327,6 @@ void main() {
testWithProfile('failure: case is not closed', fn: () async {
await _prepareApplied(status: ModerationStatus.pending);
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -371,7 +346,6 @@ void main() {
testWithProfile('failure: subject is not on the case', fn: () async {
await _prepareApplied();
await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
await expectApiException(
client.postReport(ReportForm(
Expand All @@ -395,7 +369,6 @@ void main() {
);

await withHttpPubApiClient(
experimental: {'report'},
fn: (client) async {
final msg = await client.postReport(ReportForm(
email: 'user2@pub.dev',
Expand Down Expand Up @@ -432,7 +405,6 @@ void main() {

await withFakeAuthHttpPubApiClient(
email: 'admin@pub.dev',
experimental: {'report'},
fn: (client) async {
final msg = await client.postReport(ReportForm(
subject: 'package-version:oxygen/1.2.0',
Expand Down
15 changes: 0 additions & 15 deletions app/test/frontend/templates_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'package:pub_dev/admin/models.dart';
import 'package:pub_dev/audit/backend.dart';
import 'package:pub_dev/audit/models.dart';
import 'package:pub_dev/fake/backend/fake_auth_provider.dart';
import 'package:pub_dev/frontend/handlers/experimental.dart';
import 'package:pub_dev/frontend/handlers/package.dart'
show loadPackagePageData;
import 'package:pub_dev/frontend/request_context.dart';
Expand Down Expand Up @@ -141,8 +140,6 @@ void main() {
'package show page',
processJobsWithFakeRunners: true,
fn: () async {
registerRequestContext(
RequestContext(experimentalFlags: ExperimentalFlags({'report'})));
final data = await withFakeAuthRequestContext(
adminAtPubDevEmail,
() => loadPackagePageDataByName('oxygen', '1.2.0', AssetKind.readme),
Expand Down Expand Up @@ -173,8 +170,6 @@ void main() {
'package example page',
processJobsWithFakeRunners: true,
fn: () async {
registerRequestContext(
RequestContext(experimentalFlags: ExperimentalFlags({'report'})));
final data = await loadPackagePageDataByName(
'oxygen', '1.2.0', AssetKind.example);
final html = renderPkgExamplePage(data);
Expand Down Expand Up @@ -212,8 +207,6 @@ void main() {
'package show page - with version',
processJobsWithFakeRunners: true,
fn: () async {
registerRequestContext(
RequestContext(experimentalFlags: ExperimentalFlags({'report'})));
final data = await loadPackagePageDataByName(
'oxygen', '1.2.0', AssetKind.readme);
final html = renderPkgShowPage(data);
Expand Down Expand Up @@ -484,8 +477,6 @@ void main() {
'package versions page',
processJobsWithFakeRunners: true,
fn: () async {
registerRequestContext(
RequestContext(experimentalFlags: ExperimentalFlags({'report'})));
final data = await loadPackagePageDataByName('oxygen', '1.2.0', null);
final rs = await issueGet('/packages/oxygen/versions');
final html = await rs.readAsString();
Expand Down Expand Up @@ -523,8 +514,6 @@ void main() {
'publisher packages page',
processJobsWithFakeRunners: true,
fn: () async {
registerRequestContext(
RequestContext(experimentalFlags: ExperimentalFlags({'report'})));
final searchForm = SearchForm();
final publisher = (await publisherBackend.getPublisher('example.com'))!;
final neon = (await scoreCardBackend.getPackageView('neon'))!;
Expand Down Expand Up @@ -811,8 +800,6 @@ void main() {
});

testWithProfile('report page', fn: () async {
registerRequestContext(
RequestContext(experimentalFlags: ExperimentalFlags({'report'})));
final html = renderReportPage(
sessionData: null,
subject: ModerationSubject.package('oxygen'),
Expand All @@ -824,8 +811,6 @@ void main() {
});

testWithProfile('report page - appeal', fn: () async {
registerRequestContext(
RequestContext(experimentalFlags: ExperimentalFlags({'report'})));
final html = renderReportPage(
sessionData: null,
subject: ModerationSubject.package('oxygen'),
Expand Down
2 changes: 1 addition & 1 deletion app/test/task/end2end_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void main() {
final _headers = {
'Cookie': Cookie(
experimentalCookieName,
ExperimentalFlags({'report'}).encodedAsCookie(),
ExperimentalFlags({'experiment-name'}).encodedAsCookie(),
).toString(),
};

Expand Down
8 changes: 0 additions & 8 deletions pkg/pub_integration/test/report_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ void main() {
// visit report page and file a report
await anonReporter.withBrowserPage(
(page) async {
// enable experimental flag
await page.gotoOrigin('/experimental?report=1');
await Future.delayed(Duration(seconds: 1));

await page.gotoOrigin('/report?subject=package:oxygen');
await page.waitAndClick('.report-page-direct-report');
await page.waitFocusAndType('#report-email', 'reporter@pub.dev');
Expand Down Expand Up @@ -188,10 +184,6 @@ void main() {

// admin appeals
await pkgAdminUser.withBrowserPage((page) async {
// enable experimental flag
await page.gotoOrigin('/experimental?report=1');
await Future.delayed(Duration(seconds: 1));

await page
.gotoOrigin(appealPageUrl.replaceAll('https://pub.dev/', '/'));

Expand Down

0 comments on commit f8d85ef

Please sign in to comment.