@elastic/synthetics 1.0.0-beta.26 → 1.0.0-beta.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +24 -14
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +0 -1
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/core/gatherer.js +2 -2
  7. package/dist/core/gatherer.js.map +1 -1
  8. package/dist/core/runner.d.ts.map +1 -1
  9. package/dist/core/runner.js +5 -1
  10. package/dist/core/runner.js.map +1 -1
  11. package/dist/dsl/locations.d.ts +37 -0
  12. package/dist/dsl/locations.d.ts.map +1 -0
  13. package/dist/dsl/locations.js +41 -0
  14. package/dist/dsl/locations.js.map +1 -0
  15. package/dist/dsl/monitor.d.ts +3 -2
  16. package/dist/dsl/monitor.d.ts.map +1 -1
  17. package/dist/dsl/monitor.js +2 -1
  18. package/dist/dsl/monitor.js.map +1 -1
  19. package/dist/generator/index.d.ts +9 -1
  20. package/dist/generator/index.d.ts.map +1 -1
  21. package/dist/generator/index.js +57 -11
  22. package/dist/generator/index.js.map +1 -1
  23. package/dist/generator/utils.d.ts +1 -0
  24. package/dist/generator/utils.d.ts.map +1 -1
  25. package/dist/generator/utils.js +14 -1
  26. package/dist/generator/utils.js.map +1 -1
  27. package/dist/options.d.ts +0 -5
  28. package/dist/options.d.ts.map +1 -1
  29. package/dist/options.js +20 -28
  30. package/dist/options.js.map +1 -1
  31. package/dist/push/bundler.d.ts.map +1 -1
  32. package/dist/push/bundler.js +4 -9
  33. package/dist/push/bundler.js.map +1 -1
  34. package/dist/push/index.d.ts.map +1 -1
  35. package/dist/push/index.js +1 -4
  36. package/dist/push/index.js.map +1 -1
  37. package/dist/push/monitor.d.ts.map +1 -1
  38. package/dist/push/monitor.js +2 -7
  39. package/dist/push/monitor.js.map +1 -1
  40. package/dist/push/plugin.d.ts.map +1 -1
  41. package/dist/push/plugin.js +1 -0
  42. package/dist/push/plugin.js.map +1 -1
  43. package/dist/push/request.d.ts +0 -1
  44. package/dist/push/request.d.ts.map +1 -1
  45. package/dist/push/request.js +6 -17
  46. package/dist/push/request.js.map +1 -1
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +6 -4
  49. package/src/cli.ts +37 -17
  50. package/src/common_types.ts +0 -1
  51. package/src/core/gatherer.ts +2 -2
  52. package/src/core/runner.ts +8 -1
  53. package/src/dsl/locations.ts +38 -0
  54. package/src/dsl/monitor.ts +6 -2
  55. package/src/generator/index.ts +70 -17
  56. package/src/generator/utils.ts +13 -0
  57. package/src/options.ts +23 -29
  58. package/src/push/bundler.ts +4 -8
  59. package/src/push/index.ts +2 -6
  60. package/src/push/monitor.ts +2 -11
  61. package/src/push/plugin.ts +1 -0
  62. package/src/push/request.ts +6 -18
  63. package/templates/.github/workflows/run-synthetics.yml +26 -0
  64. package/templates/README.md +21 -0
  65. package/templates/journeys/advanced-example-helpers.ts +54 -0
  66. package/templates/journeys/advanced-example.journey.ts +43 -0
  67. package/templates/synthetics.config.ts +7 -0
