-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add basic smoke tests with sso, git commit, and file uploads (#…
- Loading branch information
1 parent
8ecd5b4
commit 2c34cf9
Showing
12 changed files
with
366 additions
and
15 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
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,26 @@ | ||
import { test as setup, expect } from '@playwright/test'; | ||
import { authFile } from './playwright.config'; | ||
|
||
setup('authenticate', async ({ page, context }) => { | ||
await page.goto('/'); | ||
|
||
await page.getByLabel('Username or email').fill('doug'); | ||
await page.getByLabel('Password').fill('unicorn123!@#'); | ||
await page.getByRole('button', { name: "Log In" }).click(); | ||
|
||
await page.waitForURL('/'); // successful redirect | ||
|
||
// ensure auth cookies were set | ||
const cookies = await context.cookies(); | ||
const keycloakCookie = cookies.find( | ||
(cookie) => cookie.name === "KEYCLOAK_SESSION", | ||
); | ||
|
||
expect(keycloakCookie).toBeDefined(); | ||
expect(keycloakCookie?.value).not.toBe(""); | ||
expect(keycloakCookie?.domain).toContain("sso."); | ||
|
||
await page.context().storageState({ path: authFile }); | ||
|
||
await expect(page).toHaveURL('/'); | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 @@ | ||
kind: ZarfPackageConfig | ||
metadata: | ||
name: gitlab-git-tests | ||
version: 0.0.1 | ||
description: A package with git repos used for testing | ||
|
||
components: | ||
- name: git-repos | ||
repos: | ||
# This references a commit that has a .gitlab-ci.yml in it - to update this push a PR and a new commit. | ||
- https://github.com/defenseunicorns/uds-package-gitlab-runner.git | ||
- https://github.com/defenseunicorns/uds-core.git |
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,68 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import path from "path"; | ||
|
||
function randomProjectName(prefix: string = 'uds-package-test') { | ||
return [ prefix, Math.floor((Math.random() * 10_000)) ].join('-'); | ||
} | ||
|
||
test('setup a project', async ({ page }) => { | ||
const projectName = randomProjectName(); | ||
|
||
await page.goto('/projects/new#blank_project'); | ||
await page.getByLabel('Project name').fill(projectName); | ||
await page.getByLabel('Initialize repository with a README').setChecked(true); | ||
await page.getByRole('button', { name: 'Create project' }).click(); | ||
|
||
await expect(page).toHaveURL(`/doug/${projectName}`); | ||
|
||
await test.step('create a file', async () => { | ||
await page.goto(`/doug/${projectName}/-/new/main`); | ||
|
||
await page.getByTestId('file-name-field').fill('docs/README.md'); | ||
await page.getByLabel('Editor content;Press Alt+F1').fill('# Docs', { force: true }); | ||
await page.getByTestId('commit-button').click(); | ||
|
||
await expect(page).toHaveURL(`/doug/${projectName}/-/blob/main/docs/README.md`) | ||
await expect(page.getByRole('heading', { level: 1 })).toContainText('Docs'); | ||
}); | ||
|
||
await test.step('create an issue', async () => { | ||
await page.goto(`/doug/${projectName}/-/issues/new`); | ||
|
||
await page.getByTestId('issuable-form-title-field').fill('We should write more tests!'); | ||
|
||
const descriptionBox = page.getByTestId('issuable-form-description-field'); | ||
|
||
await descriptionBox.fill(`Why are there no tests???\n\n`); | ||
|
||
// upload a file | ||
const fileChooserPromise = page.waitForEvent('filechooser'); | ||
await page.getByRole('button', { name: 'Attach a file or image' }).click(); | ||
const fileChooser = await fileChooserPromise; | ||
await fileChooser.setFiles(path.join(__dirname, 'data/unicorns.jpeg')); | ||
|
||
// check that markdown description box is updated | ||
await expect(descriptionBox).toHaveValue(/uploads\/[a-z0-9]+\/unicorns\.jpeg/); | ||
|
||
await page.getByTestId('issuable-create-button').click(); | ||
|
||
// check that rendered image ends up in issue description | ||
await expect(page.getByRole('img', { name: 'unicorns' })) | ||
.toHaveAttribute('src', /uploads\/[a-z0-9]+\/unicorns\.jpeg/); | ||
}); | ||
|
||
// regression test for Istio path decoding: https://github.com/defenseunicorns/uds-core/issues/288 | ||
await test.step('fetch via API', async () => { | ||
const projectPath = encodeURIComponent(`doug/${projectName}`); | ||
|
||
const res = await page.request.get(`/api/v4/projects/${projectPath}`); | ||
|
||
expect(res.url()).toContain('%2F'); | ||
await expect(res).toBeOK(); | ||
|
||
const project = await res.json(); | ||
|
||
expect(project.path).toBe(projectName); | ||
expect(project.namespace.path).toBe('doug'); | ||
}); | ||
}); |
Oops, something went wrong.