Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
framitdavid committed Dec 19, 2023
1 parent d4dbf1a commit 225b620
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 39 deletions.
5 changes: 1 addition & 4 deletions frontend/testing/playwright/helpers/BasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { Environment } from './StudioEnvironment';
export class BasePage extends RouterRoute {
public readonly page: Page;

constructor(
page: Page,
environment?: Environment,
) {
constructor(page: Page, environment?: Environment) {
super(environment);
this.page = page;
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/testing/playwright/helpers/RouterRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const routerRoutes: RouterRoutes = {
editorOverview: `/editor/{{org}}/{{app}}/overview`,
};


export class RouterRoute extends StudioEnvironment {

constructor(environment: Environment) {
super(environment);
}
Expand Down
23 changes: 11 additions & 12 deletions frontend/testing/playwright/integration/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { test as setup } from '@playwright/test';
import { LoginPage } from "../pages/LoginPage";
import { LoginPage } from '../pages/LoginPage';

setup('authenticate user', async ({ page }): Promise<void> => {
const loginPage = new LoginPage(page);

setup('authenticate user', async ({page}): Promise<void> => {
const loginPage = new LoginPage(page);

await loginPage.goToAltinnLoginPage();
await loginPage.goToGiteaLoginPage();
await loginPage.writeUsername(process.env.PLAYWRIGHT_USER);
await loginPage.writePassword(process.env.PLAYWRIGHT_PASS);
await loginPage.clickLoginButton();
await loginPage.confirmSuccessfulLogin();
await loginPage.addSessionToSharableStorage();
})
await loginPage.goToAltinnLoginPage();
await loginPage.goToGiteaLoginPage();
await loginPage.writeUsername(process.env.PLAYWRIGHT_USER);
await loginPage.writePassword(process.env.PLAYWRIGHT_PASS);
await loginPage.clickLoginButton();
await loginPage.confirmSuccessfulLogin();
await loginPage.addSessionToSharableStorage();
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { test, } from '@playwright/test';
import {CreateServicePage} from "../pages/CreateServicePage";
import {DashboardPage} from "../pages/DashboardPage";
import { test } from '@playwright/test';
import { CreateServicePage } from '../pages/CreateServicePage';
import { DashboardPage } from '../pages/DashboardPage';

test.describe('create-app-and-simple-schema', () => {
test('should load dashboard and be able to navigate to create app', async ({ page }): Promise<void> => {
test('should load dashboard and be able to navigate to create app', async ({
page,
}): Promise<void> => {
const dashboardPage = new DashboardPage(page);

await dashboardPage.goToDashboard();
Expand All @@ -20,13 +22,13 @@ test.describe('create-app-and-simple-schema', () => {
await createServicePage.redirectedToEditorOverview();
});

test('should create new datamodel and name it "simple-db-model"', async ({ page }): Promise<void> => {

});
test('should create new datamodel and name it "simple-db-model"', async ({
page,
}): Promise<void> => {});

test.afterAll(async ({ request }) => {
request.delete('', {})
})
request.delete('', {});
});
});


25 changes: 13 additions & 12 deletions frontend/testing/playwright/scripts/setup.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
import path from 'path'
import path from 'path';
import fs from 'fs';

require('dotenv').config({path: path.resolve(__dirname, '../../../../.env')})
import os from "os";
require('dotenv').config({ path: path.resolve(__dirname, '../../../../.env') });
import os from 'os';

const environment: Record<string, string> = {
PLAYWRIGHT_TEST_BASE_URL: 'http://studio.localhost',
PLAYWRIGHT_DESIGNER_APP_NAME: 'auto-test-app',

PLAYWRIGHT_USER: process.env.GITEA_CYPRESS_USER,
PLAYWRIGHT_PASS: process.env.GITEA_CYPRESS_PASS
}
PLAYWRIGHT_PASS: process.env.GITEA_CYPRESS_PASS,
};

const getEnvFilePath = (): string => {
return path.resolve(__dirname, '..', '.env');
}
};

const mapEnvironment = () => {
return Object.keys(environment).map((key) => ([key, environment[key]].join('='))).join(os.EOL);
}
return Object.keys(environment)
.map((key) => [key, environment[key]].join('='))
.join(os.EOL);
};

const updateEnvironmentVars = (): void => {
const filePath: string = getEnvFilePath();
console.table(environment);
fs.writeFileSync(filePath, mapEnvironment(), {encoding: 'utf8', flag: 'w'})
}

fs.writeFileSync(filePath, mapEnvironment(), { encoding: 'utf8', flag: 'w' });
};

(async (): Promise<void> => {
console.log('----- SETUP PLAYWRIGHT ENVIRONMENT VARIABLES STARTED -----');
if (!environment.PLAYWRIGHT_USER || !environment.PLAYWRIGHT_PASS) {
console.error('Ensure to run `node setup.js` within development folder on root.');
return;
}
updateEnvironmentVars()
updateEnvironmentVars();
console.log('----- SETUP PLAYWRIGHT ENVIRONMENT VARIABLES DONE -----');
})();

0 comments on commit 225b620

Please sign in to comment.