@@ -0,0 +1,54 @@
1
+ import { step, Page, expect } from '@elastic/synthetics';
2
+
3
+ // This file contains helper files for advanced-example.journey.ts
4
+ // The functions here let you write more concise tests and re-use functionality
5
+ // across tests.
6
+
7
+ export const loadAppStep = (page: Page, url: string) => {
8
+ step('launch app', async () => {
9
+ await page.goto(url);
10
+ });
11
+ };
12
+
13
+ export const addTaskStep = (page: Page, task: string) => {
14
+ step(`add task ${task}`, async () => {
15
+ const input = await page.$('input.new-todo');
16
+ await input.type(task);
17
+ await input.press('Enter');
18
+ });
19
+ };
20
+
21
+ const todosSelector = 'ul.todo-list li.todo';
22
+
23
+ export const findTask = async (page: Page, task: string) => {
24
+ return await page.waitForSelector(`${todosSelector} >> text="${task}"`);
25
+ };
26
+
27
+ export const assertTaskListSizeStep = async (page: Page, size: number) => {
28
+ step(`check that task list has exactly ${size} elements`, async () => {
29
+ expect((await page.$$(todosSelector)).length).toBe(size);
30
+ });
31
+ };
32
+
33
+ export const checkForTaskStep = async (page: Page, task: string) => {
34
+ step(`check for task '${task}' in list`, async () => {
35
+ return findTask(page, task);
36
+ });
37
+ };
38
+
39
+ export const destroyTaskStep = async (page: Page, task: string) => {
40
+ step(`destroy task '${task}'`, async () => {
41
+ const label = await findTask(page, task);
42
+ // xpath indexes arrays starting at 1!!! Easy to forget!
43
+ const li = await label.$('xpath=ancestor::li[1]');
44
+ const destroyButton = await li.$('button');
45
+
46
+ // The destroy button is not visible until hovered. Setup a click test which
47
+ // will wait up to 30s for the button to be visible.
48
+ const clickFuture = destroyButton.click();
49
+ // now hover, making the destroy button clickable
50
+ li.hover();
51
+ // now we are done
52
+ await clickFuture;
53
+ });
54
+ };
@@ -0,0 +1,43 @@
1
+ import { journey } from '@elastic/synthetics';
2
+ import {
3
+ loadAppStep,
4
+ addTaskStep,
5
+ assertTaskListSizeStep,
6
+ checkForTaskStep,
7
+ destroyTaskStep,
8
+ } from './advanced-example-helpers';
9
+
10
+ // This file shows the use of re-usable functions, imported from
11
+ // `advanced-example-helpers.ts` to make writing tests that perform
12
+ // different combinations of similar functions simpler and with less
13
+ // duplication.
14
+
15
+ journey('addition and completion of single task', ({ page, params }) => {
16
+ const testText = "Don't put salt in your eyes";
17
+
18
+ loadAppStep(page, params.url);
19
+ addTaskStep(page, testText);
20
+ assertTaskListSizeStep(page, 1);
21
+ checkForTaskStep(page, testText);
22
+ destroyTaskStep(page, testText);
23
+ assertTaskListSizeStep(page, 0);
24
+ });
25
+
26
+ journey('adding and removing multiple tasks', ({ page, params }) => {
27
+ const testTasks = ['Task 1', 'Task 2', 'Task 3'];
28
+
29
+ loadAppStep(page, params.url);
30
+ testTasks.forEach(t => {
31
+ addTaskStep(page, t);
32
+ });
33
+
34
+ assertTaskListSizeStep(page, 3);
35
+
36
+ // remove the middle task and check that it worked
37
+ destroyTaskStep(page, testTasks[1]);
38
+ assertTaskListSizeStep(page, 2);
39
+
40
+ // add a new task and check it exists
41
+ addTaskStep(page, 'Task 4');
42
+ assertTaskListSizeStep(page, 3);
43
+ });
@@ -8,6 +8,13 @@ export default env => {
8
8
  playwrightOptions: {
9
9
  ignoreHTTPSErrors: false,
10
10
  },
11
+ /**
12
+ * Configure global monitor settings
13
+ */
14
+ monitor: {
15
+ schedule: '{{schedule}}',
16
+ locations: ["'{{locations}}'"],
17
+ },
11
18
  };
12
19
  if (env !== 'development') {
13
20
  /**