I am trying to run an elastic synthetics test using the inline script editor however when I run the following step and run a manual test to verify the test, the run seems to get stuck in pending then returns "Failed to get any results back for manual test run"
step("Internal user login", async () => {
let token;
page.on('response', async (response) => {
if (response.request().url().endsWith('/token') && response.request().method() === 'POST') {
const responseBody = await response.json();
token = responseBody.access_token;
}
});
const url = 'NotTheRealUiUrl';
await page.goto(url);
await page.getByText('Reject All Cookies').click();
await page.locator('[aria-label="Sign in"]').getByRole('button').click();
await page.locator('#signInEmail').fill('NotTheRealUser');
await page.locator('#continue').click();
await page.getByPlaceholder('password').fill('NotATheRealPassword');
await page.locator('[type="submit"]').click();
await page.waitForURL(url);
await page.locator('[heading="Surveys"]').locator('h2').click();
while(!token) {
await new Promise(resolve => setTimeout(resolve, 500));
}
const options = {
headers: {
Authorization: `Bearer ${token}`
}
};
const response = await request.get(
'NotTheRealAPiUrl', options);
});
I've placed this all in on step for simplicity. Interestingly when I remove the options object and the options variable from the script (i.e. make the get request without options) the test runs and does not get stuck in pending. Any suggestions?