-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add requirement(s) in the form of executable BDD scenarios (#557)
* test: write e2e testcases as bdd scenarios * test: enable running tests from the test explorer again * chore: enable Gherkin linter * test: re-structure into pages and steps * chore: fix linter findings * chore: update tests * chore: fix tests * Fix scenario description being seen as Given steps * chore: fix linter findings
- Loading branch information
Showing
17 changed files
with
777 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Feature: Compile source code into working software | ||
|
||
As a developer | ||
In order to generate working software | ||
Source code needs to be compiled successfully | ||
|
||
Scenario: Compile valid source code into working software targeting the host architecture | ||
|
||
Compiling valid source code into working software, able to run on the host architecture, | ||
can be necessary in several scenarios; for example when: | ||
|
||
- the host is the deployment target | ||
- running tests on the host | ||
- building plug-ins, extensions, code generators, or other additional tools that need to run on the host | ||
|
||
Given the default build configuration is selected | ||
When the configuration "host" is built | ||
Then the output should contain "Build finished with exit code 0" |
37 changes: 37 additions & 0 deletions
37
.devcontainer/cpp/e2e/features/pages/authentication.pom.ts
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,37 @@ | ||
import { type Page } from '@playwright/test'; | ||
import * as OTPAuth from 'otpauth'; | ||
import { STORAGE_STATE } from '../../playwright.config'; | ||
|
||
export class AuthenticationPage { | ||
readonly page: Page; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
} | ||
|
||
async authenticate() { | ||
await this.page.goto('https://github.com/login'); | ||
await this.page.getByLabel('Username or email address').fill(process.env.GITHUB_USER!); | ||
await this.page.getByLabel('Password').fill(process.env.GITHUB_PASSWORD!); | ||
await this.page.getByRole('button', { name: 'Sign in', exact: true }).click(); | ||
|
||
let totp = new OTPAuth.TOTP({ | ||
issuer: 'GitHub', | ||
label: 'GitHub', | ||
algorithm: 'SHA1', | ||
digits: 6, | ||
period: 30, | ||
secret: process.env.GITHUB_TOTP_SECRET! | ||
}); | ||
|
||
let code = totp.generate(); | ||
await this.page.getByPlaceholder('XXXXXX').fill(code); | ||
|
||
// Wait until the page receives the cookies. | ||
// | ||
// Sometimes login flow sets cookies in the process of several redirects. | ||
// Wait for the final URL to ensure that the cookies are actually set. | ||
await this.page.waitForURL('https://github.com/'); | ||
await this.page.context().storageState({ path: STORAGE_STATE }); | ||
} | ||
} |
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,15 @@ | ||
import { expect } from "@playwright/test"; | ||
import { Given, When, Then } from "./fixtures"; | ||
|
||
Given("the default build configuration is selected", async () => { | ||
// No-op | ||
}); | ||
|
||
When("the configuration {string} is built", async ({ codespacePage }, configuration: string) => { | ||
await codespacePage.page.getByRole('button', { name: 'Build the selected target' }).click(); | ||
await codespacePage.page.getByLabel(configuration).locator('a').click(); | ||
}); | ||
|
||
Then("the output should contain {string}", async ({ codespacePage }, expectedOutput: string) => { | ||
await expect(codespacePage.outputPanel).toContainText(expectedOutput, { timeout: 5 * 60 * 1000 }); | ||
}); |
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,24 @@ | ||
import { AuthenticationPage } from '../pages/authentication.pom'; | ||
import { CodespacePage } from '../pages/codespace.pom'; | ||
import { test as base, createBdd } from 'playwright-bdd'; | ||
|
||
export const test = base.extend<{ codespacePage: CodespacePage }, { authenticationPage: AuthenticationPage }>({ | ||
authenticationPage: [async ({ browser }, use) => { | ||
let authenticationPage = new AuthenticationPage(await browser.newPage()); | ||
await authenticationPage.authenticate(); | ||
|
||
await use(authenticationPage); | ||
}, { scope: 'worker', auto: true } | ||
], | ||
codespacePage: async ({ page }, use) => { | ||
const codespacePage = new CodespacePage(page); | ||
await codespacePage.goto(); | ||
await codespacePage.areExtensionsActive(['Testing', 'SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); | ||
|
||
await use(codespacePage); | ||
|
||
await codespacePage.executeInTerminal('git clean -fdx'); | ||
}, | ||
}); | ||
|
||
export const { Given, When, Then } = createBdd(test); |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
{ | ||
"file-name": ["on", {"style": "kebab-case"}], | ||
"new-line-at-eof": ["on", "yes"], | ||
"no-background-only-scenario": "off", | ||
"no-dupe-feature-names": "on", | ||
"no-dupe-scenario-names": ["on", "in-feature"], | ||
"no-duplicate-tags": "on", | ||
"no-empty-background": "on", | ||
"no-empty-file": "on", | ||
"no-files-without-scenarios": "on", | ||
"no-multiple-empty-lines": "on", | ||
"no-partially-commented-tag-lines": "on", | ||
"no-scenario-outlines-without-examples": "on", | ||
"no-superfluous-tags": "on", | ||
"no-trailing-spaces": "on", | ||
"no-unnamed-features": "on", | ||
"no-unnamed-scenarios": "on", | ||
"no-unused-variables": "on", | ||
"one-space-between-tags": "on", | ||
"scenario-size": ["on", { "steps-length": {"Background": 5}}], | ||
"use-and": "on" | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.features-gen/ | ||
.xwin-cache/ | ||
.xwin-hash/ | ||
build/ | ||
|
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
Oops, something went wrong.