-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from technologiestiftung/feat/adjust-local-se…
…tup-for-ui-rework-e2e-tests feat: adjust setup for ui-rework e2e tests
- Loading branch information
Showing
3 changed files
with
43 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
supabaseAnonClient, | ||
supabaseServiceRoleClient, | ||
} from "../__test-utils/supabase"; | ||
import { requestSupabaseTestToken } from "../__test-utils/req-test-token"; | ||
describe("misc test testing the schema function of the database", () => { | ||
test("inserting an existing username should alter the new name and add a uuid at end", async () => { | ||
const email1 = "[email protected]"; | ||
|
@@ -49,12 +50,16 @@ describe("misc test testing the schema function of the database", () => { | |
const numberOfTrees = 10; | ||
const email = "[email protected]"; | ||
await deleteSupabaseUser(email); // clean up before running | ||
const { data, error } = await supabaseAnonClient.auth.signUp({ | ||
email: email, | ||
password: "12345678", | ||
}); | ||
const { data, error } = | ||
await supabaseServiceRoleClient.auth.admin.createUser({ | ||
email: email, | ||
password: "12345678", | ||
email_confirm: true, | ||
}); | ||
expect(error).toBeNull(); | ||
expect(data).toBeDefined(); | ||
expect(data.user).toBeDefined(); | ||
const accessToken = await requestSupabaseTestToken(email, "12345678"); | ||
expect(accessToken).toBeDefined(); | ||
const { data: trees, error: treesError } = await supabaseAnonClient | ||
.from("trees") | ||
.select("*") | ||
|
@@ -98,7 +103,7 @@ describe("misc test testing the schema function of the database", () => { | |
headers: { | ||
apikey: SUPABASE_ANON_KEY, | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${data.session?.access_token}`, | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
expect(response.ok).toBeTruthy(); | ||
|
@@ -107,15 +112,15 @@ describe("misc test testing the schema function of the database", () => { | |
await supabaseAnonClient | ||
.from("trees_watered") | ||
.select("*") | ||
.eq("uuid", data.user?.id); | ||
.eq("uuid", data.user!.id); | ||
expect(treesAfterError).toBeNull(); | ||
expect(treesAfter).toHaveLength(0); | ||
|
||
const { data: adoptedTreesAfter, error: adoptedTreesAfterError } = | ||
await supabaseAnonClient | ||
.from("trees_adopted") | ||
.select("*") | ||
.eq("uuid", data.user?.id); | ||
.eq("uuid", data.user!.id); | ||
expect(adoptedTreesAfterError).toBeNull(); | ||
expect(adoptedTreesAfter).toHaveLength(0); | ||
await truncateTreesWaterd(); | ||
|
@@ -126,12 +131,16 @@ describe("misc test testing the schema function of the database", () => { | |
const numberOfTrees = 10; | ||
await deleteSupabaseUser(email); | ||
await truncateTreesWaterd(); | ||
const { data, error } = await supabaseAnonClient.auth.signUp({ | ||
email: email, | ||
password: "12345678", | ||
}); | ||
const { data, error } = | ||
await supabaseServiceRoleClient.auth.admin.createUser({ | ||
email: email, | ||
password: "12345678", | ||
email_confirm: true, | ||
}); | ||
expect(error).toBeNull(); | ||
expect(data).toBeDefined(); | ||
expect(data.user).toBeDefined(); | ||
const accessToken = await requestSupabaseTestToken(email, "12345678"); | ||
expect(accessToken).toBeDefined(); | ||
const { data: trees, error: treesError } = await supabaseAnonClient | ||
.from("trees") | ||
.select("*") | ||
|
@@ -164,7 +173,7 @@ describe("misc test testing the schema function of the database", () => { | |
headers: { | ||
apikey: SUPABASE_ANON_KEY, | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${data.session?.access_token}`, | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
body: JSON.stringify({ | ||
username: "bar", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters