Skip to content

Commit

Permalink
Variables for locations
Browse files Browse the repository at this point in the history
  • Loading branch information
gr812b committed Nov 18, 2024
1 parent 27732a1 commit 1ab60f3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 19 deletions.
46 changes: 38 additions & 8 deletions e2e/package-lock.json

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

12 changes: 7 additions & 5 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineConfig, devices } from '@playwright/test';

export const WEB_SERVER_URL = 'http://localhost:5173';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
Expand Down Expand Up @@ -72,9 +74,9 @@ export default defineConfig({
],

/* 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,
// },
webServer: {
command: 'cd ../front-end && npm run start',
url: WEB_SERVER_URL,
reuseExistingServer: !process.env.CI,
},
});
4 changes: 3 additions & 1 deletion e2e/testers/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { Page, expect } from '@playwright/test';
import { Tester } from './tester';

export class GraphTester extends Tester {
frontendFilePath: string;

constructor(page: Page) {
super(page);
this.frontendFilePath = '182848/BATT VOLT';
}

async testCreateGraph() {
await this.openGraphForm();
await this.pressNextButton();
await this.selectFile('182848/BATT VOLT');
await this.selectFile(this.frontendFilePath);
await this.pressNextButton();
await this.submitGraph();
await this.verifyGraphCreated();
Expand Down
4 changes: 3 additions & 1 deletion e2e/testers/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ export class UploadTester extends Tester {
binFilePath: string;
csvFilePath: string;
mp4FilePath: string;
frontendFilePath: string;

constructor(page: Page) {
super(page);
this.binFilePath = path.join(__dirname, '../test-files/182848.bin');
this.csvFilePath = '';
this.mp4FilePath = '';
this.frontendFilePath = '182848/BATT VOLT';

if (!fs.existsSync(this.binFilePath)) {
throw new Error(`Test file not found at ${this.binFilePath}`);
Expand All @@ -24,7 +26,7 @@ export class UploadTester extends Tester {
await this.uploadFile(this.binFilePath);
await this.submitFile();
await this.verifyFilesUploaded();
await this.awaitFileParsed('182848/BATT VOLT');
await this.awaitFileParsed(this.frontendFilePath);
}

async testUploadNoFile() {
Expand Down
5 changes: 2 additions & 3 deletions e2e/tests/create/no-analyzer.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { test, expect } from '@playwright/test';
import { UploadTester, GraphTester } from '../../testers';
import { WEB_SERVER_URL } from '../../playwright.config';

test.describe('Create graphs', () => {

test.beforeEach(async ({ page }) => {
const uploadTester = new UploadTester(page);
await page.goto('http://localhost:5173/');
await page.goto(WEB_SERVER_URL);
await uploadTester.testUploadBinFile();
});

test('should open upload form and submit a file', async ({ page }) => {
const graphTester = new GraphTester(page);
await graphTester.testCreateGraph();
});


});
3 changes: 2 additions & 1 deletion e2e/tests/upload/upload.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { test, expect } from '@playwright/test';
import { UploadTester } from '../../testers';
import { WEB_SERVER_URL } from '../../playwright.config';

test.describe('Upload Form', () => {

test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:5173/');
await page.goto(WEB_SERVER_URL);
await expect(page.getByRole('button', { name: 'Upload' })).toBeVisible();
});

Expand Down

0 comments on commit 1ab60f3

Please sign in to comment.