Skip to content

Commit

Permalink
Fix integration test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Oct 23, 2023
1 parent 4577c58 commit c383552
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 25 deletions.
4 changes: 2 additions & 2 deletions ui-tests/tests/add-tag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const baseRepositoryPath = 'test-repository-dirty.tar.gz';
test.use({ autoGoto: false, mockSettings: galata.DEFAULT_SETTINGS });

test.describe('Add tag', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down
4 changes: 2 additions & 2 deletions ui-tests/tests/commit-diff.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const baseRepositoryPath = 'test-repository.tar.gz';
test.use({ autoGoto: false });

test.describe('Commits diff', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down
8 changes: 4 additions & 4 deletions ui-tests/tests/file-selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const baseRepositoryPath = 'test-repository-dirty.tar.gz';
test.use({ autoGoto: false });

test.describe('File selection for normal staging', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down Expand Up @@ -51,9 +51,9 @@ test.describe('File selection for normal staging', () => {
});

test.describe('File selection for simple staging', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down
4 changes: 2 additions & 2 deletions ui-tests/tests/git-stash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const baseRepositoryPath = 'test-repository-stash.tar.gz';
test.use({ autoGoto: false });

test.describe('Git Stash Commands', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down
4 changes: 2 additions & 2 deletions ui-tests/tests/image-diff.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const baseRepositoryPath = 'test-repository.tar.gz';
test.use({ autoGoto: false });

test.describe('Image diff', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down
4 changes: 2 additions & 2 deletions ui-tests/tests/merge-commit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const baseRepositoryPath = 'test-repository-merge-commits.tar.gz';
test.use({ autoGoto: false, mockSettings: galata.DEFAULT_SETTINGS });

test.describe('Merge commit tests', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down
4 changes: 2 additions & 2 deletions ui-tests/tests/merge-conflict.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const baseRepositoryPath = 'test-repository.tar.gz';
test.use({ autoGoto: false, mockSettings: galata.DEFAULT_SETTINGS });

test.describe('Merge conflict tests', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down
4 changes: 2 additions & 2 deletions ui-tests/tests/rebase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const baseRepositoryPath = 'test-repository.tar.gz';
test.use({ autoGoto: false, mockSettings: galata.DEFAULT_SETTINGS });

test.describe('Rebase', () => {
test.beforeEach(async ({ baseURL, page, tmpPath }) => {
test.beforeEach(async ({ page, request, tmpPath }) => {

Check failure on line 9 in ui-tests/tests/rebase.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/rebase.spec.ts:44:7 › Rebase › should resolve a conflicted rebase

5) tests/rebase.spec.ts:44:7 › Rebase › should resolve a conflicted rebase ─────────────────────── Test timeout of 60000ms exceeded while running "beforeEach" hook. 7 | 8 | test.describe('Rebase', () => { > 9 | test.beforeEach(async ({ page, request, tmpPath }) => { | ^ 10 | await extractFile( 11 | request, 12 | path.resolve(__dirname, 'data', baseRepositoryPath), at /home/runner/work/jupyterlab-git/jupyterlab-git/ui-tests/tests/rebase.spec.ts:9:8
await extractFile(
baseURL,
request,
path.resolve(__dirname, 'data', baseRepositoryPath),
path.join(tmpPath, 'repository.tar.gz')
);
Expand Down
11 changes: 4 additions & 7 deletions ui-tests/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { galata } from '@jupyterlab/galata';
import fetch from 'node-fetch';
import path from 'path';
import { APIRequestContext } from '@playwright/test';

export async function extractFile(
baseURL: string,
request: APIRequestContext,
filePath: string,
destination: string
): Promise<void> {
const contents = galata.newContentsHelper(baseURL);
const contents = galata.newContentsHelper(request);
await contents.uploadFile(filePath, destination);

await fetch(`${contents.baseURL}/extract-archive/${destination}`, {
method: 'GET'
});
await request.get(`/extract-archive/${destination}`);

await contents.deleteFile(destination);
}

0 comments on commit c383552

Please sign in to comment.