Skip to content

Commit

Permalink
[Scout] add maps test
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneseymour committed Dec 17, 2024
1 parent 3e06d6a commit c75ecd1
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
20 changes: 20 additions & 0 deletions x-pack/plugins/maps/ui_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## How to run tests
First start the servers with

```bash
// ESS
node scripts/scout_start_servers.js --stateful
// Serverless
node scripts/scout_start_servers.js --serverless=es
```

Then you can run the tests multiple times in another terminal with:

```bash
// ESS
npx playwright test --config x-pack/plugins/maps/ui_tests/playwright.config.ts --grep @ess
// Serverless
npx playwright test --config x-pack/plugins/maps/ui_tests/playwright.config.ts --grep @svlSearch // @svlOblt, @svlSecurity
```

Test results are available in `x-pack/plugins/maps/ui_tests/output`
44 changes: 44 additions & 0 deletions x-pack/plugins/maps/ui_tests/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import {
test as base,
PageObjects,
createLazyPageObject,
ScoutTestFixtures,
ScoutWorkerFixtures,
} from '@kbn/scout';
import { GisPage } from './page_objects';

export interface ExtendedScoutTestFixtures extends ScoutTestFixtures {
pageObjects: PageObjects & {
gis: GisPage;
};
}

export const test = base.extend<ExtendedScoutTestFixtures, ScoutWorkerFixtures>({
pageObjects: async (
{
pageObjects,
page,
}: {
pageObjects: ExtendedScoutTestFixtures['pageObjects'];
page: ExtendedScoutTestFixtures['page'];
},
use: (pageObjects: ExtendedScoutTestFixtures['pageObjects']) => Promise<void>
) => {
const extendedPageObjects = {
...pageObjects,
gis: createLazyPageObject(GisPage, page),
};

await use(extendedPageObjects);
},
});

// export * as testData from './constants';
// export * as assertionMessages from './assertion_messages';
28 changes: 28 additions & 0 deletions x-pack/plugins/maps/ui_tests/fixtures/page_objects/gis_page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { ScoutPage} from '@kbn/scout';

export class GisPage {
constructor(private readonly page: ScoutPage) {}

async fullScreenModeMenuItemExists() {
await this.page.testSubj.locator('mapsFullScreenMode').waitFor({ state: 'visible' });
}

async clickFullScreenMode() {
await this.page.testSubj.click('mapsFullScreenMode')
}

async clickExitFullScreenTextButton() {
await this.page.testSubj.click('exitFullScreenModeText');
}

async goto() {
await this.page.gotoApp('maps');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { GisPage } from './gis_page';
13 changes: 13 additions & 0 deletions x-pack/plugins/maps/ui_tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { createPlaywrightConfig } from '@kbn/scout';

// eslint-disable-next-line import/no-default-export
export default createPlaywrightConfig({
testDir: './tests',
});
33 changes: 33 additions & 0 deletions x-pack/plugins/maps/ui_tests/tests/full_screen_mode.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { expect, tags } from '@kbn/scout';
import { test } from '../fixtures';

test.describe('maps full screen mode', { tag: tags.ESS_ONLY } , () => {
test.beforeEach(async ({ browserAuth, pageObjects }) => {
await browserAuth.loginAsViewer();
await pageObjects.gis.goto();
});
test('full screen button should exist', async ({ pageObjects}) => {
await pageObjects.gis.fullScreenModeMenuItemExists();
});
test('full screen mode hides the kbn app wrapper', async ({ page, pageObjects }) => {
expect(await page.testSubj.locator('kbnAppWrapper visibleChrome').waitFor({state: 'visible'}));
await pageObjects.gis.clickFullScreenMode();
expect(await page.testSubj.locator('kbnAppWrapper hiddenChrome').waitFor({state: 'visible'}));
await pageObjects.gis.clickExitFullScreenTextButton();
expect(await page.testSubj.locator('kbnAppWrapper visibleChrome').waitFor({state: 'visible'}));
});
test.skip('layer control is visible', async ({ page }) => {
expect(await page.testSubj.locator('addLayerButton').waitFor({state: 'visible'}));
});
// test('displays exit full screen logo button', async ({ page }) => {
// });
// test('exits when the text button is clicked on', async ({ page }) => {
// });
});

0 comments on commit c75ecd1

Please sign in to comment.