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

Json database #48

Merged
merged 12 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@
5. Set up local development for supabase
```sh
https://supabase.com/docs/guides/cli/local-development

Enable webhooks in the supabase dashboard or create a "supabase_functions" schema manually.
Update environment variables (supabaseProjectUrl, supabaseAnonKey, supabaseRoleLevelSecurityKeys VAPID_Keys ) in
- src/environments/environment.ts
- supabase/migrations/<all files with webhook>
- the .bat files

Optional: Set up a remote environment on supabase.com
```
6. Start Angular dev server
```sh
Expand Down
7 changes: 5 additions & 2 deletions copy_sql_files_to_migration_folder.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ if errorlevel 1 (
supabase db push --include-all
pause

supabase functions deploy
pause

@REM Generate types from remote (requires to click apply editor config to work locally, else wise type errors
@REM occure)
supabase gen types typescript --project-id "abcwkgkiztruxwvfwabf" --schema public > supabase/types/supabase.ts
supabase gen types typescript --project-id "abcwkgkiztruxwvfwabf" --schema authenticated_access > supabase/types/supabase_authenticated_access.ts
supabase gen types typescript --project-id "rjljgqxktntquuftngcf" --schema public > supabase/types/supabase.ts
supabase gen types typescript --project-id "rjljgqxktntquuftngcf" --schema authenticated_access > supabase/types/supabase_authenticated_access.ts

@REM Start angular client and run tests
@REM pause
Expand Down
7 changes: 3 additions & 4 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import {defineConfig} from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on: any, config: any) {
// implement node event listeners here
},
baseUrl: 'http://localhost:4200',
defaultCommandTimeout: 10000
defaultCommandTimeout: 10000,
requestTimeout: 10000,
retries: 0
}
});
4 changes: 3 additions & 1 deletion cypress/e2e/00.1 landing-navigation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {Size, Sizes} from "../fixtures/size";

Sizes.forEach((size: Size): void => {
describe(`Landing page tests with screen size ${size.width} show that users can `, () => {
describe(`Landing page tests with screen size ${size.width} show that users can `, (): void => {
before((): void => {
})

beforeEach((): void => {
cy.viewport(size.width, size.height)
Expand Down
12 changes: 8 additions & 4 deletions cypress/e2e/01.1 auth.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import {ProfileTest} from "../fixtures/profile";
import {Size, Sizes} from "../fixtures/size";
import {userCreatedByCypress} from "../fixtures/user";
import {userCreatedByCypress} from "../../seed_and_test_data/user_created_by_cypress";
import {AuthData} from "../../seed_and_test_data/01_test_auth";

const newUser: ProfileTest = userCreatedByCypress;
const newUser: AuthData = userCreatedByCypress;
Sizes.forEach((size: Size): void => {
describe(`Auth tests with screen size ${size.width} show that users can `, () => {
describe(`Auth tests with screen size ${size.width} show that users can `, (): void => {
before((): void => {
cy.resetSupabase()
})

beforeEach((): void => {
cy.viewport(size.width, size.height)
cy.clearLocalStorage()
Expand Down
9 changes: 5 additions & 4 deletions cypress/e2e/01.2 app-navigation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Size, Sizes} from "../fixtures/size";
import {ProfileTest} from "../fixtures/profile";
import {seedReadUser2} from "../fixtures/user";
import {AUTH_DATA1, AuthData} from "../../seed_and_test_data/01_test_auth";

const profile1: ProfileTest = seedReadUser2;
const profile1: AuthData = AUTH_DATA1;

Sizes.forEach((size: Size): void => {
describe(`App navigation tests with screen size ${size.width} show that users can `, () => {
describe(`App navigation tests with screen size ${size.width} show that users can `, (): void => {
before(() => {
})

beforeEach((): void => {
cy.viewport(size.width, size.height)
Expand Down
39 changes: 22 additions & 17 deletions cypress/e2e/02.1 profile.cy.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
import {ProfileTest} from "../fixtures/profile";
import {seedReadUser3, seedWriteUser} from "../fixtures/user";
import {Size, Sizes} from "../fixtures/size";
import {AUTH_DATA1, AuthData} from "../../seed_and_test_data/01_test_auth";
import {Profile, PROFILE1, PROFILE2} from "../../seed_and_test_data/02_test_profiles";

const seedUser2: ProfileTest = seedReadUser3;
const userWhoEditsItsProfileAuthData: AuthData = AUTH_DATA1;
const userWhoEditsItsProfileProfileData: Profile = PROFILE1;
const userWhosProfileIsChecked: Profile = PROFILE2;

Sizes.forEach((size: Size): void => {
describe(`Profile tests with screen size ${size.width} show that users can `, () => {
describe(`Profile tests with screen size ${size.width} show that users can `, (): void => {

before((): void => {
cy.resetSupabase()
})

beforeEach((): void => {
cy.viewport(size.width, size.height)
cy.visit('landing/sign-in');
cy.signIn(seedWriteUser);
cy.signIn(userWhoEditsItsProfileAuthData);
})

const newFirstName = seedWriteUser.first_name as string + Math.random();
const newLastName = seedWriteUser.last_name as string + Math.random();
const newFirstName: string = userWhoEditsItsProfileProfileData.first_name as string + Math.random();
const newLastName: string = userWhoEditsItsProfileProfileData.last_name as string + Math.random();

it('edit its own profile data.', () => {
it('edit its own profile data.', (): void => {
cy.getDataCy('nav-profile-edit', 'nav-profile-edit-desktop')
.filter(':visible')
.first()
.click()
cy.getDataCy('edit-instruction')
.shouldBeVisible()

// cy.intercept('POST', 'https://abcwkgkiztruxwvfwabf.supabase.co/rest/v1/profiles').
cy.interceptSupabaseCall('update_user').as('updateProfile')
cy.getDataCy('firstName').clear()
cy.getDataCy('firstName').type(newFirstName)
Expand All @@ -37,14 +42,14 @@ Sizes.forEach((size: Size): void => {
cy.wait('@updateProfile')
})

it('view its own profile.', () => {
it('view its own profile.', (): void => {
cy.getDataCy('first-name')
.shouldBeVisible()
.contains(newFirstName)
.contains(newLastName)
})

it('change its profile image.', () => {
it('change its profile image.', (): void => {
cy.getDataCy('nav-profile-edit', 'nav-profile-edit-desktop')
.filter(':visible')
.first()
Expand Down Expand Up @@ -74,27 +79,27 @@ Sizes.forEach((size: Size): void => {

it('view other user profiles', (): void => {
cy.openSearchTab()
cy.getDataCy('search').type(seedUser2.first_name as string)
cy.getDataCy('search').type(userWhosProfileIsChecked.first_name as string)
cy.getDataCy('user-search-results')
.find('polity-search-profile-result')
.shouldBeVisible()
.contains(seedUser2.first_name as string)
.contains(userWhosProfileIsChecked.first_name as string)
.click()
cy.getDataCy('first-name')
.shouldBeVisible()
.contains(seedUser2.first_name as string)
.contains(userWhosProfileIsChecked.first_name as string)
cy.getDataCy('first-name')
.shouldBeVisible()
.contains(seedUser2.last_name as string)
.contains(userWhosProfileIsChecked.last_name as string)
})

it('not edit other users profiles', (): void => {
cy.openSearchTab()
cy.getDataCy('search').type(seedUser2.first_name as string)
cy.getDataCy('search').type(userWhosProfileIsChecked.first_name as string)
cy.getDataCy('user-search-results')
.find('polity-search-profile-result')
.shouldBeVisible()
.contains(seedUser2.first_name as string)
.contains(userWhosProfileIsChecked.first_name as string)
.click()
cy.getDataCy('nav-profile-edit', 'nav-profile-edit-desktop')
.should('not.exist')
Expand Down
19 changes: 14 additions & 5 deletions cypress/e2e/02.2 profile negative api tests.cy.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import {supabaseClient} from "../../src/app/auth/supabase-client";
import {POSTGRES_ERRORS} from "../fixtures/postgres_errors";
import {AuthTokenResponse} from "@supabase/supabase-js";
import {AUTH_DATA1, AUTH_DATA2, AuthData} from "../../seed_and_test_data/01_test_auth";

describe(`Negative api tests for profile_counter table show that `, async () => {
const signedInUserAuth: AuthData = AUTH_DATA1;
const otherUser: AuthData = AUTH_DATA2;

describe(`Negative api tests for profile_counter table show that `, async (): Promise<void> => {
let user_id: string | undefined;
let token: string | undefined;
const TEST_ID = '42e58ca1-2eb8-4651-93c2-cefba2e32f42';
const TEST_ID: string = otherUser.id;

before((): void => {
cy.resetSupabase()
})

beforeEach(async (): Promise<void> => {
cy.visit('landing/sign-in');
const response = await supabaseClient.auth.signInWithPassword(
const response: AuthTokenResponse = await supabaseClient.auth.signInWithPassword(
{
email: 'follow@seed.com',
password: '12345678',
email: signedInUserAuth.email,
password: signedInUserAuth.password,
}
)
user_id = response.data.user?.id
Expand Down
Loading
Loading