Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: env variable config and automatic setServerAddress [TESTENG-49] #9582

Merged
merged 6 commits into from
Jul 1, 2024

Conversation

JComins000
Copy link
Contributor

@JComins000 JComins000 commented Jun 27, 2024

Ticket

TESTENG-49

Description

autouse dev setserveradress
move env var config to a file
rename env vars, check the readme

Test Plan

Checklist

  • Changes have been manually QA'd
  • New features have been approved by the corresponding PM
  • User-facing API changes have the "User-facing API Change" label
  • Release notes have been added as a separate file under docs/release-notes/
    See Release Note for details.
  • Licenses have been included for new code which was copied and/or modified from any external code

@JComins000 JComins000 requested a review from a team as a code owner June 27, 2024 16:20
@cla-bot cla-bot bot added the cla-signed label Jun 27, 2024
Copy link

netlify bot commented Jun 27, 2024

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit c19df87
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/667f2468592a5b0008ff45d5
😎 Deploy Preview https://deploy-preview-9582--determined-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.


const serverAddess = process.env.PW_SERVER_ADDRESS;
if (serverAddess === undefined) {
throw new Error('Expected PW_SERVER_ADDRESS to be set.');
throw new Error(`Expected PW_SERVER_ADDRESS to be set. ${JSON.stringify(process.env)}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

circle automatically hides sensitive things

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.27%. Comparing base (b73fbbc) to head (c19df87).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9582      +/-   ##
==========================================
- Coverage   49.86%   45.27%   -4.60%     
==========================================
  Files        1247      923     -324     
  Lines      162287   121954   -40333     
  Branches     2888     2887       -1     
==========================================
- Hits        80931    55216   -25715     
+ Misses      81185    66567   -14618     
  Partials      171      171              
Flag Coverage Δ
harness ?
web 46.22% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 324 files with indirect coverage changes

await use(dev);
},
devSetup: [
Copy link
Contributor Author

@JComins000 JComins000 Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now we automatically use a dev command on the UI for each page we get (every test). the dev command is set to local storage

@JComins000 JComins000 force-pushed the jcom/temp/testing-pw-config-stuff branch from 986cc2e to 43db0a6 Compare June 27, 2024 20:27
});
await this.browserContext.addCookies(state.cookies);
const token = JSON.stringify(await this.getBearerToken(true));
await page.evaluate((token) => localStorage.setItem('global/auth-token', token), token);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was the magic i needed

}

export function apiUrl(): string {
return process.env.PW_BACKEND_SERVER_ADDRESS ?? webServerUrl();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djanicekpach @johnkim-det can you help me reconsider this environment variable name? maybe like this?

PW_BASE_URL="http://localhost:3000/"
PW_SERVER_ADDRESS="http://latest-main.determined.ai:8080/"
PW_USER_NAME="..."
PW_PASSWORD="..."
PW_DET_PATH="/Users/jcomins/miniconda3/envs/det/bin/det"

where PW_SERVER_ADDRESS would be optional, so this would also work

PW_BASE_URL="http://localhost:3000"
PW_USER_NAME="admin"
PW_PASSWORD=""
PW_DET_PATH="/Users/jcomins/miniconda3/envs/det/bin/det"

do these names look good to you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw PW_DET_MASTER in code and I thought that name was good. Is that included?
I don't love PW_BASE_URL, but it matches playwright's config so I'm ok with it.

import { defineConfig, devices } from '@playwright/test';
import * as dotenv from 'dotenv';

dotenv.config();
dotenv.config({ path: path.resolve(__dirname, '.env') });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnkim-det can you try .env with this change?

@johnkim-det johnkim-det self-requested a review June 28, 2024 17:14
@johnkim-det johnkim-det self-assigned this Jun 28, 2024
@JComins000 JComins000 force-pushed the jcom/temp/testing-pw-config-stuff branch 5 times, most recently from a08cd71 to cf9f024 Compare June 28, 2024 19:54
webui/react/src/e2e/fixtures/global-fixtures.ts Outdated Show resolved Hide resolved
}

export function apiUrl(): string {
return process.env.PW_BACKEND_SERVER_ADDRESS ?? webServerUrl();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw PW_DET_MASTER in code and I thought that name was good. Is that included?
I don't love PW_BASE_URL, but it matches playwright's config so I'm ok with it.

@JComins000 JComins000 force-pushed the jcom/temp/testing-pw-config-stuff branch from cf9f024 to 78b3c2a Compare June 28, 2024 20:02
@JComins000 JComins000 force-pushed the jcom/temp/testing-pw-config-stuff branch from 78b3c2a to c19df87 Compare June 28, 2024 21:00
@JComins000 JComins000 merged commit 98d574e into main Jul 1, 2024
85 of 98 checks passed
@JComins000 JComins000 deleted the jcom/temp/testing-pw-config-stuff branch July 1, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants