go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/analysis/frontend/ui/cypress/integration/test_data.ts (about)

     1  // Copyright 2022 The LUCI Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  export function setupTestRule() {
    16    cy.request({
    17      url: '/api/authState',
    18      headers: {
    19        'Sec-Fetch-Site': 'same-origin',
    20      },
    21    }).then((response) => {
    22      assert.strictEqual(response.status, 200);
    23      const body = response.body;
    24      const accessToken = body.accessToken;
    25      assert.isString(accessToken);
    26      assert.notEqual(accessToken, '');
    27  
    28      // Set initial rule state.
    29      cy.request({
    30        method: 'POST',
    31        url: '/prpc/luci.analysis.v1.Rules/Update',
    32        body: {
    33          rule: {
    34            name: 'projects/chromium/rules/ea5305bc5069b449ee43ee64d26d667f',
    35            ruleDefinition: 'test = "cypress test 1"',
    36            bug: {
    37              system: 'monorail',
    38              id: 'chromium/920867',
    39            },
    40            isActive: true,
    41            isManagingBug: true,
    42          },
    43          updateMask: 'ruleDefinition,bug,isActive,isManagingBug',
    44        },
    45        headers: {
    46          Authorization: 'Bearer ' + accessToken,
    47        },
    48      });
    49    });
    50  }