Skip to content

Commit

Permalink
Merge commit '396057de431265ea704663f3ac5e7569d839dd9d' into feature/…
Browse files Browse the repository at this point in the history
…documentation-update
  • Loading branch information
rjaegers committed Nov 7, 2024
2 parents 954e3ee + 396057d commit e9951f8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
36 changes: 30 additions & 6 deletions .github/workflows/acceptance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,44 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
- run: npm ci
- run: npx playwright install --with-deps
# Create a GitHub Codespace and communicate the image version via a Codespace secret (should be a Codespace environment variable).
# This secret is used by devcontainer.json, as such it is a resource that should not be used concurrently.
- run: |
- name: Start Codespace
run: |
set -Eeuo pipefail
gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}"
echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ inputs.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV"
env:
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
HEAD_REF: ${{ github.head_ref }}
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
- run: npm ci
- run: npx playwright install --with-deps
- name: Wait for Codespace to be active
run: |
set -Eeuo pipefail
MAX_WAIT_SECONDS=$((3 * 60))
SECONDS_ELAPSED=0
while true; do
STATE=$(gh codespace list --json name,state --jq ".[] | select(.name == \"$CODESPACE_NAME\") | .state")
echo "Current state: $STATE"
if [ "$STATE" == "Available" ]; then
echo "Codespace is active!"
break
fi
if [ $SECONDS_ELAPSED -ge $MAX_WAIT_SECONDS ]; then
echo "Timeout reached. Codespace is not active."
exit 1
fi
sleep 5
SECONDS_ELAPSED=$((SECONDS_ELAPSED + 5))
done
env:
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
- run: cd test/${{ inputs.flavor }}/features && npm test
env:
GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }}
Expand Down
6 changes: 5 additions & 1 deletion test/cpp/features/pages/codespace.pom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class CodespacePage {
test.setTimeout(3 * 60 * 1000);

for (const plugin of extensions) {
await expect(this.page.getByRole('tab', { name: plugin }).locator('a')).toBeVisible({ timeout: 5 * 60 * 1000 });
await expect(this.page.getByRole('tab', { name: plugin, exact: true }).locator('a')).toBeVisible({ timeout: 5 * 60 * 1000 });
}

await expect(this.page.getByRole('button', { name: 'Activating Extensions...' })).toBeHidden();
Expand Down Expand Up @@ -148,6 +148,10 @@ export class CodespacePage {
await expect(this.page.getByRole('code')).toContainText(expected);
}

async expectOutputToContain(expectedOutput: string) {
await expect(this.outputPanel).toContainText(expectedOutput, { timeout: 5 * 60 * 1000 });
}

async expectFileContentsToMatch(actual: string, expected: string) {
await this.executeInTerminal(`diff -s ${actual} ${expected}`);
await expect(this.page.locator('#terminal')).toContainText(`Files ${actual} and ${expected} are identical`);
Expand Down
3 changes: 1 addition & 2 deletions test/cpp/features/steps/codespace.steps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from "@playwright/test";
import { Given, When, Then } from "./fixtures";

Given("build configuration {string} is selected", async ({ codespacePage }, configuration: string) => {
Expand Down Expand Up @@ -26,7 +25,7 @@ When("the active document is saved", async ({ codespacePage }) => {
});

Then("the output should contain {string}", async ({ codespacePage }, expectedOutput: string) => {
await expect(codespacePage.outputPanel).toContainText(expectedOutput, { timeout: 5 * 60 * 1000 });
await codespacePage.expectOutputToContain(expectedOutput);
});

Then("the editor should contain {string}", async ({ codespacePage }, expectedContent: string) => {
Expand Down

0 comments on commit e9951f8

Please sign in to comment.