-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4504b08
commit 10977a6
Showing
8 changed files
with
294 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Feature: details | ||
|
||
Scenario: app store can be discovered | ||
When "Admin" logs in | ||
And "Admin" navigates to the app store | ||
Then "Admin" should see the app store | ||
When "Admin" clicks on the app "Development boilerplate" | ||
Then "Admin" should see the app details of "Development boilerplate" | ||
And "Admin" downloads app version "0.1.0" | ||
When "Admin" navigates back to the app store overview | ||
Then "Admin" should see the app store | ||
And "Admin" downloads the latest version of the app "Development boilerplate" | ||
And "Admin" logs out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Feature: discovery | ||
|
||
Scenario: app store can be discovered | ||
When "Admin" logs in | ||
And "Admin" navigates to the app store | ||
Then "Admin" should see the app store | ||
And "Admin" should see the following apps | ||
| app | | ||
| Draw.io | | ||
| JSON Viewer | | ||
| Unzip | | ||
When "Admin" enters the search term "draw" | ||
Then "Admin" should see the following apps | ||
| app | | ||
| Draw.io | | ||
When "Admin" clicks on the tag "viewer" of the app "Draw.io" | ||
Then "Admin" should see the following apps | ||
| app | | ||
| JSON Viewer | | ||
| Draw.io | | ||
When "Admin" clicks on the app "JSON Viewer" | ||
Then "Admin" should see the app details of "JSON Viewer" | ||
When "Admin" clicks on the tag "viewer" | ||
Then "Admin" should see the app store | ||
Then "Admin" should see the following apps | ||
| app | | ||
| JSON Viewer | | ||
| Draw.io | | ||
And "Admin" logs out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { DataTable, Then, When } from '@cucumber/cucumber' | ||
import { World } from '../../environment' | ||
import { objects } from '../../../support' | ||
import { expect } from '@playwright/test' | ||
|
||
When( | ||
'{string} navigates to the app store', | ||
async function (this: World, stepUser: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
await pageObject.openAppStore() | ||
} | ||
) | ||
|
||
Then( | ||
'{string} should see the app store', | ||
async function (this: World, stepUser: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
await pageObject.waitForAppStoreIsVisible() | ||
} | ||
) | ||
|
||
Then( | ||
'{string} should see the following apps(s)', | ||
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
const apps = await pageObject.getAppsList() | ||
for (const { app } of stepTable.hashes()) { | ||
expect(apps).toContain(app) | ||
} | ||
} | ||
) | ||
|
||
When( | ||
'{string} enters the search term {string}', | ||
async function (this: World, stepUser: string, searchTerm: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
await pageObject.setSearchTerm(searchTerm) | ||
} | ||
) | ||
|
||
When( | ||
'{string} clicks on the tag {string} of the app {string}', | ||
async function (this: World, stepUser: string, tag: string, app: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
await pageObject.selectAppTag({ tag, app }) | ||
} | ||
) | ||
|
||
When( | ||
'{string} clicks on the tag {string}', | ||
async function (this: World, stepUser: string, tag: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
await pageObject.selectTag(tag) | ||
} | ||
) | ||
|
||
When( | ||
'{string} clicks on the app {string}', | ||
async function (this: World, stepUser: string, app: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
await pageObject.selectApp(app) | ||
} | ||
) | ||
|
||
Then( | ||
'{string} should see the app details of {string}', | ||
async function (this: World, stepUser: string, app: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
await pageObject.waitForAppDetailsIsVisible(app) | ||
} | ||
) | ||
|
||
Then( | ||
'{string} downloads app version {string}', | ||
async function (this: World, stepUser: string, version: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
expect(await pageObject.downloadAppVersion(version)).toContain(version) | ||
} | ||
) | ||
Then( | ||
'{string} downloads the latest version of the app {string}', | ||
async function (this: World, stepUser: string, app: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
expect(await pageObject.downloadApp(app)).toBeDefined() | ||
} | ||
) | ||
|
||
When( | ||
'{string} navigates back to the app store overview', | ||
async function (this: World, stepUser: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const pageObject = new objects.appStore.AppStore({ page }) | ||
await pageObject.navigateToAppStoreOverview() | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Download, Page } from '@playwright/test' | ||
import util from 'util' | ||
|
||
const selectors = { | ||
appLoadingSpinner: '#app-loading-spinner', | ||
appSwitcherButton: '#_appSwitcherButton', | ||
appStoreMenuButton: 'data-test-id=app.app-store.menuItem', | ||
downloadButton: '//a[contains(., "%s")]/ancestor::li//button[.//span[text()="Download"]]', | ||
downloadVersionButton: '//tr[@data-item-id="%s"]//button[.//span[text()="Download"]]', | ||
appStoreHeadline: '.app-list-headline', | ||
appTileTitle: '.app-tile-title', | ||
selectAppTitle: '//a[contains(.,"%s")]', | ||
appDetailsBack: '.app-details-back', | ||
appDetailsTitle: '//h2[contains(@class, "app-details-title")][text()="%s"]', | ||
appsFilter: '#apps-filter', | ||
tag: '//button[contains(@class,"oc-tag")][span[text()="%s"]]', | ||
appTag: '//a[contains(.,"%s")]/following::button[contains(@class,"oc-tag")][span[text()="%s"]]' | ||
} | ||
|
||
export const openAppStore = async (args: { page: Page }): Promise<void> => { | ||
const { page } = args | ||
await page.locator(selectors.appSwitcherButton).click() | ||
await page.locator(selectors.appStoreMenuButton).click() | ||
await page.locator(selectors.appLoadingSpinner).waitFor({ state: 'detached' }) | ||
} | ||
export const navigateToAppStoreOverview = async (args: { page: Page }): Promise<void> => { | ||
const { page } = args | ||
await page.locator(selectors.appDetailsBack).click() | ||
await page.locator(selectors.appDetailsBack).waitFor({ state: 'detached' }) | ||
} | ||
|
||
export const waitForAppStoreIsVisible = (args: { page: Page }): Promise<void> => { | ||
const { page } = args | ||
return page.locator(selectors.appStoreHeadline).waitFor() | ||
} | ||
|
||
export const getAppsList = (args: { page: Page }): Promise<string[]> => { | ||
const { page } = args | ||
return page.locator(selectors.appTileTitle).allTextContents() | ||
} | ||
|
||
export const setSearchTerm = (args: { page: Page; searchTerm: string }): Promise<void> => { | ||
const { page, searchTerm } = args | ||
return page.locator(selectors.appsFilter).fill(searchTerm) | ||
} | ||
|
||
export const selectAppTag = (args: { page: Page; app: string; tag: string }): Promise<void> => { | ||
const { page, app, tag } = args | ||
return page.locator(util.format(selectors.appTag, app, tag)).click() | ||
} | ||
export const selectTag = (args: { page: Page; tag: string }): Promise<void> => { | ||
const { page, tag } = args | ||
return page.locator(util.format(selectors.tag, tag)).click() | ||
} | ||
|
||
export const selectApp = (args: { page: Page; app: string }): Promise<void> => { | ||
const { page, app } = args | ||
return page.locator(util.format(selectors.selectAppTitle, app)).click() | ||
} | ||
|
||
export const waitForAppDetailsIsVisible = (args: { page: Page; app }): Promise<void> => { | ||
const { page, app } = args | ||
return page.locator(util.format(selectors.appDetailsTitle, app)).waitFor() | ||
} | ||
|
||
export const downloadAppVersion = async (args: { | ||
page: Page | ||
version: string | ||
}): Promise<string> => { | ||
const { page, version } = args | ||
const [download] = await Promise.all([ | ||
// Start waiting for the download CONTINUE HERE | ||
page.waitForEvent('download'), | ||
// Perform the action that initiates download | ||
page.locator(util.format(selectors.downloadVersionButton, version)).click() | ||
]) | ||
|
||
return download.suggestedFilename() | ||
} | ||
|
||
export const downloadApp = async (args: { page: Page; app: string }): Promise<Download> => { | ||
const { page, app } = args | ||
const [download] = await Promise.all([ | ||
page.waitForEvent('download'), | ||
page.locator(util.format(selectors.downloadButton, app)).click() | ||
]) | ||
|
||
return download | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Download, Page } from '@playwright/test' | ||
import * as po from './actions' | ||
|
||
export class AppStore { | ||
#page: Page | ||
|
||
constructor({ page }: { page: Page }) { | ||
this.#page = page | ||
} | ||
|
||
async openAppStore(): Promise<void> { | ||
await po.openAppStore({ page: this.#page }) | ||
} | ||
|
||
async waitForAppStoreIsVisible(): Promise<void> { | ||
return po.waitForAppStoreIsVisible({ page: this.#page }) | ||
} | ||
|
||
async getAppsList(): Promise<string[]> { | ||
return po.getAppsList({ page: this.#page }) | ||
} | ||
|
||
async setSearchTerm(searchTerm: string): Promise<void> { | ||
return po.setSearchTerm({ page: this.#page, searchTerm }) | ||
} | ||
|
||
async selectAppTag({ app, tag }: { app: string; tag: string }): Promise<void> { | ||
return po.selectAppTag({ page: this.#page, app, tag }) | ||
} | ||
|
||
async selectTag(tag): Promise<void> { | ||
return po.selectTag({ page: this.#page, tag }) | ||
} | ||
|
||
async selectApp(app: string): Promise<void> { | ||
return po.selectApp({ page: this.#page, app }) | ||
} | ||
|
||
async waitForAppDetailsIsVisible(app: string): Promise<void> { | ||
return po.waitForAppDetailsIsVisible({ page: this.#page, app }) | ||
} | ||
|
||
async downloadApp(app: string): Promise<Download> { | ||
return po.downloadApp({ page: this.#page, app }) | ||
} | ||
|
||
async downloadAppVersion(version: string): Promise<string> { | ||
return po.downloadAppVersion({ page: this.#page, version }) | ||
} | ||
|
||
async navigateToAppStoreOverview(): Promise<void> { | ||
await po.navigateToAppStoreOverview({ page: this.#page }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters