From c3835522c60bc787cf8b96162961626403eeaf90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Mon, 23 Oct 2023 17:19:42 +0200 Subject: [PATCH] Fix integration test utils --- ui-tests/tests/add-tag.spec.ts | 4 ++-- ui-tests/tests/commit-diff.spec.ts | 4 ++-- ui-tests/tests/file-selection.spec.ts | 8 ++++---- ui-tests/tests/git-stash.spec.ts | 4 ++-- ui-tests/tests/image-diff.spec.ts | 4 ++-- ui-tests/tests/merge-commit.spec.ts | 4 ++-- ui-tests/tests/merge-conflict.spec.ts | 4 ++-- ui-tests/tests/rebase.spec.ts | 4 ++-- ui-tests/tests/utils.ts | 11 ++++------- 9 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ui-tests/tests/add-tag.spec.ts b/ui-tests/tests/add-tag.spec.ts index dce44754f..10ed85b7c 100644 --- a/ui-tests/tests/add-tag.spec.ts +++ b/ui-tests/tests/add-tag.spec.ts @@ -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') ); diff --git a/ui-tests/tests/commit-diff.spec.ts b/ui-tests/tests/commit-diff.spec.ts index e65dddc24..2bc95cc55 100644 --- a/ui-tests/tests/commit-diff.spec.ts +++ b/ui-tests/tests/commit-diff.spec.ts @@ -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') ); diff --git a/ui-tests/tests/file-selection.spec.ts b/ui-tests/tests/file-selection.spec.ts index a9ae7dd08..9cafc61e6 100644 --- a/ui-tests/tests/file-selection.spec.ts +++ b/ui-tests/tests/file-selection.spec.ts @@ -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') ); @@ -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') ); diff --git a/ui-tests/tests/git-stash.spec.ts b/ui-tests/tests/git-stash.spec.ts index 43820727a..589d8853c 100644 --- a/ui-tests/tests/git-stash.spec.ts +++ b/ui-tests/tests/git-stash.spec.ts @@ -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') ); diff --git a/ui-tests/tests/image-diff.spec.ts b/ui-tests/tests/image-diff.spec.ts index 1570806f8..0523b8ace 100644 --- a/ui-tests/tests/image-diff.spec.ts +++ b/ui-tests/tests/image-diff.spec.ts @@ -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') ); diff --git a/ui-tests/tests/merge-commit.spec.ts b/ui-tests/tests/merge-commit.spec.ts index b9b970dd3..8a10f3857 100644 --- a/ui-tests/tests/merge-commit.spec.ts +++ b/ui-tests/tests/merge-commit.spec.ts @@ -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') ); diff --git a/ui-tests/tests/merge-conflict.spec.ts b/ui-tests/tests/merge-conflict.spec.ts index b508ff5ba..53c6dd72e 100644 --- a/ui-tests/tests/merge-conflict.spec.ts +++ b/ui-tests/tests/merge-conflict.spec.ts @@ -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') ); diff --git a/ui-tests/tests/rebase.spec.ts b/ui-tests/tests/rebase.spec.ts index af22c08c7..9e8a48fe4 100644 --- a/ui-tests/tests/rebase.spec.ts +++ b/ui-tests/tests/rebase.spec.ts @@ -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 }) => { await extractFile( - baseURL, + request, path.resolve(__dirname, 'data', baseRepositoryPath), path.join(tmpPath, 'repository.tar.gz') ); diff --git a/ui-tests/tests/utils.ts b/ui-tests/tests/utils.ts index 1f5932932..faaee9105 100644 --- a/ui-tests/tests/utils.ts +++ b/ui-tests/tests/utils.ts @@ -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 { - 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); }