Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Merge branch 'credential-registry' of github.com:Altinn/summer-camp-2…
Browse files Browse the repository at this point in the history
…023 into credential-registry
  • Loading branch information
Seip committed Aug 8, 2023
2 parents 654d977 + 106e634 commit 1008e34
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test-results
playwright-report
67 changes: 67 additions & 0 deletions tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "summer-camp-2023",
"version": "1.0.0",
"description": "Backlog for sommercamp 2023",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.36.2"
}
}
77 changes: 77 additions & 0 deletions tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },

// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
Empty file added tests/tests/clear.spec.ts
Empty file.
20 changes: 20 additions & 0 deletions tests/tests/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { test, expect } from '@playwright/test';

// https://playwright.dev/docs/api-testing

test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});

test('get started link', async ({ page }) => {
await page.goto('https://playwright.dev/');

// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click();

// Expects the URL to contain intro.
await expect(page).toHaveURL(/.*intro/);
});
48 changes: 48 additions & 0 deletions tests/tests/register.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { test, expect } from '@playwright/test';

const url = 'http://localhost:5000'

test('should not return OK for empty input', async ({ request }) => {

const response = await request.post(url + "/register", {
data: {}
});

expect(response.ok()).toBeFalsy();
});

test('should not return 200 OK for invalid input', async ({ request }) => {

const response = await request.post(url + "/register", {
data: {
did: 'invalid did',
firstName: '',
lastName: '',
expDate: '',
location: '',
municipality: '',
alcoGroup: ''
}
});

expect(response.ok()).toBeFalsy();
});

test('should register credential for correct input', async ({ request }) => {
const data = {
did:"did:digdir:0x2546BcD3c84621e976D8185a91A922aE77ECEc30",
firstName:"Emil",
lastName:"Ovesen",
expDate:"17-12-2023",
location:"Langtvekkistan",
municipality:"Brønnøysund",
alcoGroup:"Mega"
}
const response = await request.post(url + "/register", {
data: data
});

expect(response.ok()).toBeTruthy();
// TODO: Confirm registration
});

Empty file added tests/tests/revoke.spec.ts
Empty file.
Empty file added tests/tests/verify.spec.ts
Empty file.

0 comments on commit 1008e34

Please sign in to comment.