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

[STCOR-869] Add small margin to fixed timeout warning to match call to /logout #1517

Open
wants to merge 4 commits into
base: keycloak-ramsons
Choose a base branch
from

Conversation

ryandberger
Copy link
Member

Copy link

Jest Unit Test Results

276 tests  ±0   276 ✅ ±0   58s ⏱️ -1s
 54 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 13cd263. ± Comparison against base commit da01a6a.

Copy link

Jest Unit Test Results

276 tests  ±0   276 ✅ ±0   1m 0s ⏱️ -1s
 54 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 13cd263. ± Comparison against base commit da01a6a.

Copy link

github-actions bot commented Aug 14, 2024

Bigtest Unit Test Results

192 tests  ±0   187 ✅ ±0   6s ⏱️ ±0s
  1 suites ±0     5 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 13cd263. ± Comparison against base commit da01a6a.

♻️ This comment has been updated with latest results.

Copy link

sonarcloud bot commented Aug 14, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
77.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Copy link
Member

@zburke zburke left a comment

Choose a reason for hiding this comment

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

@ryandberger, This works, but it splits the "when does my session end?" math across two different places, FFetch and FixedLengthSessionWarning. Could we consolidate all of into FFetch around lines 118-119? That would allow us to leave FixedLengthSessionWarning alone, and it would simplify the setTimeout() calls a little since they'd each just rely on their single rt...Interval values.

What do you think?

@@ -92,4 +92,4 @@ export const RTR_RT_EXPIRY_IF_UNKNOWN = '10m';
* To account for minor delays between events (such as cookie expiration and API calls),
* this is a small amount of time to wait so the proper order can be ensured if they happen simultaneously.
*/
export const RTR_TIME_MARGIN_IN_MS = 200;
export const RTR_TIME_MARGIN = '200m';
Copy link
Member

Choose a reason for hiding this comment

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

TLDR, use '200' instead of '200m'.

ms() parses strings -> ints and parses ints -> strings. Normally, the string contains a unit (s, m, h, d... for seconds, minutes, hours, days...) but if you want to provide an input in milliseconds then you omit the unit 🤷 just don't tell your high school physics teacher.

Since all our other time-values here get pushed through ms(), I think it's good practice to follow suit here, even though it feels kinda dumb to convert from milliseconds to milliseconds. I should've included the same comment from line 71, "value must be a string parsable by ms()", just above on in the description for the RTR_*_EXPIRY_IF_UNKNOWN values at line 87 🤦, which would have helped make this more obvious.

Comment on lines -34 to +41
screen.getByText(/0:00/);
screen.getByText(
new RegExp(timestampFormatter(ms(stripes.config.rtr.fixedLengthSessionWarningTTL) - ms(RTR_TIME_MARGIN)))
);
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why this test changed because from the user's point of view, nothing will be any different on screen: you will still see a countdown and it will still count down to 0:00 and then terminate your session. The only difference is that if your session was previously 100 seconds long, now it will be 99.8 seconds long. So, we still want to see 0:00 on the clock, we just expect to see it 200ms earlier than we did previously.

Comment on lines -56 to +65
await waitFor(() => screen.getByText(/00:09/), { timeout: 2000 });
await waitFor(() => screen.getByText(
new RegExp(timestampFormatter(ms(stripes.config.rtr.fixedLengthSessionWarningTTL) - ms(RTR_TIME_MARGIN)))
), { timeout: 2000 });
Copy link
Member

Choose a reason for hiding this comment

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

As above, I don't think we this test should need to change. Can you explain why this was necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants