Skip to content

Commit b8bd320

Browse files
authored
chore: update cSpell and fix isNotificationTextPrefixed (#4076)
* chore: update cSpell words * chore: add ignorePaths for cSpell * fix: update isNotificationTextPrefixed This removes an eslint-disable rule and adds two new tests to ensure isNotificationTextPrefixed is working as expected. * fix(e2e): remove filter in workspacesPage
1 parent 9e9a9e0 commit b8bd320

File tree

5 files changed

+38
-98
lines changed

5 files changed

+38
-98
lines changed

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"circbuf",
99
"cliflag",
1010
"cliui",
11+
"codecov",
12+
"Codespaces",
1113
"coderd",
1214
"coderdtest",
1315
"codersdk",
@@ -80,6 +82,7 @@
8082
"ptty",
8183
"ptys",
8284
"ptytest",
85+
"quickstart",
8386
"reconfig",
8487
"retrier",
8588
"rpty",
@@ -117,10 +120,12 @@
117120
"tstun",
118121
"turnconn",
119122
"typegen",
123+
"typesafe",
120124
"unconvert",
121125
"Untar",
122126
"Userspace",
123127
"VMID",
128+
"walkthrough",
124129
"weblinks",
125130
"webrtc",
126131
"wgcfg",
@@ -140,6 +145,10 @@
140145
"xstate",
141146
"yamux"
142147
],
148+
"cSpell.ignorePaths": [
149+
"site/package.json",
150+
".vscode/settings.json"
151+
],
143152
"emeraldwalk.runonsave": {
144153
"commands": [
145154
{

site/e2e/tests/login.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { test } from "@playwright/test"
22
import { email, password } from "../constants"
3-
import { SignInPage, WorkspacesPage } from "../pom"
4-
import { waitForClientSideNavigation } from "./../util"
3+
import { SignInPage } from "../pom"
54

65
test("Login takes user to /workspaces", async ({ baseURL, page }) => {
76
await page.goto(baseURL + "/", { waitUntil: "networkidle" })
@@ -10,8 +9,5 @@ test("Login takes user to /workspaces", async ({ baseURL, page }) => {
109
const signInPage = new SignInPage(baseURL, page)
1110
await signInPage.submitBuiltInAuthentication(email, password)
1211

13-
const workspacesPage = new WorkspacesPage(baseURL, page, "?filter=owner%3Ame")
14-
await waitForClientSideNavigation(page, { to: workspacesPage.url })
15-
1612
await page.waitForSelector("text=Workspaces")
1713
})

site/e2e/util.ts

Lines changed: 0 additions & 91 deletions
This file was deleted.

site/src/components/GlobalSnackbar/utils.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
isNotificationTextPrefixed,
55
MsgType,
66
NotificationMsg,
7+
NotificationTextPrefixed,
78
SnackbarEventType,
89
} from "./utils"
910

@@ -17,6 +18,29 @@ describe("Snackbar", () => {
1718
// When
1819
const isTextPrefixed = isNotificationTextPrefixed(msg)
1920

21+
// Then
22+
expect(isTextPrefixed).toBe(false)
23+
})
24+
it("returns true if prefixed", () => {
25+
// Given
26+
const msg: NotificationTextPrefixed = {
27+
prefix: "warning",
28+
text: "careful with this workspace",
29+
}
30+
31+
// When
32+
const isTextPrefixed = isNotificationTextPrefixed(msg)
33+
34+
// Then
35+
expect(isTextPrefixed).toBe(true)
36+
})
37+
it("returns false if not prefixed", () => {
38+
// Given
39+
const msg = "plain ol' message"
40+
41+
// When
42+
const isTextPrefixed = isNotificationTextPrefixed(msg)
43+
2044
// Then
2145
expect(isTextPrefixed).toBe(false)
2246
})

site/src/components/GlobalSnackbar/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ export const isNotificationText = (msg: AdditionalMessage): msg is string => {
2727
export const isNotificationTextPrefixed = (
2828
msg: AdditionalMessage | null,
2929
): msg is NotificationTextPrefixed => {
30-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
31-
return typeof (msg as NotificationTextPrefixed)?.prefix !== "undefined"
30+
if (msg) {
31+
return typeof msg !== "string" && Object.prototype.hasOwnProperty.call(msg, "prefix")
32+
}
33+
return false
3234
}
3335

3436
export const isNotificationList = (msg: AdditionalMessage): msg is string[] => {

0 commit comments

Comments
 (0)